4 var config = new Object();
\r
6 config. width = 0 // Tooltip width, 0 for auto
\r
7 config. OffsetX = 40 // Horizontal offset of left-top corner from mousepointer
\r
8 config. OffsetY = -30 // Vertical offset
\r
9 config. Sticky = true // Move or not while shown
\r
10 config. Border = true // Show border
\r
11 config. step = 15 // Opacity step time
\r
12 config. timeUp = 0 // Show opacity time
\r
13 config. timeDown = 300 // Hide opacity time
\r
14 tt_aV = new Array(); // Caches and enumerates config data for currently active tooltip
\r
17 var tt_musX = 0, tt_musY = 0;
\r
20 var tt_opaTimer = new Number(0),
\r
21 tt_mainDiv = 0, // Main div
\r
22 tt_subDiv = 0, // Main sub div - for opacity
\r
23 tt_status = 0, // Status & 1 - tip shown/hide
\r
24 tt_element = 0, // onmouseover element for hide tooltip
\r
25 tt_opacity = 0, // Current sub div opacity
\r
28 tt_loading_text = '<div class=loading> </div>';
\r
32 tt_currentTip = arguments[0];
\r
33 arguments[0] = tt_loading_text;
\r
34 var id = tt_currentTip;
\r
36 my_AJAX.GETupload("ajax.php?tip=" + id, function(text){tt_updateTipData(id, text);});
\r
38 function tt_hrefTip()
\r
42 if (this.firstChild.tagName=='IMG')
\r
45 ajaxTip(this.id, STICKY, false);
\r
53 function tt_Tip(arg)
\r
56 tt_UpdateTip(arg[0]);
\r
57 tt_updatePosition();
\r
60 function tt_updateTipData(id, text)
\r
62 if (tt_currentTip != id)
\r
64 if ((tt_status & 1) == 0)
\r
67 setOpacity(tt_subDiv, tt_opacity);
\r
68 tt_updatePosition();
\r
70 function tt_opaStepUp(step)
\r
72 tt_opacity+=(100*step/tt_aV[TIMEUP]);
\r
73 if (tt_opacity < 100)
\r
74 tt_opaTimer.Timer("tt_opaStepUp(" + step + ")", step, true);
\r
76 {tt_opaTimer.EndTimer();tt_opacity = 100;}
\r
77 setOpacity(tt_subDiv, tt_opacity);
\r
79 function tt_opaStepDown(step)
\r
81 tt_opacity-=(100*step/tt_aV[TIMEDOWN]);
\r
83 tt_opaTimer.Timer("tt_opaStepDown(" + step + ")", step, true);
\r
85 {tt_opaTimer.EndTimer();tt_finishHideTip();}
\r
86 setOpacity(tt_subDiv, tt_opacity);
\r
88 function tt_startShowTip()
\r
90 tt_opaTimer.EndTimer();
\r
93 removeEvent(tt_element, "mouseout", tt_Hide);
\r
98 tt_mainDiv.style.visibility = "visible";
\r
102 tt_opaStepUp(tt_aV[STEP]);
\r
107 setOpacity(tt_subDiv, tt_opacity);
\r
110 function tt_startHideTip()
\r
112 tt_opaTimer.EndTimer();
\r
114 if (tt_aV[TIMEDOWN])
\r
115 tt_opaStepDown(tt_aV[STEP]);
\r
117 tt_finishHideTip();
\r
119 function tt_finishHideTip()
\r
121 tt_mainDiv.style.visibility = "hidden";
\r
124 function tt_updatePosition()
\r
126 var p = getPageRect(),
\r
127 width = tt_subDiv.offsetWidth,
\r
128 height= tt_subDiv.offsetHeight,
\r
129 max_x = p.left + p.width - width,
\r
130 max_y = p.top + p.height - height,
\r
131 x = tt_musX + tt_aV[OFFSETX],
\r
132 y = tt_musY + tt_aV[OFFSETY];
\r
133 if (x >= max_x) x = max_x;
\r
134 if (y >= max_y) y = max_y;
\r
136 var inX_ByX = (tt_musX > x && tt_musX < x + width);
\r
137 var inY_ByY = (tt_musY > y && tt_musY < y + height);
\r
138 if (inX_ByX && inY_ByY)
\r
140 x = tt_musX - width - tt_aV[OFFSETX];
\r
141 x = x<p.left?p.left:x;
\r
142 inX_ByX = (tt_musX > x && tt_musX < x + width);
\r
143 if (inX_ByX) y = tt_musY - height - tt_aV[OFFSETY];
\r
145 var css = tt_mainDiv.style;
\r
146 css.left = (x<p.left?p.left:x) + 'px';
\r
147 css.top = (y<p.top?p.top:y) + 'px';
\r
150 function tt_UpdateTip(text)
\r
154 var tt_tipBody = $('tt_tip_body');
\r
157 tt_tipBody.innerHTML = text;
\r
160 tt_mainDiv.innerHTML = ''
\r
161 + '<div id=tt_tooltip>'
\r
162 + '<table class=tooltip cellSpacing=0 cellPadding=0><tbody>'
\r
163 + '<tr><td class=tiptopl></td><td class=tiptop></td><td class=tiptopr></td></tr>'
\r
164 + '<tr><td class=tipl> </td><td class=tipbody id=tt_tip_body>'
\r
166 + '</td><td class=tipr> </td></tr>'
\r
167 + '<tr><td class=tipbottoml></td><td class=tipbottom></td><td class=tipbottomr></td></tr>'
\r
168 + '</tbody></table></div>';
\r
171 tt_mainDiv.innerHTML = ''
\r
172 + '<div id=tt_tooltip>'
\r
175 tt_subDiv = $('tt_tooltip');
\r
176 tt_subDiv.style.width = tt_aV[WIDTH] ? tt_aV[WIDTH] + 'px' : 'auto';
\r
179 function tt_Hide(e)
\r
181 e = window.event || e;
\r
183 var target = e.target || e.srcElement;
\r
184 if (tt_element == target) {
\r
185 removeEvent(tt_element, "mouseout", tt_Hide);
\r
191 function tt_Move(e)
\r
193 e = window.event || e;
\r
195 var b = document.body || document.documentElement;
\r
196 tt_musX = e.pageX || (e.clientX + b.scrollLeft);
\r
197 tt_musY = e.pageY || (e.clientY + b.scrollTop);
\r
198 if (tt_element == 0 && tt_status & 1)
\r
200 tt_element = e.target || e.srcElement;
\r
201 addEvent(tt_element, "mouseout", tt_Hide);
\r
203 if (!tt_aV[STICKY] && tt_status&1)
\r
204 tt_updatePosition();
\r
208 // Create the tooltip DIV
\r
209 tt_mainDiv = insertElement(getBody(), 'DIV','tt_mytooltip');
\r
210 tt_mainDiv.style.position = "absolute";
\r
211 tt_mainDiv.style.zIndex = 1000;
\r
213 addEvent(document, "mousemove", tt_Move);
\r
214 tt_finishHideTip();
\r
217 // Creates command names by translating config variable names to upper case
\r
218 function tt_MkCmdEnum()
\r
221 for(var i in config)
\r
222 eval("window." + i.toString().toUpperCase() + " = " + n++);
\r
224 function tt_ReadCmds(a)
\r
227 // First load the global config values, to initialize also values
\r
228 // for which no command has been passed
\r
229 for(var j in config)
\r
230 tt_aV[i++] = config[j];
\r
231 // Then replace each cached config value for which a command has been
\r
232 // passed (ensure the # of command args plus value args be even)
\r
235 for(i = a.length - 1; i > 0; i -= 2)
\r
236 tt_aV[a[i - 1]] = a[i];
\r
239 tt_Err("Incorrect call of Tip() or ajaxTip().\n"
\r
240 + "Each command must be followed by a value.");
\r