-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathtips.js
46 lines (39 loc) · 1.3 KB
/
tips.js
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
var currentTip = null;
var currentTipElement = null;
function hideTip(evt, name, unique) {
var el = document.getElementById(name);
el.style.display = "none";
currentTip = null;
}
function findPos(obj) {
// no idea why, but it behaves differently in webbrowser component
if (window.location.search == "?inapp")
return [obj.offsetLeft + 10, obj.offsetTop + 30];
var curleft = 0;
var curtop = obj.offsetHeight;
while (obj && obj.className != "page-inner") {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
obj = obj.offsetParent;
};
return [curleft, curtop];
}
function hideUsingEsc(e) {
if (!e) { e = event; }
hideTip(e, currentTipElement, currentTip);
}
function showTip(evt, name, unique, owner) {
document.onkeydown = hideUsingEsc;
if (currentTip == unique) return;
currentTip = unique;
currentTipElement = name;
var pos = findPos(owner ? owner : (evt.srcElement ? evt.srcElement : evt.target));
var posx = pos[0];
var posy = pos[1];
var el = document.getElementById(name);
var parent = (document.documentElement == null) ? document.body : document.documentElement;
el.style.position = "absolute";
el.style.left = posx + "px";
el.style.top = posy + "px";
el.style.display = "block";
}