forked from ReDEnergy/SessionSync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtooltip-system.js
More file actions
52 lines (37 loc) · 1.43 KB
/
Copy pathtooltip-system.js
File metadata and controls
52 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
define(function(require, exports) {
'use strict';
// *****************************************************************************
// Modules
const { HTMLCreator } = require('../utils/dom');
const { WindowEvents } = require('../utils/global-events');
// *****************************************************************************
// TooltipSystem
function TooltipSystem()
{
var DomElem = HTMLCreator();
var tooltip = DomElem('div', {class : 'tooltip-system'});
// ------------------------------------------------------------------------
// Events
var hideTooltip = function hideTooltip()
{
tooltip.removeAttribute('active');
};
var showTooltip = function showTooltip(options)
{
tooltip.textContent = options.message;
tooltip.setAttribute('active', '');
var position = options.node.getBoundingClientRect();
tooltip.setAttribute('active', '');
tooltip.style.left = position.x - Math.floor((tooltip.clientWidth - options.node.clientWidth) / 2) + 'px';
tooltip.style.top = position.y - tooltip.clientHeight + 'px';
};
WindowEvents.on(document, 'ShowTooltip', showTooltip);
WindowEvents.on(document, 'HideTooltip', hideTooltip);
// ------------------------------------------------------------------------
// Public data
this.DOMRoot = tooltip;
}
// *****************************************************************************
// Public API
exports.TooltipSystem = TooltipSystem;
});