Merge pull request #4 from nasa/open884

[Info Bubble] Add info bubble
This commit is contained in:
Victor Woeltjen 2015-06-17 11:47:34 -07:00
commit dc85d3c191
24 changed files with 939 additions and 178 deletions

View File

@ -7,6 +7,7 @@
"platform/commonUI/edit", "platform/commonUI/edit",
"platform/commonUI/dialog", "platform/commonUI/dialog",
"platform/commonUI/general", "platform/commonUI/general",
"platform/commonUI/inspect",
"platform/containment", "platform/containment",
"platform/telemetry", "platform/telemetry",
"platform/features/layout", "platform/features/layout",
@ -16,7 +17,6 @@
"platform/forms", "platform/forms",
"platform/persistence/queue", "platform/persistence/queue",
"platform/policy", "platform/policy",
"platform/entanglement",
"example/persistence", "example/persistence",
"example/generator" "example/generator"

View File

@ -57,7 +57,8 @@
{ {
"key": "grid-item", "key": "grid-item",
"templateUrl": "templates/items/grid-item.html", "templateUrl": "templates/items/grid-item.html",
"uses": [ "type", "action" ] "uses": [ "type", "action" ],
"gestures": [ "info", "menu" ]
}, },
{ {
"key": "object-header", "key": "object-header",

View File

@ -181,7 +181,7 @@
"key": "label", "key": "label",
"templateUrl": "templates/label.html", "templateUrl": "templates/label.html",
"uses": [ "type" ], "uses": [ "type" ],
"gestures": [ "drag", "menu" ] "gestures": [ "drag", "menu", "info" ]
}, },
{ {
"key": "node", "key": "node",

View File

@ -328,6 +328,10 @@ span {
*/ } */ }
/* line 72, ../sass/_global.scss */ /* line 72, ../sass/_global.scss */
mct-container {
display: block; }
/* line 76, ../sass/_global.scss */
.abs, .btn-menu span.l-click-area { .abs, .btn-menu span.l-click-area {
position: absolute; position: absolute;
top: 0; top: 0;
@ -337,51 +341,51 @@ span {
height: auto; height: auto;
width: auto; } width: auto; }
/* line 82, ../sass/_global.scss */ /* line 86, ../sass/_global.scss */
.code, .codehilite { .code, .codehilite {
font-family: "Lucida Console", monospace; font-family: "Lucida Console", monospace;
font-size: 0.7em; font-size: 0.7em;
line-height: 150%; line-height: 150%;
white-space: pre; } white-space: pre; }
/* line 89, ../sass/_global.scss */ /* line 93, ../sass/_global.scss */
.codehilite { .codehilite {
background-color: rgba(255, 255, 255, 0.1); background-color: rgba(255, 255, 255, 0.1);
padding: 1em; } padding: 1em; }
/* line 95, ../sass/_global.scss */ /* line 99, ../sass/_global.scss */
.align-right { .align-right {
text-align: right; } text-align: right; }
/* line 99, ../sass/_global.scss */ /* line 103, ../sass/_global.scss */
.centered { .centered {
text-align: center; } text-align: center; }
/* line 103, ../sass/_global.scss */ /* line 107, ../sass/_global.scss */
.no-margin { .no-margin {
margin: 0; } margin: 0; }
/* line 107, ../sass/_global.scss */ /* line 111, ../sass/_global.scss */
.colorKey { .colorKey {
color: #0099cc; } color: #0099cc; }
/* line 111, ../sass/_global.scss */ /* line 115, ../sass/_global.scss */
.ds { .ds {
-moz-box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px; -moz-box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px;
-webkit-box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px; -webkit-box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px;
box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px; } box-shadow: rgba(0, 0, 0, 0.7) 0 4px 10px 2px; }
/* line 115, ../sass/_global.scss */ /* line 119, ../sass/_global.scss */
.hide, .hide,
.hidden { .hidden {
display: none !important; } display: none !important; }
/* line 121, ../sass/_global.scss */ /* line 125, ../sass/_global.scss */
.paused:not(.s-btn):not(.icon-btn) { .paused:not(.s-btn):not(.icon-btn) {
border-color: #c56f01 !important; border-color: #c56f01 !important;
color: #c56f01 !important; } color: #c56f01 !important; }
/* line 127, ../sass/_global.scss */ /* line 131, ../sass/_global.scss */
.sep { .sep {
color: rgba(255, 255, 255, 0.2); } color: rgba(255, 255, 255, 0.2); }
@ -2611,7 +2615,7 @@ label.checkbox.custom {
position: absolute; position: absolute;
height: 200px; height: 200px;
width: 170px; width: 170px;
z-index: 59; } z-index: 70; }
/* line 172, ../sass/controls/_menus.scss */ /* line 172, ../sass/controls/_menus.scss */
.context-menu-holder .context-menu-wrapper { .context-menu-holder .context-menu-wrapper {
position: absolute; position: absolute;
@ -4215,137 +4219,101 @@ input[type="text"] {
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
/* line 24, ../sass/helpers/_bubbles.scss */ /* line 24, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper { .l-infobubble-wrapper {
position: absolute; -moz-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
z-index: 70; } -webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
/* line 27, ../sass/helpers/_bubbles.scss */ box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
.l-bubble-wrapper .l-bubble { position: relative;
padding: 5px 10px; } z-index: 50; }
/* line 29, ../sass/helpers/_bubbles.scss */ /* line 29, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-bubble .l-btn.close { .l-infobubble-wrapper .l-infobubble {
padding: 0 2px;
position: absolute;
right: 5px;
top: 5px; }
/* line 36, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .arw {
position: absolute; }
/* line 38, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .arw.arw-up {
bottom: 100%; }
/* line 42, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .arw.arw-down {
top: 100%; }
/* line 47, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble {
display: inline-block; display: inline-block;
max-width: 250px; } min-width: 100px;
/* line 51, ../sass/helpers/_bubbles.scss */ max-width: 300px;
.l-bubble-wrapper .l-infobubble:before { padding: 5px 10px; }
/* line 34, ../sass/helpers/_bubbles.scss */
.l-infobubble-wrapper .l-infobubble:before {
content: ""; content: "";
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; } height: 0; }
/* line 57, ../sass/helpers/_bubbles.scss */ /* line 40, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble table { .l-infobubble-wrapper .l-infobubble table {
width: 100%; } width: 100%; }
/* line 60, ../sass/helpers/_bubbles.scss */ /* line 43, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble table tr td { .l-infobubble-wrapper .l-infobubble table tr td {
padding: 2px 0; padding: 2px 0;
vertical-align: top; } vertical-align: top; }
/* line 67, ../sass/helpers/_bubbles.scss */ /* line 50, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble table tr td.label { .l-infobubble-wrapper .l-infobubble table tr td.label {
padding-right: 10px; padding-right: 10px;
white-space: nowrap; } white-space: nowrap; }
/* line 71, ../sass/helpers/_bubbles.scss */ /* line 54, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble table tr td.value { .l-infobubble-wrapper .l-infobubble table tr td.value {
white-space: nowrap; } white-space: nowrap; }
/* line 75, ../sass/helpers/_bubbles.scss */ /* line 58, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble table tr td.align-wrap { .l-infobubble-wrapper .l-infobubble table tr td.align-wrap {
white-space: normal; } white-space: normal; }
/* line 81, ../sass/helpers/_bubbles.scss */ /* line 64, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper .l-infobubble .title { .l-infobubble-wrapper .l-infobubble .title {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
margin-bottom: 5px; } margin-bottom: 5px; }
/* line 88, ../sass/helpers/_bubbles.scss */ /* line 71, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-left { .l-infobubble-wrapper.arw-left {
margin-left: 20px; } margin-left: 20px; }
/* line 90, ../sass/helpers/_bubbles.scss */ /* line 73, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-left .l-infobubble::before { .l-infobubble-wrapper.arw-left .l-infobubble::before {
right: 100%; right: 100%;
width: 0; width: 0;
height: 0; height: 0;
border-top: 6.66667px solid transparent; border-top: 6.66667px solid transparent;
border-bottom: 6.66667px solid transparent; border-bottom: 6.66667px solid transparent;
border-right: 10px solid #ddd; } border-right: 10px solid #ddd; }
/* line 96, ../sass/helpers/_bubbles.scss */ /* line 79, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-right { .l-infobubble-wrapper.arw-right {
margin-right: 20px; } margin-right: 20px; }
/* line 98, ../sass/helpers/_bubbles.scss */ /* line 81, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-right .l-infobubble::before { .l-infobubble-wrapper.arw-right .l-infobubble::before {
left: 100%; left: 100%;
width: 0; width: 0;
height: 0; height: 0;
border-top: 6.66667px solid transparent; border-top: 6.66667px solid transparent;
border-bottom: 6.66667px solid transparent; border-bottom: 6.66667px solid transparent;
border-left: 10px solid #ddd; } border-left: 10px solid #ddd; }
/* line 105, ../sass/helpers/_bubbles.scss */ /* line 88, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-top .l-infobubble::before { .l-infobubble-wrapper.arw-top .l-infobubble::before {
top: 20px; } top: 20px; }
/* line 111, ../sass/helpers/_bubbles.scss */ /* line 94, ../sass/helpers/_bubbles.scss */
.l-bubble-wrapper.arw-btm .l-infobubble::before { .l-infobubble-wrapper.arw-btm .l-infobubble::before {
bottom: 20px; } bottom: 20px; }
/* line 99, ../sass/helpers/_bubbles.scss */
/* line 121, ../sass/helpers/_bubbles.scss */ .l-infobubble-wrapper.arw-down {
.l-thumbsbubble-wrapper { margin-bottom: 10px; }
position: absolute; /* line 101, ../sass/helpers/_bubbles.scss */
left: 10px; .l-infobubble-wrapper.arw-down .l-infobubble::before {
right: 10px; left: 50%;
height: 183px; top: 100%;
width: auto; } margin-left: -5px;
/* line 128, ../sass/helpers/_bubbles.scss */ border-left: 5px solid transparent;
.l-thumbsbubble-wrapper .l-thumbsbubble { border-right: 5px solid transparent;
overflow: hidden; border-top: 7.5px solid #ddd; }
position: absolute; /* line 110, ../sass/helpers/_bubbles.scss */
top: 0px; .l-infobubble-wrapper .arw {
right: 0px;
bottom: 0px;
left: 0px;
width: auto;
height: auto; }
/* line 130, ../sass/helpers/_bubbles.scss */
.l-thumbsbubble-wrapper .l-thumbsbubble .l-image-thumbs-wrapper {
height: auto;
top: 5px !important;
right: 25px;
bottom: 5px !important;
left: 5px; }
/* line 135, ../sass/helpers/_bubbles.scss */
.l-thumbsbubble-wrapper .arw {
z-index: 2; } z-index: 2; }
/* line 140, ../sass/helpers/_bubbles.scss */ /* line 113, ../sass/helpers/_bubbles.scss */
.l-thumbsbubble-wrapper.arw-up .arw.arw-down, .l-thumbsbubble-wrapper.arw-down .arw.arw-up { .l-infobubble-wrapper.arw-up .arw.arw-down, .l-infobubble-wrapper.arw-down .arw.arw-up {
display: none; } display: none; }
/* line 150, ../sass/helpers/_bubbles.scss */ /* line 120, ../sass/helpers/_bubbles.scss */
.s-bubble {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px; }
/* line 156, ../sass/helpers/_bubbles.scss */
.l-thumbsbubble-wrapper .arw-up { .l-thumbsbubble-wrapper .arw-up {
width: 0; width: 0;
height: 0; height: 0;
border-left: 6.66667px solid transparent; border-left: 6.66667px solid transparent;
border-right: 6.66667px solid transparent; border-right: 6.66667px solid transparent;
border-bottom: 10px solid #4d4d4d; } border-bottom: 10px solid #4d4d4d; }
/* line 159, ../sass/helpers/_bubbles.scss */ /* line 123, ../sass/helpers/_bubbles.scss */
.l-thumbsbubble-wrapper .arw-down { .l-thumbsbubble-wrapper .arw-down {
width: 0; width: 0;
height: 0; height: 0;
@ -4353,27 +4321,33 @@ input[type="text"] {
border-right: 6.66667px solid transparent; border-right: 6.66667px solid transparent;
border-top: 10px solid #4d4d4d; } border-top: 10px solid #4d4d4d; }
/* line 163, ../sass/helpers/_bubbles.scss */ /* line 127, ../sass/helpers/_bubbles.scss */
.s-infobubble { .s-infobubble {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
box-shadow: rgba(0, 0, 0, 0.4) 0 1px 5px;
background: #ddd; background: #ddd;
color: #666; color: #666;
font-size: 0.8rem; } font-size: 0.8rem; }
/* line 168, ../sass/helpers/_bubbles.scss */ /* line 134, ../sass/helpers/_bubbles.scss */
.s-infobubble .title { .s-infobubble .title {
color: #333333; color: #333333;
font-weight: bold; } font-weight: bold; }
/* line 173, ../sass/helpers/_bubbles.scss */ /* line 139, ../sass/helpers/_bubbles.scss */
.s-infobubble tr td { .s-infobubble tr td {
border-top: 1px solid #c4c4c4; border-top: 1px solid #c4c4c4;
font-size: 0.9em; } font-size: 0.9em; }
/* line 177, ../sass/helpers/_bubbles.scss */ /* line 143, ../sass/helpers/_bubbles.scss */
.s-infobubble tr:first-child td { .s-infobubble tr:first-child td {
border-top: none; } border-top: none; }
/* line 181, ../sass/helpers/_bubbles.scss */ /* line 147, ../sass/helpers/_bubbles.scss */
.s-infobubble .value { .s-infobubble .value {
color: #333333; } color: #333333; }
/* line 186, ../sass/helpers/_bubbles.scss */ /* line 152, ../sass/helpers/_bubbles.scss */
.s-thumbsbubble { .s-thumbsbubble {
background: #4d4d4d; background: #4d4d4d;
color: #b3b3b3; } color: #b3b3b3; }

View File

@ -67,6 +67,8 @@ $colorLimitRed: #aa0000;
$colorTelemFresh: #fff; $colorTelemFresh: #fff;
$colorTelemStale: #888; $colorTelemStale: #888;
$styleTelemState: italic; $styleTelemState: italic;
$colorInfoBubbleFg: #666;
$colorInfoBubbleBg: #ddd;
// Ratios // Ratios
$ltGamma: 20%; $ltGamma: 20%;
@ -150,6 +152,9 @@ $imageThumbPad: 1px;
// Bubbles // Bubbles
$bubbleArwSize: 10px; $bubbleArwSize: 10px;
$bubblePad: $interiorMargin; $bubblePad: $interiorMargin;
$bubbleMinW: 100px;
$bubbleMaxW: 300px;
// Timing // Timing
$controlFadeMs: 100ms; $controlFadeMs: 100ms;

View File

@ -69,6 +69,10 @@ span {
*/ */
} }
mct-container {
display: block;
}
.abs { .abs {
position: absolute; position: absolute;
top: 0; top: 0;

View File

@ -168,7 +168,7 @@
position: absolute; position: absolute;
height: 200px; height: 200px;
width: 170px; width: 170px;
z-index: 59; z-index: 70;
.context-menu-wrapper { .context-menu-wrapper {
position: absolute; position: absolute;
height: 100%; height: 100%;

View File

@ -21,33 +21,16 @@
*****************************************************************************/ *****************************************************************************/
//************************************************* LAYOUT //************************************************* LAYOUT
.l-bubble-wrapper { .l-infobubble-wrapper {
position: absolute; $arwSize: 5px;
z-index: 70; @include box-shadow(rgba(black, 0.4) 0 1px 5px);
.l-bubble { position: relative;
padding: $bubblePad $bubblePad*2; z-index: 50;
.l-btn.close {
padding: 0 2px;
position: absolute;
right: $interiorMargin;
top: $interiorMargin;
}
}
.arw {
position: absolute;
&.arw-up {
bottom: 100%;
}
&.arw-down {
top: 100%;
}
}
.l-infobubble { .l-infobubble {
display: inline-block; display: inline-block;
max-width: 250px; min-width: $bubbleMinW;
//padding: 5px 10px; max-width: $bubbleMaxW;
padding: 5px 10px;
&:before { &:before {
content:""; content:"";
position: absolute; position: absolute;
@ -114,27 +97,17 @@
} }
&.arw-down { &.arw-down {
margin-bottom: $arwSize*2;
} .l-infobubble::before {
} left: 50%;
top: 100%;
.l-thumbsbubble-wrapper { margin-left: -1 * $arwSize;
$closeBtnD: 15px; border-left: $arwSize solid transparent;
position: absolute; border-right: $arwSize solid transparent;
left: $interiorMarginLg; border-top: ($arwSize * 1.5) solid $colorInfoBubbleBg;
right: $interiorMarginLg;
height: $imageThumbsWrapperH + $bubblePad*2 + $interiorMargin;
width: auto;
.l-thumbsbubble {
@include absPosDefault();
.l-image-thumbs-wrapper {
height: auto;
top: $bubblePad !important; right: $closeBtnD + ($interiorMargin*2); bottom: $bubblePad !important; left: $bubblePad;
} }
} }
.arw { .arw {
//left: 50%;
//margin-left: $bubbleArwSize / -2;
z-index: 2; z-index: 2;
} }
&.arw-up .arw.arw-down, &.arw-up .arw.arw-down,
@ -143,15 +116,6 @@
//************************************************* LOOK AND FEEL //************************************************* LOOK AND FEEL
.s-bubble-wrapper {
//@include box-shadow(rgba(black, 0.4) 0 1px 5px);
}
.s-bubble {
@include border-radius($basicCr);
@include box-shadow(rgba(black, 0.4) 0 1px 5px);
}
.l-thumbsbubble-wrapper { .l-thumbsbubble-wrapper {
.arw-up { .arw-up {
@include triangle('up', $bubbleArwSize, 1.5, $colorThumbsBubbleBg); @include triangle('up', $bubbleArwSize, 1.5, $colorThumbsBubbleBg);
@ -162,6 +126,8 @@
} }
.s-infobubble { .s-infobubble {
$emFg: darken($colorInfoBubbleFg, 20%); $emFg: darken($colorInfoBubbleFg, 20%);
@include border-radius($basicCr);
@include box-shadow(rgba(black, 0.4) 0 1px 5px);
background: $colorInfoBubbleBg; background: $colorInfoBubbleBg;
color: $colorInfoBubbleFg; color: $colorInfoBubbleFg;
font-size: 0.8rem; font-size: 0.8rem;

View File

@ -1,20 +1,50 @@
{ {
"extensions": { "extensions": {
"types": [ "templates": [
{ {
"key": "infobubble", "key": "info-table",
"name": "Info Bubble", "templateUrl": "info-table.html"
"glyph": "\u00EA", },
"description": "Static markup for info bubbles", {
"features": [ "creation" ] "key": "info-bubble",
"templateUrl": "info-bubble.html"
} }
], ],
"views": [ "containers": [
{ {
"templateUrl": "infobubble.html", "key": "bubble",
"name": "Info Bubble", "templateUrl": "bubble.html",
"type": "infobubble", "attributes": [ "bubbleTitle", "bubbleLayout" ],
"key": "infobubble" "alias": "bubble"
}
],
"gestures": [
{
"key": "info",
"implementation": "gestures/InfoGesture.js",
"depends": [
"$timeout",
"infoService",
"INFO_HOVER_DELAY"
]
}
],
"services": [
{
"key": "infoService",
"implementation": "services/InfoService.js",
"depends": [
"$compile",
"$document",
"$window",
"$rootScope"
]
}
],
"constants": [
{
"key": "INFO_HOVER_DELAY",
"value": 500
} }
] ]
} }

View File

@ -0,0 +1,9 @@
<div class="t-infobubble s-infobubble l-infobubble-wrapper {{bubble.bubbleLayout}}">
<div class="l-infobubble">
<div ng-show="bubble.bubbleTitle.length > 0"
class="title">
{{bubble.bubbleTitle}}
</div>
<span ng-transclude></span>
</div>
</div>

View File

@ -0,0 +1,7 @@
<mct-container key="bubble"
bubble-title="{{parameters.title}}"
bubble-layout="{{parameters.layout}}">
<mct-include key="info-table"
ng-model="ngModel">
</mct-include>
</mct-container>

View File

@ -0,0 +1,8 @@
<table>
<tr ng-repeat="property in ngModel">
<td class="label">{{property.name}}</td>
<td title="{{property.value}}" class="value align-{{property.align}}">
{{property.value}}
</td>
</tr>
</table>

View File

@ -0,0 +1,35 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define({
BUBBLE_TEMPLATE: "<mct-container key=\"bubble\" " +
"bubble-title=\"{{bubbleTitle}}\" " +
"bubble-layout=\"{{bubbleLayout}}\">" +
"<mct-include key=\"bubbleTemplate\" ng-model=\"bubbleModel\">" +
"</mct-include>" +
"</mct-container>",
// Pixel offset for bubble, to align arrow position
BUBBLE_OFFSET: [ 0, -26 ],
// Max width and margins allowed for bubbles; defined in /platform/commonUI/general/res/sass/_constants.scss
BUBBLE_MARGIN_LR: 10,
BUBBLE_MAX_WIDTH: 300
});

View File

@ -0,0 +1,121 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
[],
function () {
"use strict";
/**
* The `info` gesture displays domain object metadata in a
* bubble on hover.
*
* @constructor
* @param $timeout Angular's `$timeout`
* @param {InfoService} infoService a service which shows info bubbles
* @param {number} DELAY delay, in milliseconds, before bubble appears
* @param element jqLite-wrapped DOM element
* @param {DomainObject} domainObject the domain object for which to
* show information
*/
function InfoGesture($timeout, infoService, DELAY, element, domainObject) {
var dismissBubble,
pendingBubble,
mousePosition,
scopeOff;
function trackPosition(event) {
// Record mouse position, so bubble can be shown at latest
// mouse position (not just where the mouse entered)
mousePosition = [ event.clientX, event.clientY ];
}
function hideBubble() {
// If a bubble is showing, dismiss it
if (dismissBubble) {
dismissBubble();
element.off('mouseleave', hideBubble);
dismissBubble = undefined;
}
// If a bubble will be shown on a timeout, cancel that
if (pendingBubble) {
$timeout.cancel(pendingBubble);
element.off('mousemove', trackPosition);
element.off('mouseleave', hideBubble);
pendingBubble = undefined;
}
// Also clear mouse position so we don't have a ton of tiny
// arrays allocated while user mouses over things
mousePosition = undefined;
}
function showBubble(event) {
trackPosition(event);
// Also need to track position during hover
element.on('mousemove', trackPosition);
// Show the bubble, after a suitable delay (if mouse has
// left before this time is up, this will be canceled.)
pendingBubble = $timeout(function () {
dismissBubble = infoService.display(
"info-table",
domainObject.getModel().name,
domainObject.useCapability('metadata'),
mousePosition
);
element.off('mousemove', trackPosition);
pendingBubble = undefined;
}, DELAY);
element.on('mouseleave', hideBubble);
}
// Show bubble (on a timeout) on mouse over
element.on('mouseenter', showBubble);
// Also make sure we dismiss bubble if representation is destroyed
// before the mouse actually leaves it
scopeOff = element.scope().$on('$destroy', hideBubble);
return {
/**
* Detach any event handlers associated with this gesture.
* @memberof InfoGesture
* @method
*/
destroy: function () {
// Dismiss any active bubble...
hideBubble();
// ...and detach listeners
element.off('mouseenter', showBubble);
scopeOff();
}
};
}
return InfoGesture;
}
);

View File

@ -0,0 +1,95 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define*/
define(
['../InfoConstants'],
function (InfoConstants) {
"use strict";
var BUBBLE_TEMPLATE = InfoConstants.BUBBLE_TEMPLATE,
OFFSET = InfoConstants.BUBBLE_OFFSET;
/**
* Displays informative content ("info bubbles") for the user.
* @constructor
*/
function InfoService($compile, $document, $window, $rootScope) {
function display(templateKey, title, content, position) {
var body = $document.find('body'),
scope = $rootScope.$new(),
winDim = [$window.innerWidth, $window.innerHeight],
bubbleSpaceLR = InfoConstants.BUBBLE_MARGIN_LR + InfoConstants.BUBBLE_MAX_WIDTH,
goLeft = position[0] > (winDim[0] - bubbleSpaceLR),
goUp = position[1] > (winDim[1] / 2),
bubble;
// Pass model & container parameters into the scope
scope.bubbleModel = content;
scope.bubbleTemplate = templateKey;
scope.bubbleLayout = (goUp ? 'arw-btm' : 'arw-top') + ' ' +
(goLeft ? 'arw-right' : 'arw-left');
scope.bubbleTitle = title;
// Create the context menu
bubble = $compile(BUBBLE_TEMPLATE)(scope);
// Position the bubble
bubble.css('position', 'absolute');
if (goLeft) {
bubble.css('right', (winDim[0] - position[0] + OFFSET[0]) + 'px');
} else {
bubble.css('left', position[0] + OFFSET[0] + 'px');
}
if (goUp) {
bubble.css('bottom', (winDim[1] - position[1] + OFFSET[1]) + 'px');
} else {
bubble.css('top', position[1] + OFFSET[1] + 'px');
}
// Add the menu to the body
body.append(bubble);
// Return a function to dismiss the bubble
return function () { bubble.remove(); };
}
return {
/**
* Display an info bubble at the specified location.
* @param {string} templateKey template to place in bubble
* @param {string} title title for the bubble
* @param {*} content content to pass to the template, via
* `ng-model`
* @param {number[]} x,y position of the info bubble, in
* pixel coordinates.
* @returns {Function} a function that may be invoked to
* dismiss the info bubble
*/
display: display
};
}
return InfoService;
}
);

View File

@ -0,0 +1,157 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/gestures/InfoGesture'],
function (InfoGesture) {
"use strict";
describe("The info gesture", function () {
var mockTimeout,
mockInfoService,
testDelay = 12321,
mockElement,
mockDomainObject,
mockScope,
mockOff,
testMetadata,
mockPromise,
mockHide,
gesture;
function fireEvent(evt, value) {
mockElement.on.calls.forEach(function (call) {
if (call.args[0] === evt) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockTimeout = jasmine.createSpy('$timeout');
mockTimeout.cancel = jasmine.createSpy('cancel');
mockInfoService = jasmine.createSpyObj(
'infoService',
[ 'display' ]
);
mockElement = jasmine.createSpyObj(
'element',
[ 'on', 'off', 'scope', 'css' ]
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
);
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
mockOff = jasmine.createSpy('$off');
testMetadata = [ { name: "Test name", value: "Test value" } ];
mockPromise = jasmine.createSpyObj('promise', ['then']);
mockHide = jasmine.createSpy('hide');
mockDomainObject.getModel.andReturn({ name: "Test Object" });
mockDomainObject.useCapability.andCallFake(function (c) {
return (c === 'metadata') ? testMetadata : undefined;
});
mockElement.scope.andReturn(mockScope);
mockScope.$on.andReturn(mockOff);
mockTimeout.andReturn(mockPromise);
mockInfoService.display.andReturn(mockHide);
gesture = new InfoGesture(
mockTimeout,
mockInfoService,
testDelay,
mockElement,
mockDomainObject
);
});
it("listens for mouseenter on the representation", function () {
expect(mockElement.on)
.toHaveBeenCalledWith('mouseenter', jasmine.any(Function));
});
it("displays an info bubble on a delay after mouseenter", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
expect(mockTimeout)
.toHaveBeenCalledWith(jasmine.any(Function), testDelay);
mockTimeout.mostRecentCall.args[0]();
expect(mockInfoService.display).toHaveBeenCalledWith(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1977, 42 ]
);
});
it("does not display info bubble if mouse leaves too soon", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
fireEvent("mouseleave", { clientX: 1977, clientY: 42 });
expect(mockTimeout.cancel).toHaveBeenCalledWith(mockPromise);
expect(mockInfoService.display).not.toHaveBeenCalled();
});
it("hides a shown bubble when mouse leaves", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
mockTimeout.mostRecentCall.args[0]();
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
fireEvent("mouseleave", {});
expect(mockHide).toHaveBeenCalled();
});
it("tracks mouse position", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
fireEvent("mousemove", { clientX: 1999, clientY: 11 });
fireEvent("mousemove", { clientX: 1984, clientY: 11 });
mockTimeout.mostRecentCall.args[0]();
// Should have displayed at the latest observed mouse position
expect(mockInfoService.display).toHaveBeenCalledWith(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1984, 11 ]
);
});
it("hides shown bubbles when destroyed", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
mockTimeout.mostRecentCall.args[0]();
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
gesture.destroy();
expect(mockHide).toHaveBeenCalled();
});
it("detaches listeners when destroyed", function () {
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
gesture.destroy();
mockElement.on.calls.forEach(function (call) {
expect(mockElement.off).toHaveBeenCalledWith(
call.args[0],
call.args[1]
);
});
});
});
}
);

View File

@ -0,0 +1,131 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/services/InfoService', '../../src/InfoConstants'],
function (InfoService, InfoConstants) {
"use strict";
describe("The info service", function () {
var mockCompile,
mockDocument,
testWindow,
mockRootScope,
mockCompiledTemplate,
testScope,
mockBody,
mockElement,
service;
beforeEach(function () {
mockCompile = jasmine.createSpy('$compile');
mockDocument = jasmine.createSpyObj('$document', ['find']);
testWindow = { innerWidth: 1000, innerHeight: 100 };
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
mockCompiledTemplate = jasmine.createSpy('template');
testScope = {};
mockBody = jasmine.createSpyObj('body', ['append']);
mockElement = jasmine.createSpyObj('element', ['css', 'remove']);
mockDocument.find.andCallFake(function (tag) {
return tag === 'body' ? mockBody : undefined;
});
mockCompile.andReturn(mockCompiledTemplate);
mockCompiledTemplate.andReturn(mockElement);
mockRootScope.$new.andReturn(testScope);
service = new InfoService(
mockCompile,
mockDocument,
testWindow,
mockRootScope
);
});
it("creates elements and appends them to the body to display", function () {
service.display('', '', {}, [0, 0]);
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
});
it("provides a function to remove displayed info bubbles", function () {
var fn = service.display('', '', {}, [0, 0]);
expect(mockElement.remove).not.toHaveBeenCalled();
fn();
expect(mockElement.remove).toHaveBeenCalled();
});
describe("depending on mouse position", function () {
// Positioning should vary based on quadrant in window,
// which is 1000 x 100 in this test case.
it("displays from the top-left in the top-left quadrant", function () {
service.display('', '', {}, [250, 25]);
expect(mockElement.css).toHaveBeenCalledWith(
'left',
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'top',
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the top-right in the top-right quadrant", function () {
service.display('', '', {}, [700, 25]);
expect(mockElement.css).toHaveBeenCalledWith(
'right',
(300 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'top',
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the bottom-left in the bottom-left quadrant", function () {
service.display('', '', {}, [250, 70]);
expect(mockElement.css).toHaveBeenCalledWith(
'left',
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'bottom',
(30 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
it("displays from the bottom-right in the bottom-right quadrant", function () {
service.display('', '', {}, [800, 60]);
expect(mockElement.css).toHaveBeenCalledWith(
'right',
(200 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
);
expect(mockElement.css).toHaveBeenCalledWith(
'bottom',
(40 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
);
});
});
});
}
);

View File

@ -0,0 +1,4 @@
[
"gestures/InfoGesture",
"services/InfoService"
]

View File

@ -165,6 +165,10 @@
"implementation": "capabilities/PersistenceCapability.js", "implementation": "capabilities/PersistenceCapability.js",
"depends": [ "persistenceService", "PERSISTENCE_SPACE" ] "depends": [ "persistenceService", "PERSISTENCE_SPACE" ]
}, },
{
"key": "metadata",
"implementation": "capabilities/MetadataCapability.js"
},
{ {
"key": "mutation", "key": "mutation",
"implementation": "capabilities/MutationCapability.js", "implementation": "capabilities/MutationCapability.js",

View File

@ -0,0 +1,92 @@
/*global define*/
define(
['moment'],
function (moment) {
"use strict";
/**
* A piece of information about a domain object.
* @typedef {Object} MetadataProperty
* @property {string} name the human-readable name of this property
* @property {string} value the human-readable value of this property,
* for this specific domain object
*/
var TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
/**
* Implements the `metadata` capability of a domain object, providing
* properties of that object for display.
*
* Usage: `domainObject.useCapability("metadata")`
*
* ...which will return an array of objects containing `name` and
* `value` properties describing that domain object (suitable for
* display.)
*
* @constructor
*/
function MetadataCapability(domainObject) {
var model = domainObject.getModel();
function hasDisplayableValue(metadataProperty) {
var t = typeof metadataProperty.value;
return (t === 'string' || t === 'number');
}
function formatTimestamp(timestamp) {
return typeof timestamp === 'number' ?
(moment.utc(timestamp).format(TIME_FORMAT) + " UTC") :
undefined;
}
function getProperties() {
var type = domainObject.getCapability('type');
function lookupProperty(typeProperty) {
return {
name: typeProperty.getDefinition().name,
value: typeProperty.getValue(model)
};
}
return (type ? type.getProperties() : []).map(lookupProperty);
}
function getCommonMetadata() {
var type = domainObject.getCapability('type');
// Note that invalid values will be filtered out later
return [
{
name: "Updated",
value: formatTimestamp(model.modified)
},
{
name: "Type",
value: type && type.getName()
},
{
name: "ID",
value: domainObject.getId()
}
];
}
function getMetadata() {
return getProperties().concat(getCommonMetadata())
.filter(hasDisplayableValue);
}
return {
/**
* Get metadata about this object.
* @returns {MetadataProperty[]} metadata about this object
*/
invoke: getMetadata
};
}
return MetadataCapability;
}
);

View File

@ -0,0 +1,101 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
['../../src/capabilities/MetadataCapability'],
function (MetadataCapability) {
"use strict";
describe("The metadata capability", function () {
var mockDomainObject,
mockType,
mockProperties,
testModel,
metadata;
function getCapability(key) {
return key === 'type' ? mockType : undefined;
}
function findValue(properties, name) {
var i;
for (i = 0; i < properties.length; i += 1) {
if (properties[i].name === name) {
return properties[i].value;
}
}
}
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
'domainObject',
['getId', 'getCapability', 'useCapability', 'getModel']
);
mockType = jasmine.createSpyObj(
'type',
['getProperties', 'getName']
);
mockProperties = ['a', 'b', 'c'].map(function (k) {
var mockProperty = jasmine.createSpyObj(
'property-' + k,
['getValue', 'getDefinition']
);
mockProperty.getValue.andReturn("Value " + k);
mockProperty.getDefinition.andReturn({ name: "Property " + k});
return mockProperty;
});
testModel = { name: "" };
mockDomainObject.getId.andReturn("Test id");
mockDomainObject.getModel.andReturn(testModel);
mockDomainObject.getCapability.andCallFake(getCapability);
mockDomainObject.useCapability.andCallFake(getCapability);
mockType.getProperties.andReturn(mockProperties);
mockType.getName.andReturn("Test type");
metadata = new MetadataCapability(mockDomainObject);
});
it("reads properties from the domain object model", function () {
metadata.invoke();
mockProperties.forEach(function (mockProperty) {
expect(mockProperty.getValue).toHaveBeenCalledWith(testModel);
});
});
it("reports type-specific properties", function () {
var properties = metadata.invoke();
expect(findValue(properties, 'Property a')).toEqual("Value a");
expect(findValue(properties, 'Property b')).toEqual("Value b");
expect(findValue(properties, 'Property c')).toEqual("Value c");
});
it("reports generic properties", function () {
var properties = metadata.invoke();
expect(findValue(properties, 'ID')).toEqual("Test id");
expect(findValue(properties, 'Type')).toEqual("Test type");
});
});
}
);

View File

@ -9,6 +9,7 @@
"capabilities/ContextualDomainObject", "capabilities/ContextualDomainObject",
"capabilities/CoreCapabilityProvider", "capabilities/CoreCapabilityProvider",
"capabilities/DelegationCapability", "capabilities/DelegationCapability",
"capabilities/MetadataCapability",
"capabilities/MutationCapability", "capabilities/MutationCapability",
"capabilities/PersistenceCapability", "capabilities/PersistenceCapability",
"capabilities/RelationshipCapability", "capabilities/RelationshipCapability",

View File

@ -84,6 +84,22 @@ define(
// Should have cleared out the time stamp // Should have cleared out the time stamp
expect(mockScope.ngModel.test).toBeUndefined(); expect(mockScope.ngModel.test).toBeUndefined();
}); });
it("initializes form fields with values from ng-model", function () {
mockScope.ngModel = { test: 1417215313000 };
mockScope.field = "test";
mockScope.$watch.calls.forEach(function (call) {
if (call.args[0] === 'ngModel[field]') {
call.args[1](mockScope.ngModel.test);
}
});
expect(mockScope.datetime).toEqual({
date: "2014-332",
hour: "22",
min: "55",
sec: "13"
});
});
}); });
} }
); );

View File

@ -22,8 +22,8 @@
/*global define,moment*/ /*global define,moment*/
define( define(
['../lib/moment.min.js'], ['moment'],
function () { function (moment) {
"use strict"; "use strict";
// Date format to use for domain values; in particular, // Date format to use for domain values; in particular,