Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / phpmyadmin / js / tooltip.js
blob4f9cd359c0abf831afb227d72da2316540f9b8b3
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * Displays the Tooltips (hints), if we have some
4  * 2005-01-20 added by Michael Keck (mkkeck)
5  *
6  * @version $Id$
7  */
9 /**
10  *
11  */
12 var ttXpos = 0, ttYpos = 0;
13 var ttXadd = 10, ttYadd = -10;
14 var ttDisplay = 0, ttHoldIt = 0;
15 // Check if browser does support dynamic content and dhtml
16 var ttNS4 = (document.layers) ? 1 : 0;           // the old Netscape 4
17 var ttIE4 = (document.all) ? 1 : 0;              // browser wich uses document.all
18 var ttDOM = (document.getElementById) ? 1 : 0;   // DOM-compatible browsers
19 if (ttDOM) { // if DOM-compatible, set the others to false
20     ttNS4 = 0;
21     ttIE4 = 0;
24 var myTooltipContainer = null;
26 if ( (ttDOM) || (ttIE4) || (ttNS4) ) {
27     // mouse-event
28     if ( ttNS4 ) {
29         document.captureEvents(Event.MOUSEMOVE);
30     } else {
31         document.onmousemove = mouseMove;
32     }
35 /**
36  * init the tooltip and write the text into it
37  *
38  * @param string theText tooltip content
39  */
40 function textTooltip(theText) {
41     if  (ttDOM || ttIE4) {                   // document.getEelementById || document.all
42         myTooltipContainer.innerHTML = "";  // we should empty it first
43         myTooltipContainer.innerHTML = theText;
44     } else if (ttNS4) {                     // document.layers
45         var layerNS4 = myTooltipContainer.document;
46         layerNS4.write(theText);
47         layerNS4.close();
48     }
51 /**
52  * @var integer
53  */
54 var ttTimerID = 0;
56 /**
57  * swap the Tooltip // show and hide
58  *
59  * @param boolean stat view status
60  */
61 function swapTooltip(stat) {
62     if (ttHoldIt!=1) {
63         if (stat!='default') {
64             if (stat=='true')
65                 showTooltip(true);
66             else if (stat=='false')
67                 showTooltip(false);
68         } else {
69             if (ttDisplay)
70                 ttTimerID = setTimeout("showTooltip(false);",500);
71             else
72                 showTooltip(true);
73         }
74     } else {
75         if (ttTimerID) {
76            clearTimeout(ttTimerID);
77            ttTimerID = 0;
78         }
79         showTooltip(true);
80     }
83 /**
84  * show / hide the Tooltip
85  *
86  * @param boolean stat view status
87  */
88 function showTooltip(stat) {
89     if (stat==false) {
90         if (ttNS4)
91             myTooltipContainer.visibility = "hide";
92         else
93             myTooltipContainer.style.visibility = "hidden";
94         ttDisplay = 0;
95     } else {
96         if (ttNS4)
97             myTooltipContainer.visibility = "show";
98         else
99             myTooltipContainer.style.visibility = "visible";
100         ttDisplay = 1;
101     }
104  * hold it, if we create or move the mouse over the tooltip
105  */
106 function holdTooltip() {
107     ttHoldIt = 1;
108     swapTooltip('true');
109     ttHoldIt = 0;
113  * move the tooltip to mouse position
115  * @param integer posX    horiz. position
116  * @param integer posY    vert. position
117  */
118 function moveTooltip(posX, posY) {
119     if (ttDOM || ttIE4) {
120         myTooltipContainer.style.left   =       posX + "px";
121         myTooltipContainer.style.top  = posY + "px";
122     } else if (ttNS4) {
123         myTooltipContainer.left = posX;
124         myTooltipContainer.top  = posY;
125     }
129  * build the tooltip
131  * @param    string    theText    tooltip content
132  */
133 function pmaTooltip( theText ) {
134     // reference to TooltipContainer
135     if ( null == myTooltipContainer ) {
136         if (ttNS4) {
137             myTooltipContainer = document.TooltipContainer;
138         } else if (ttIE4) {
139             myTooltipContainer = document.all('TooltipContainer');
140         } else if (ttDOM) {
141             myTooltipContainer = document.getElementById('TooltipContainer');
142         } else {
143             return;
144         }
146         if ( typeof( myTooltipContainer ) == 'undefined' ) {
147             return;
148         }
149     }
151     var plusX=0, plusY=0, docX=0, docY=0;
152     var divHeight = myTooltipContainer.clientHeight;
153     var divWidth  = myTooltipContainer.clientWidth;
154     if (navigator.appName.indexOf("Explorer")!=-1) {
155         if (document.documentElement && document.documentElement.scrollTop) {
156             plusX = document.documentElement.scrollLeft;
157             plusY = document.documentElement.scrollTop;
158             docX = document.documentElement.offsetWidth + plusX;
159             docY = document.documentElement.offsetHeight + plusY;
160         } else {
161             plusX = document.body.scrollLeft;
162             plusY = document.body.scrollTop;
163             docX = document.body.offsetWidth + plusX;
164             docY = document.body.offsetHeight + plusY;
165         }
166     } else {
167         docX = document.body.clientWidth;
168         docY = document.body.clientHeight;
169     }
171     ttXpos = ttXpos + plusX;
172     ttYpos = ttYpos + plusY;
174     if ((ttXpos + divWidth) > docX)
175         ttXpos = ttXpos - (divWidth + (ttXadd * 2));
176     if ((ttYpos + divHeight) > docY)
177         ttYpos = ttYpos - (divHeight + (ttYadd * 2));
179     textTooltip(theText);
180     moveTooltip((ttXpos + ttXadd), (ttYpos + ttYadd));
181     holdTooltip();
185  * register mouse moves
187  * @param    event    e
188  */
189 function mouseMove(e) {
190     if ( typeof( event ) != 'undefined' ) {
191         ttXpos = event.x;
192         ttYpos = event.y;
193     } else {
194         ttXpos = e.pageX;
195         ttYpos = e.pageY;
196     }