PluginProbe
AI Builder – Generate pages, blocks, images & translate with AI / 2.1.2
AI Builder – Generate pages, blocks, images & translate with AI v2.1.2
2.7.10 2.7.9 2.7.8 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.10 All 122 releases
ai-builder / assets / js / stats-tooltips.js

stats-tooltips.js in AI Builder – Generate pages, blocks, images & translate with AI 2.1.2, at assets/js/stats-tooltips.js

69 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 function createTip() {
3 var tip = document.createElement("div");
4 tip.className = "aibui-stats-tip";
5 tip.style.position = "fixed";
6 tip.style.zIndex = "99999";
7 tip.style.pointerEvents = "none";
8 tip.style.padding = "6px 8px";
9 tip.style.border = "1px solid #e5e7eb";
10 tip.style.background = "#111827";
11 tip.style.color = "#fff";
12 tip.style.fontSize = "12px";
13 tip.style.borderRadius = "6px";
14 tip.style.boxShadow = "0 4px 14px rgba(0,0,0,.15)";
15 tip.style.transform = "translate(-50%, -120%)";
16 tip.style.whiteSpace = "nowrap";
17 tip.style.display = "none";
18 document.body.appendChild(tip);
19 return tip;
20 }
21 var tipEl = createTip();
22 function showTip(text, x, y) {
23 tipEl.textContent = text;
24 tipEl.style.left = x + "px";
25 tipEl.style.top = y + "px";
26 tipEl.style.display = "block";
27 }
28 function hideTip() {
29 tipEl.style.display = "none";
30 }
31
32 function attach(root) {
33 root.addEventListener("pointerover", function (e) {
34 var t = e.target;
35 if (!(t instanceof Element)) return;
36 var label = t.getAttribute("data-label");
37 var value = t.getAttribute("data-value");
38 if (value == null) return;
39 var series = t.getAttribute("data-series") || "";
40 var parts = [];
41 if (series) parts.push(series);
42 if (label) parts.push(label);
43 parts.push(value);
44 var text = value;
45 var rect = t.getBoundingClientRect();
46 showTip(text, rect.left + rect.width / 2, rect.top);
47 });
48 root.addEventListener("pointermove", function (e) {
49 if (tipEl.style.display === "none") return;
50 showTip(tipEl.textContent, e.clientX, e.clientY - 10);
51 });
52 root.addEventListener("pointerout", function (e) {
53 hideTip();
54 });
55 }
56
57 function boot() {
58 var roots = document.querySelectorAll(".aibui-stats .aibui-stats-svg");
59 for (var i = 0; i < roots.length; i++) {
60 attach(roots[i]);
61 }
62 }
63 if (document.readyState === "loading") {
64 document.addEventListener("DOMContentLoaded", boot);
65 } else {
66 boot();
67 }
68 })();
69