From 05a78f70e390770cb77d7304d3750421a015f999 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 22 May 2015 12:03:58 -0700 Subject: [PATCH] [Info Bubble] Begin adding info gesture Begin adding info gesture, which will attach info bubbles to representations of domain objects. WTD-884. --- platform/commonUI/inspect/bundle.json | 19 ++++++++ .../inspect/src/gestures/InfoGesture.js | 45 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 platform/commonUI/inspect/src/gestures/InfoGesture.js diff --git a/platform/commonUI/inspect/bundle.json b/platform/commonUI/inspect/bundle.json index 55e1c76767..74fb65260e 100644 --- a/platform/commonUI/inspect/bundle.json +++ b/platform/commonUI/inspect/bundle.json @@ -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" + ] + } ] } } \ No newline at end of file diff --git a/platform/commonUI/inspect/src/gestures/InfoGesture.js b/platform/commonUI/inspect/src/gestures/InfoGesture.js new file mode 100644 index 0000000000..dadd81e93d --- /dev/null +++ b/platform/commonUI/inspect/src/gestures/InfoGesture.js @@ -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; + + } + +); \ No newline at end of file