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