2 * JavaScript code to create "bubble tooltips"
4 * Copyright (C) 2006 Alessandro Fulciniti [http://web-graphics.com]
5 * Copyright (C) 2006 Art Cancro [http://www.citadel.org]
7 * The original version of this module was released into the public
8 * domain. This version is distributed as part of the Citadel system
9 * under the terms of the GNU General Public License v3.
13 function btt_enableTooltips(id)
16 if (!document.getElementById || !document.getElementsByTagName) {
19 h = document.createElement("span");
21 h.setAttribute("id", "btc");
22 h.style.position = "absolute";
23 document.getElementsByTagName("body")[0].appendChild(h);
25 links = document.getElementsByTagName("a");
28 links = document.getElementById(id).getElementsByTagName("a");
30 for (i = 0; i < links.length; i++) {
31 btt_Prepare(links[i]);
35 function btt_Prepare(el)
37 var tooltip, b, s, l, ih;
38 ih = el.getAttribute("btt_tooltext");
42 el.removeAttribute("btt_tooltext");
43 el.removeAttribute("title");
44 tooltip = btt_CreateEl("span", "tooltip");
45 s = btt_CreateEl("span", "top");
46 s.appendChild(document.createTextNode(""));
48 tooltip.appendChild(s);
49 b = btt_CreateEl("b", "bottom");
50 tooltip.appendChild(b);
51 btt_setOpacity(tooltip);
53 el.onmouseover = btt_showTooltip;
54 el.onmouseout = btt_hideTooltip;
55 el.onmousemove = btt_Locate;
58 function btt_showTooltip(e)
60 document.getElementById("btc").appendChild(this.tooltip);
64 function btt_hideTooltip(e)
66 var d = document.getElementById("btc");
67 if (d.childNodes.length > 0) {
68 d.removeChild(d.firstChild);
72 function btt_setOpacity(el)
74 el.style.filter = "alpha(opacity:95)";
75 el.style.KHTMLOpacity = "0.95";
76 el.style.MozOpacity = "0.95";
77 el.style.opacity = "0.95";
80 function btt_CreateEl(t, c)
82 var x = document.createElement(t);
84 x.style.display = "block";
88 function btt_Locate(e)
90 var posx = 0, posy = 0;
94 if (e.pageX || e.pageY) {
99 else if (e.clientX || e.clientY) {
100 if (document.documentElement.scrollTop) {
103 document.documentElement.scrollLeft;
105 e.clientY + document.documentElement.scrollTop;
109 posx = e.clientX + document.body.scrollLeft;
110 posy = e.clientY + document.body.scrollTop;
113 document.getElementById("btc").style.top = (posy + 10) + "px";
114 document.getElementById("btc").style.left = (posx - 260) + "px";