[Info Bubble] Begin adding info gesture

Begin adding info gesture, which will attach info bubbles
to representations of domain objects. WTD-884.
This commit is contained in:
Victor Woeltjen 2015-05-22 12:03:58 -07:00
parent 179b0b46e5
commit 05a78f70e3
2 changed files with 64 additions and 0 deletions

View File

@ -34,6 +34,25 @@
"attributes": [ "bubbleTitle", "bubbleLayout" ],
"alias": "bubble"
}
],
"gestures": [
{
"key": "info",
"implementation": "gestures/InfoGesture.js",
"depends": [ "infoService" ]
}
],
"services": [
{
"key": "infoService",
"implementation": "services/InfoService.js",
"depends": [
"$compile",
"$document",
"$window",
"$rootScope"
]
}
]
}
}

View File

@ -0,0 +1,45 @@
/*global define*/
define(
[],
function () {
"use strict";
function InfoGesture(infoService, element, domainObject) {
var dismissBubble;
function hideBubble() {
if (dismissBubble) {
dismissBubble();
element.off('mouseleave', hideBubble);
dismissBubble = undefined;
}
}
function showBubble(event) {
dismissBubble = infoService.display(
"info-table",
domainObject.getName(),
[
{ name: "ID", value: domainObject.getId() }
],
[ event.clientX, event.clientY ]
);
element.on('mouseleave', hideBubble);
}
element.on('mouseenter', showBubble);
return {
destroy: function () {
hideBubble();
element.off('mouseenter', showBubble);
}
};
}
return InfoGesture;
}
);