author | Dan |
Thu, 28 Jun 2007 13:49:40 -0400 | |
changeset 30 | 7e8fd44b36b0 |
parent 22 | d0314575e2f0 |
child 40 | 723bb7acf914 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* The jBox menu system. Written by Dan Fuhry and licensed under the GPL. |
|
3 |
*/ |
|
4 |
||
5 |
// Cache of DOM and event objects, used in setTimeout() calls due to scope rules |
|
6 |
var jBoxObjCache = new Object(); |
|
7 |
||
8 |
// Cache of "correct" heights for unordered list objects used in submenus. Helps the animation routine know what height it's aiming for. |
|
9 |
var jBoxMenuHeights = new Object(); |
|
10 |
||
11 |
// Blocks animations from running if there's already an animation going on the same object |
|
12 |
var jBoxSlideBlocker = new Object(); |
|
13 |
||
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
14 |
// Switch to enable or disable jBox slide animation |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
15 |
var jBox_slide_enable = true; |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
16 |
|
1 | 17 |
// Speed at which the menus should slide open. 1 to 100 or -1 to disable. |
18 |
// Setting this higher than 100 will cause an infinite loop in the browser. |
|
19 |
// Default is 80 - anything higher than 90 means exponential speed increase |
|
20 |
var slide_speed = 80; |
|
21 |
||
22 |
// Inertia value to start with |
|
23 |
// Default is 0 |
|
24 |
var inertia_base = 0; |
|
25 |
||
26 |
// Value added to inertia_base on each frame - generally 1 to 3 is good, with 1 being slowest animation |
|
27 |
// Default is 1 |
|
28 |
var inertia_inc = 1; |
|
29 |
||
30 |
// Opacity that menus should fade to. 1 to 100 or -1 to disable fades. This only works if the slide effect is also enabled. |
|
31 |
// Default is 100 |
|
32 |
var jBox_opacity = 100; |
|
33 |
||
34 |
// Adds the jBox CSS to the HTML header. Called on window onload. |
|
35 |
function jBoxInit() |
|
36 |
{ |
|
37 |
setTimeout('jBoxBatchSetup();', 200); |
|
38 |
} |
|
39 |
||
40 |
// Initializes each menu. |
|
41 |
function jBoxBatchSetup() |
|
42 |
{ |
|
43 |
var menus = document.getElementsByClassName('div', 'menu_nojs'); |
|
44 |
if ( menus.length > 0 ) |
|
45 |
{ |
|
46 |
for ( var i in menus ) |
|
47 |
{ |
|
48 |
if ( typeof(menus[i]) != 'object') |
|
49 |
continue; // toJSONString() compatibility |
|
50 |
jBoxSetup(menus[i]); |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
||
55 |
// Initializes a div with a jBox menu in it. |
|
56 |
function jBoxSetup(obj) |
|
57 |
{ |
|
58 |
$(obj).addClass('menu'); |
|
59 |
removeTextNodes(obj); |
|
60 |
for ( var i in obj.childNodes ) |
|
61 |
{ |
|
62 |
/* normally this would be done in about 2 lines of code, but javascript is so picky..... */ |
|
63 |
if ( obj.childNodes[i] ) |
|
64 |
{ |
|
65 |
if ( obj.childNodes[i].tagName ) |
|
66 |
{ |
|
67 |
if ( obj.childNodes[i].tagName.toLowerCase() == 'a' ) |
|
68 |
{ |
|
69 |
if ( obj.childNodes[i].nextSibling.tagName ) |
|
70 |
{ |
|
71 |
if ( obj.childNodes[i].nextSibling.tagName.toLowerCase() == 'ul' || ( obj.childNodes[i].nextSibling.tagName.toLowerCase() == 'div' && obj.childNodes[i].nextSibling.className == 'submenu' ) ) |
|
72 |
{ |
|
73 |
// Calculate height |
|
74 |
var ul = obj.childNodes[i].nextSibling; |
|
75 |
domObjChangeOpac(0, ul); |
|
76 |
ul.style.display = 'block'; |
|
77 |
var dim = fetch_dimensions(ul); |
|
78 |
if ( !ul.id ) |
|
79 |
ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000); |
|
80 |
jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width |
|
81 |
ul.style.display = 'none'; |
|
82 |
domObjChangeOpac(100, ul); |
|
83 |
||
84 |
// Setup events |
|
85 |
obj.childNodes[i].onmouseover = function() { jBoxOverHandler(this); }; |
|
86 |
obj.childNodes[i].onmouseout = function(e) { jBoxOutHandler(this, e); }; |
|
87 |
obj.childNodes[i].nextSibling.onmouseout = function(e) { jBoxOutHandler(this, e); }; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
// Called when user hovers mouse over a submenu |
|
97 |
function jBoxOverHandler(obj) |
|
98 |
{ |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
99 |
if ( is_Safari ) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
100 |
alert('Safari and over'); |
1 | 101 |
// Random ID used to track the object to perform on |
102 |
var seed = Math.floor(Math.random() * 1000000); |
|
103 |
jBoxObjCache[seed] = obj; |
|
104 |
||
105 |
// Sleep for a (little more than a tenth of a) second to see if the user really wants the menu to expand |
|
106 |
setTimeout('if(isOverObj(jBoxObjCache['+seed+'], false, false)) jBoxOverHandlerBin(jBoxObjCache['+seed+']);', 150); |
|
107 |
} |
|
108 |
||
109 |
// Displays a menu. |
|
110 |
function jBoxOverHandlerBin(obj) |
|
111 |
{ |
|
112 |
var others = obj.parentNode.getElementsByTagName('ul'); |
|
113 |
for ( var i in others ) |
|
114 |
{ |
|
115 |
if(typeof(others[i]) == 'object') |
|
116 |
{ |
|
117 |
others[i].style.display = 'none'; |
|
118 |
others[i].previousSibling.className = ''; |
|
119 |
} |
|
120 |
} |
|
121 |
var others = obj.parentNode.getElementsByTagName('div'); |
|
122 |
for ( var i in others ) |
|
123 |
{ |
|
124 |
if(typeof(others[i]) == 'object') |
|
125 |
{ |
|
126 |
if ( others[i].className == 'submenu' ) |
|
127 |
{ |
|
128 |
others[i].style.display = 'none'; |
|
129 |
others[i].previousSibling.className = ''; |
|
130 |
} |
|
131 |
} |
|
132 |
} |
|
133 |
if(obj.nextSibling.tagName.toLowerCase() == 'ul' || ( obj.nextSibling.tagName.toLowerCase() == 'div' && obj.nextSibling.className == 'submenu' )) |
|
134 |
{ |
|
135 |
obj.className = 'liteselected'; |
|
136 |
var ul = obj.nextSibling; |
|
137 |
var dim = fetch_dimensions(obj); |
|
138 |
var off = fetch_offset(obj); |
|
139 |
var dimh = parseInt(dim['h']); |
|
140 |
var offtop = parseInt(off['top']); |
|
141 |
var top = dimh + offtop; |
|
142 |
left = off['left']; |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
143 |
if ( jBox_slide_enable ) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
144 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
145 |
domObjChangeOpac(0, ul); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
146 |
} |
1 | 147 |
ul.style.left = left + 'px'; |
148 |
ul.style.top = top + 'px'; |
|
149 |
ul.style.clip = 'rect(auto,auto,auto,auto)'; |
|
150 |
ul.style.overflow = 'visible'; |
|
151 |
ul.style.display = 'block'; |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
152 |
if ( jBox_slide_enable ) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
153 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
154 |
slideOut(ul); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
155 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
156 |
else |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
157 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
158 |
domObjChangeOpac(100, ul); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
1
diff
changeset
|
159 |
} |
1 | 160 |
} |
161 |
} |
|
162 |
||
163 |
function jBoxOutHandler(obj, event) |
|
164 |
{ |
|
165 |
var seed = Math.floor(Math.random() * 1000000); |
|
166 |
var seed2 = Math.floor(Math.random() * 1000000); |
|
167 |
jBoxObjCache[seed] = obj; |
|
168 |
jBoxObjCache[seed2] = event; |
|
169 |
setTimeout('jBoxOutHandlerBin(jBoxObjCache['+seed+'], jBoxObjCache['+seed2+']);', 750); |
|
170 |
} |
|
171 |
||
172 |
function jBoxOutHandlerBin(obj, event) |
|
173 |
{ |
|
174 |
var caller = obj.tagName.toLowerCase(); |
|
175 |
if(caller == 'a') |
|
176 |
{ |
|
177 |
a = obj; |
|
178 |
ul = obj.nextSibling; |
|
179 |
} |
|
180 |
else if(caller == 'ul' || caller == 'div') |
|
181 |
{ |
|
182 |
a = obj.previousSibling; |
|
183 |
ul = obj; |
|
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
return false; |
|
188 |
} |
|
189 |
||
190 |
if (!isOverObj(a, false, event) && !isOverObj(ul, true, event)) |
|
191 |
{ |
|
192 |
a.className = ''; |
|
193 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
194 |
if ( jBox_slide_enable ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
195 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
196 |
slideIn(ul); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
197 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
198 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
199 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
200 |
ul.style.display = 'none'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
201 |
} |
1 | 202 |
|
203 |
} |
|
204 |
||
205 |
return true; |
|
206 |
} |
|
207 |
||
208 |
// Slide an element downwards until it is at full height. |
|
209 |
// First parameter should be a DOM object with style.display = block and opacity = 0. |
|
210 |
||
211 |
var sliderobj = new Object(); |
|
212 |
||
213 |
function slideOut(obj) |
|
214 |
{ |
|
215 |
if ( jBoxSlideBlocker[obj.id] ) |
|
216 |
return false; |
|
217 |
||
218 |
jBoxSlideBlocker[obj.id] = true; |
|
219 |
||
220 |
if ( slide_speed == -1 ) |
|
221 |
{ |
|
222 |
obj.style.display = 'block'; |
|
223 |
return false; |
|
224 |
} |
|
225 |
||
226 |
var currentheight = 0; |
|
227 |
var targetheight = jBoxMenuHeights[obj.id]; |
|
228 |
var inertiabase = inertia_base; |
|
229 |
var inertiainc = inertia_inc; |
|
230 |
slideStep(obj, 0); |
|
231 |
domObjChangeOpac(100, obj); |
|
232 |
obj.style.overflow = 'hidden'; |
|
233 |
||
234 |
// Don't edit past here |
|
235 |
var timercnt = 0; |
|
236 |
||
237 |
var seed = Math.floor(Math.random() * 1000000); |
|
238 |
sliderobj[seed] = obj; |
|
239 |
||
240 |
var framecnt = 0; |
|
241 |
||
242 |
while(true) |
|
243 |
{ |
|
244 |
framecnt++; |
|
245 |
timercnt += ( 100 - slide_speed ); |
|
246 |
inertiabase += inertiainc; |
|
247 |
currentheight += inertiabase; |
|
248 |
if ( currentheight > targetheight ) |
|
249 |
currentheight = targetheight; |
|
250 |
setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+', '+targetheight+');', timercnt); |
|
251 |
if ( currentheight >= targetheight ) |
|
252 |
break; |
|
253 |
} |
|
254 |
timercnt = timercnt + ( 100 - slide_speed ); |
|
255 |
setTimeout('jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt); |
|
256 |
var opacstep = jBox_opacity / framecnt; |
|
257 |
var opac = 0; |
|
258 |
var timerstep = 0; |
|
259 |
domObjChangeOpac(0, obj); |
|
260 |
while(true) |
|
261 |
{ |
|
262 |
timerstep += ( 100 - slide_speed ); |
|
263 |
opac += opacstep; |
|
264 |
setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep); |
|
265 |
if ( opac >= jBox_opacity ) |
|
266 |
break; |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
function slideIn(obj) |
|
271 |
{ |
|
272 |
if ( obj.style.display != 'block' ) |
|
273 |
return false; |
|
274 |
||
275 |
if ( jBoxSlideBlocker[obj.id] ) |
|
276 |
return false; |
|
277 |
||
278 |
jBoxSlideBlocker[obj.id] = true; |
|
279 |
||
280 |
var targetheight = 0; |
|
281 |
var dim = fetch_dimensions(obj); |
|
282 |
var currentheight = jBoxMenuHeights[obj.id]; |
|
283 |
var origheight = currentheight; |
|
284 |
var inertiabase = inertia_base; |
|
285 |
var inertiainc = inertia_inc; |
|
286 |
domObjChangeOpac(100, obj); |
|
287 |
obj.style.overflow = 'hidden'; |
|
288 |
||
289 |
// Don't edit past here |
|
290 |
var timercnt = 0; |
|
291 |
||
292 |
var seed = Math.floor(Math.random() * 1000000); |
|
293 |
sliderobj[seed] = obj; |
|
294 |
||
295 |
var framecnt = 0; |
|
296 |
||
297 |
for(var j = 0;j<100;j++) // while(true) |
|
298 |
{ |
|
299 |
framecnt++; |
|
300 |
timercnt = timercnt + ( 100 - slide_speed ); |
|
301 |
inertiabase = inertiabase + inertiainc; |
|
302 |
currentheight = currentheight - inertiabase; |
|
303 |
if ( currentheight < targetheight ) |
|
304 |
currentheight = targetheight; |
|
305 |
setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+');', timercnt); |
|
306 |
if ( currentheight <= targetheight ) |
|
307 |
break; |
|
308 |
} |
|
309 |
timercnt += ( 100 - slide_speed ); |
|
310 |
setTimeout('sliderobj['+seed+'].style.display="none";sliderobj['+seed+'].style.height="'+origheight+'px";jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt); |
|
311 |
||
312 |
var opacstep = jBox_opacity / framecnt; |
|
313 |
var opac = jBox_opacity; |
|
314 |
var timerstep = 0; |
|
315 |
domObjChangeOpac(100, obj); |
|
316 |
while(true) |
|
317 |
{ |
|
318 |
timerstep += ( 100 - slide_speed ); |
|
319 |
opac -= opacstep; |
|
320 |
setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep); |
|
321 |
if ( opac <= 0 ) |
|
322 |
break; |
|
323 |
} |
|
324 |
||
325 |
} |
|
326 |
||
327 |
function slideStep(obj, height, maxheight) |
|
328 |
{ |
|
329 |
obj.style.height = height + 'px'; |
|
330 |
//obj.style.clip = 'rect(3px,auto,'+maxheight+'px,auto)'; |
|
331 |
obj.style.overflow = 'hidden'; |
|
332 |
//obj.style.clip = 'rect('+height+'px,0px,'+maxheight+'px,auto);'; |
|
333 |
} |
|
334 |
||
335 |
function isOverObj(obj, bias, event) |
|
336 |
{ |
|
337 |
var fieldUL = new Object(); |
|
338 |
var dim = fetch_dimensions(obj); |
|
339 |
var off = fetch_offset(obj); |
|
340 |
fieldUL['top'] = off['top']; |
|
341 |
fieldUL['left'] = off['left']; |
|
342 |
fieldUL['right'] = off['left'] + dim['w']; |
|
343 |
fieldUL['bottom'] = off['top'] + dim['h']; |
|
344 |
||
345 |
//document.getElementById('debug').innerHTML = '<br /><br /><br /><br /><br />Mouse: x: '+mouseX+', y:' + mouseY + '<br />'; // + document.getElementById('debug').innerHTML; |
|
346 |
||
347 |
if(bias) |
|
348 |
{ |
|
349 |
if ( ( mouseX < fieldUL['left'] + 2 || mouseX > fieldUL['right'] - 5 ) || |
|
350 |
( mouseY < fieldUL['top'] - 2 || mouseY > fieldUL['bottom'] - 2 ) ) |
|
351 |
{ |
|
352 |
return false; |
|
353 |
} |
|
354 |
} |
|
355 |
else |
|
356 |
{ |
|
357 |
if ( ( mouseX < fieldUL['left'] || mouseX > fieldUL['right'] ) || |
|
358 |
( mouseY < fieldUL['top'] || mouseY > fieldUL['bottom'] ) ) |
|
359 |
return false; |
|
360 |
} |
|
361 |
||
362 |
return true; |
|
363 |
||
364 |
/* |
|
365 |
var tgt = event.target; |
|
366 |
if ( !tgt ) |
|
367 |
return false; |
|
368 |
do { |
|
369 |
if ( tgt == obj ) |
|
370 |
return true; |
|
371 |
tgt = tgt.parentNode; |
|
372 |
} while (tgt.tagName.toLowerCase() != 'body' ); |
|
373 |
return false; |
|
374 |
*/ |
|
375 |
} |
|
376 |
||
377 |
function jBoxGarbageCollection(e) |
|
378 |
{ |
|
379 |
setMousePos(e); |
|
380 |
var menus = document.getElementsByClassName('div', 'menu'); |
|
381 |
if ( menus.length > 0 ) |
|
382 |
{ |
|
383 |
for ( var i in menus ) |
|
384 |
{ |
|
385 |
if ( typeof(menus[i]) != 'object') |
|
386 |
continue; // toJSONString() compatibility |
|
387 |
var uls = menus[i].getElementsByTagName('ul'); |
|
388 |
if ( uls.length > 0 ) |
|
389 |
{ |
|
390 |
for ( var j = 0; j < uls.length; j++ ) |
|
391 |
{ |
|
392 |
if ( !isOverObj(uls[j], false, e) ) |
|
393 |
{ |
|
394 |
uls[j].previousSibling.className = ''; |
|
395 |
//uls[j].style.display = 'none'; |
|
396 |
slideIn(uls[j]); |
|
397 |
} |
|
398 |
} |
|
399 |
} |
|
400 |
var uls = getElementsByClassName(menus[i], 'divs', 'submenu'); |
|
401 |
if ( uls.length > 0 ) |
|
402 |
{ |
|
403 |
for ( var j = 0; j < uls.length; j++ ) |
|
404 |
{ |
|
405 |
if ( !isOverObj(uls[j], false, e) ) |
|
406 |
{ |
|
407 |
uls[j].previousSibling.className = ''; |
|
408 |
//uls[j].style.display = 'none'; |
|
409 |
slideIn(uls[j]); |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
document.onclick = jBoxGarbageCollection; |
|
418 |
||
419 |
function removeTextNodes(obj) |
|
420 |
{ |
|
421 |
if(obj) |
|
422 |
{ |
|
423 |
if(typeof(obj.tagName) != 'string') |
|
424 |
{ |
|
425 |
if ( obj.nodeType == 3 && obj.data.match(/^([\s]*)$/ig) ) |
|
426 |
{ |
|
427 |
obj.parentNode.removeChild(obj); |
|
428 |
return; |
|
429 |
} |
|
430 |
} |
|
431 |
if(obj.firstChild) |
|
432 |
{ |
|
433 |
for(var i in obj.childNodes) |
|
434 |
{ |
|
435 |
removeTextNodes(obj.childNodes[i]); |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
var getElementsByClassName = function(parent, type, cls) { |
|
442 |
if(!type) |
|
443 |
type = '*'; |
|
444 |
ret = new Array(); |
|
445 |
el = parent.getElementsByTagName(type); |
|
446 |
for ( var i in el ) |
|
447 |
{ |
|
448 |
if ( typeof(el[i]) != 'object') |
|
449 |
continue; // toJSONString() compatibility |
|
450 |
if(el[i].className) |
|
451 |
{ |
|
452 |
if(el[i].className.indexOf(' ') > 0) |
|
453 |
{ |
|
454 |
classes = el[i].className.split(' '); |
|
455 |
} |
|
456 |
else |
|
457 |
{ |
|
458 |
classes = new Array(); |
|
459 |
classes.push(el[i].className); |
|
460 |
} |
|
461 |
if ( in_array(cls, classes) ) |
|
462 |
ret.push(el[i]); |
|
463 |
} |
|
464 |
} |
|
465 |
return ret; |
|
466 |
} |
|
467 |
||
468 |
document.getElementsByClassName = function(type, cls) { |
|
469 |
return getElementsByClassName(document, type, cls); |
|
470 |
} |
|
471 |
||
472 |
function setMousePos(event) |
|
473 |
{ |
|
474 |
if(IE) |
|
475 |
{ |
|
476 |
if(!event) |
|
477 |
{ |
|
478 |
event = window.event; |
|
479 |
} |
|
480 |
clX = event.clientX; |
|
481 |
sL = document.body.scrollLeft; |
|
482 |
mouseX = clX + sL; |
|
483 |
mouseY = event.clientY + document.body.scrollTop; |
|
484 |
return; |
|
485 |
} |
|
486 |
if( typeof(event.clientX) == 'number' ) |
|
487 |
{ |
|
488 |
mouseX = event.clientX; |
|
489 |
mouseY = event.clientY; |
|
490 |
return; |
|
491 |
} |
|
492 |
else if( typeof(event.layerX) == 'number' ) |
|
493 |
{ |
|
494 |
mouseX = event.layerX; |
|
495 |
mouseY = event.layerY; |
|
496 |
return; |
|
497 |
} |
|
498 |
else if( typeof(event.offsetX) == 'number' ) |
|
499 |
{ |
|
500 |
mouseX = event.offsetX; |
|
501 |
mouseY = event.offsetY; |
|
502 |
return; |
|
503 |
} |
|
504 |
else if( typeof(event.screenX) == 'number' ) |
|
505 |
{ |
|
506 |
mouseX = event.screenX; |
|
507 |
mouseY = event.screenY; |
|
508 |
return; |
|
509 |
} |
|
510 |
else if( typeof(event.x) == 'number' ) |
|
511 |
{ |
|
512 |
mouseX = event.x; |
|
513 |
mouseY = event.y; |
|
514 |
return; |
|
515 |
} |
|
516 |
} |
|
517 |
||
518 |
document.onmousemove = function(e) |
|
519 |
{ |
|
520 |
setMousePos(e); |
|
521 |
}; |
|
522 |
||
523 |
function domObjChangeOpac(opacity, id) { |
|
524 |
var object = id.style; |
|
525 |
object.opacity = (opacity / 100); |
|
526 |
object.MozOpacity = (opacity / 100); |
|
527 |
object.KhtmlOpacity = (opacity / 100); |
|
528 |
object.filter = "alpha(opacity=" + opacity + ")"; |
|
529 |
} |
|
530 |