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