1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * Displays the Tooltips (hints), if we have some
4 * 2005-01-20 added by Michael Keck (mkkeck)
12 var ttXpos = 0, ttYpos = 0;
13 var ttXadd = 10, ttYadd = -10;
14 var ttDisplay = 0, ttHoldIt = 0;
16 // Check if browser does support dynamic content and dhtml
17 if (document.getElementById) {
18 // DOM-compatible browsers
22 var ttNS4 = (document.layers) ? 1 : 0;
23 // browser wich uses document.all
24 var ttIE4 = (document.all) ? 1 : 0;
27 var myTooltipContainer = null;
32 function PMA_TT_init()
34 // get all 'light bubbles' on page
35 var tooltip_icons = window.parent.getElementsByClassName('footnotemarker', document, 'sup');
36 var tooltip_count = tooltip_icons.length;
38 if (tooltip_count < 1) {
43 // insert tooltip container
44 myTooltipContainer = document.createElement("div");
45 myTooltipContainer.id = 'TooltipContainer';
46 window.parent.addEvent(myTooltipContainer, 'mouseover', holdTooltip);
47 window.parent.addEvent(myTooltipContainer, 'mouseout', swapTooltip);
48 document.body.appendChild(myTooltipContainer);
50 // capture mouse-events
51 for (i = 0; i < tooltip_count; i++) {
52 window.parent.addEvent(tooltip_icons[i], 'mousemove', mouseMove);
53 window.parent.addEvent(tooltip_icons[i], 'mouseover', pmaTooltip);
54 window.parent.addEvent(tooltip_icons[i], 'mouseout', swapTooltip);
59 * init the tooltip and write the text into it
61 * @param string theText tooltip content
63 function PMA_TT_setText(theText)
65 if (ttDOM || ttIE4) { // document.getEelementById || document.all
66 myTooltipContainer.innerHTML = ""; // we should empty it first
67 myTooltipContainer.innerHTML = theText;
68 } else if (ttNS4) { // document.layers
69 var layerNS4 = myTooltipContainer.document;
70 layerNS4.write(theText);
81 * swap the Tooltip // show and hide
83 * @param boolean stat view status
85 function swapTooltip(stat)
90 } else if (ttDisplay) {
91 ttTimerID = setTimeout("showTooltip(false);", 500);
97 clearTimeout(ttTimerID);
105 * show / hide the Tooltip
107 * @param boolean stat view status
109 function showTooltip(stat)
113 myTooltipContainer.visibility = "hide";
115 myTooltipContainer.style.visibility = "hidden";
119 myTooltipContainer.visibility = "show";
121 myTooltipContainer.style.visibility = "visible";
127 * hold it, if we create or move the mouse over the tooltip
129 function holdTooltip()
137 * move the tooltip to mouse position
139 * @param integer posX horiz. position
140 * @param integer posY vert. position
142 function moveTooltip(posX, posY)
144 if (ttDOM || ttIE4) {
145 myTooltipContainer.style.left = posX + "px";
146 myTooltipContainer.style.top = posY + "px";
148 myTooltipContainer.left = posX;
149 myTooltipContainer.top = posY;
155 * usally called from eventhandler
157 * @param string theText tooltip content
159 function pmaTooltip(e)
161 var theText = document.getElementById('footnote_' + this.innerHTML).innerHTML;
163 var plusX = 0, plusY = 0, docX = 0, docY = 0;
164 var divHeight = myTooltipContainer.clientHeight;
165 var divWidth = myTooltipContainer.clientWidth;
167 if (navigator.appName.indexOf("Explorer") != -1) {
169 if (document.documentElement && document.documentElement.scrollTop) {
170 plusX = document.documentElement.scrollLeft;
171 plusY = document.documentElement.scrollTop;
172 docX = document.documentElement.offsetWidth + plusX;
173 docY = document.documentElement.offsetHeight + plusY;
175 plusX = document.body.scrollLeft;
176 plusY = document.body.scrollTop;
177 docX = document.body.offsetWidth + plusX;
178 docY = document.body.offsetHeight + plusY;
181 docX = document.body.clientWidth;
182 docY = document.body.clientHeight;
185 ttXpos = ttXpos + plusX;
186 ttYpos = ttYpos + plusY;
188 if ((ttXpos + divWidth) > docX)
189 ttXpos = ttXpos - (divWidth + (ttXadd * 2));
190 if ((ttYpos + divHeight) > docY)
191 ttYpos = ttYpos - (divHeight + (ttYadd * 2));
193 PMA_TT_setText(theText);
194 moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
199 * register mouse moves
203 function mouseMove(e) {
204 if ( typeof( event ) != 'undefined' ) {
211 moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));