Mercurial > hg > index.fcgi > www > www-1
comparison life_calendar/tooltip.js @ 138:3bc6b79919dc
myrss2: FEEDS: Add Rest Of World; update Quillete; remove old feeds
author | paulo |
---|---|
date | Thu, 23 Mar 2023 07:52:22 +0000 |
parents | 256b8df1c686 |
children |
comparison
equal
deleted
inserted
replaced
0:4b88785d1ddd | 1:77498b839fdc |
---|---|
7 | 7 |
8 function getTooltipElm() { | 8 function getTooltipElm() { |
9 return document.querySelector("#" + _tt_options.tooltipId); | 9 return document.querySelector("#" + _tt_options.tooltipId); |
10 } | 10 } |
11 | 11 |
12 function adjustTooltip(evt, tooltipElm, title, text) { | 12 function adjustTooltip(evt, tooltipElm, title, text, subtext) { |
13 var offset = _tt_options.offsetDefault; | 13 var offset = _tt_options.offsetDefault; |
14 var scrollY = window.scrollY || window.pageYOffset; | 14 var scrollY = window.scrollY || window.pageYOffset; |
15 var scrollX = window.scrollX || window.pageXOffset; | 15 var scrollX = window.scrollX || window.pageXOffset; |
16 var tooltipTop = evt.pageY + offset; | 16 var tooltipTop = evt.pageY + offset; |
17 var tooltipLeft = evt.pageX + offset; | 17 var tooltipLeft = evt.pageX + offset; |
20 tooltipLeft = (tooltipLeft - scrollX + tooltipElm.offsetWidth + 20 >= window.innerWidth ? (tooltipLeft - tooltipElm.offsetWidth - 20) : tooltipLeft); | 20 tooltipLeft = (tooltipLeft - scrollX + tooltipElm.offsetWidth + 20 >= window.innerWidth ? (tooltipLeft - tooltipElm.offsetWidth - 20) : tooltipLeft); |
21 | 21 |
22 tooltipElm.style.top = tooltipTop + "px"; | 22 tooltipElm.style.top = tooltipTop + "px"; |
23 tooltipElm.style.left = tooltipLeft + "px"; | 23 tooltipElm.style.left = tooltipLeft + "px"; |
24 | 24 |
25 setTooltipText(tooltipElm, title, text); | 25 setTooltipText(tooltipElm, title, text, subtext); |
26 } | 26 } |
27 | 27 |
28 function removeTooltip() { | 28 function removeTooltip() { |
29 document.querySelector("body").removeChild(getTooltipElm()); | 29 document.querySelector("body").removeChild(getTooltipElm()); |
30 } | 30 } |
31 | 31 |
32 function createTooltip(evt, title, text) { | 32 function createTooltip(evt, title, text, subtext) { |
33 var tooltipElm = getTooltipElm(); | 33 var tooltipElm = getTooltipElm(); |
34 | 34 |
35 if (!tooltipElm) { | 35 if (!tooltipElm) { |
36 tooltipElm = document.createElement("div"); | 36 tooltipElm = document.createElement("div"); |
37 tooltipElm.appendChild(document.createElement("h1")); | 37 tooltipElm.appendChild(document.createElement("h1")); |
38 tooltipElm.appendChild(document.createElement("h2")); | 38 tooltipElm.appendChild(document.createElement("h2")); |
39 tooltipElm.appendChild(document.createElement("h3")); | |
39 | 40 |
40 tooltipElm.style.position = "absolute"; | 41 tooltipElm.style.position = "absolute"; tooltipElm.setAttribute("id", _tt_options.tooltipId); |
41 tooltipElm.setAttribute("id", _tt_options.tooltipId); | |
42 | 42 |
43 document.querySelector("body").appendChild(tooltipElm); | 43 document.querySelector("body").appendChild(tooltipElm); |
44 } | 44 } |
45 | 45 |
46 adjustTooltip(evt, tooltipElm, title, text); | 46 adjustTooltip(evt, tooltipElm, title, text, subtext); |
47 } | 47 } |
48 | 48 |
49 function setTooltipText(tooltipElm, title, text) { | 49 function setTooltipText(tooltipElm, title, text, subtext) { |
50 var eTitle = tooltipElm.children[0]; | 50 var eTitle = tooltipElm.children[0]; |
51 var eText = tooltipElm.children[1]; | 51 var eText = tooltipElm.children[1]; |
52 var eSubText = tooltipElm.children[2]; | |
52 if (eTitle && title) { | 53 if (eTitle && title) { |
53 eTitle.textContent = title; | 54 eTitle.textContent = title; |
54 } | 55 } |
55 if (eText && text) { | 56 if (eText && text) { |
56 eText.textContent = text; | 57 eText.textContent = text; |
57 } | 58 } |
59 if (eSubText) { | |
60 eSubText.textContent = subtext; | |
61 } | |
58 } | 62 } |