author | Dan |
Mon, 11 Feb 2008 13:55:14 -0500 | |
changeset 409 | 267be9e394c2 |
parent 394 | fbfdcea634a7 |
child 420 | 301f546688d1 |
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'; |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
126 |
$(others[i].previousSibling).rmClass('liteselected'); |
1 | 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'; |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
137 |
$(others[i].previousSibling).rmClass('liteselected'); |
1 | 138 |
} |
139 |
} |
|
140 |
} |
|
141 |
if(obj.nextSibling.tagName.toLowerCase() == 'ul' || ( obj.nextSibling.tagName.toLowerCase() == 'div' && obj.nextSibling.className == 'submenu' )) |
|
142 |
{ |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
143 |
$(a).addClass('liteselected'); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
144 |
//obj.className = 'liteselected'; |
1 | 145 |
var ul = obj.nextSibling; |
146 |
var dim = fetch_dimensions(obj); |
|
147 |
var off = fetch_offset(obj); |
|
148 |
var dimh = parseInt(dim['h']); |
|
149 |
var offtop = parseInt(off['top']); |
|
150 |
var top = dimh + offtop; |
|
151 |
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
|
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 |
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
|
155 |
} |
1 | 156 |
ul.style.left = left + 'px'; |
157 |
ul.style.top = top + 'px'; |
|
158 |
ul.style.clip = 'rect(auto,auto,auto,auto)'; |
|
159 |
ul.style.overflow = 'visible'; |
|
160 |
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
|
161 |
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
|
162 |
{ |
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 |
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
|
164 |
} |
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 |
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
|
166 |
{ |
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 |
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
|
168 |
} |
1 | 169 |
} |
170 |
} |
|
171 |
||
172 |
function jBoxOutHandler(obj, event) |
|
173 |
{ |
|
174 |
var seed = Math.floor(Math.random() * 1000000); |
|
175 |
var seed2 = Math.floor(Math.random() * 1000000); |
|
176 |
jBoxObjCache[seed] = obj; |
|
177 |
jBoxObjCache[seed2] = event; |
|
178 |
setTimeout('jBoxOutHandlerBin(jBoxObjCache['+seed+'], jBoxObjCache['+seed2+']);', 750); |
|
179 |
} |
|
180 |
||
181 |
function jBoxOutHandlerBin(obj, event) |
|
182 |
{ |
|
183 |
var caller = obj.tagName.toLowerCase(); |
|
184 |
if(caller == 'a') |
|
185 |
{ |
|
186 |
a = obj; |
|
187 |
ul = obj.nextSibling; |
|
188 |
} |
|
189 |
else if(caller == 'ul' || caller == 'div') |
|
190 |
{ |
|
191 |
a = obj.previousSibling; |
|
192 |
ul = obj; |
|
193 |
} |
|
194 |
else |
|
195 |
{ |
|
196 |
return false; |
|
197 |
} |
|
198 |
||
199 |
if (!isOverObj(a, false, event) && !isOverObj(ul, true, event)) |
|
200 |
{ |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
201 |
$(a).rmClass('liteselected'); |
1 | 202 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
203 |
if ( jBox_slide_enable ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
204 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
205 |
slideIn(ul); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
206 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
207 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
208 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
209 |
ul.style.display = 'none'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
210 |
} |
1 | 211 |
|
212 |
} |
|
213 |
||
214 |
return true; |
|
215 |
} |
|
216 |
||
217 |
// Slide an element downwards until it is at full height. |
|
218 |
// First parameter should be a DOM object with style.display = block and opacity = 0. |
|
219 |
||
220 |
var sliderobj = new Object(); |
|
221 |
||
222 |
function slideOut(obj) |
|
223 |
{ |
|
224 |
if ( jBoxSlideBlocker[obj.id] ) |
|
225 |
return false; |
|
226 |
||
227 |
jBoxSlideBlocker[obj.id] = true; |
|
228 |
||
229 |
if ( slide_speed == -1 ) |
|
230 |
{ |
|
231 |
obj.style.display = 'block'; |
|
232 |
return false; |
|
233 |
} |
|
234 |
||
235 |
var currentheight = 0; |
|
236 |
var targetheight = jBoxMenuHeights[obj.id]; |
|
237 |
var inertiabase = inertia_base; |
|
238 |
var inertiainc = inertia_inc; |
|
239 |
slideStep(obj, 0); |
|
240 |
domObjChangeOpac(100, obj); |
|
241 |
obj.style.overflow = 'hidden'; |
|
242 |
||
243 |
// Don't edit past here |
|
244 |
var timercnt = 0; |
|
245 |
||
246 |
var seed = Math.floor(Math.random() * 1000000); |
|
247 |
sliderobj[seed] = obj; |
|
248 |
||
249 |
var framecnt = 0; |
|
250 |
||
251 |
while(true) |
|
252 |
{ |
|
253 |
framecnt++; |
|
254 |
timercnt += ( 100 - slide_speed ); |
|
255 |
inertiabase += inertiainc; |
|
256 |
currentheight += inertiabase; |
|
257 |
if ( currentheight > targetheight ) |
|
258 |
currentheight = targetheight; |
|
259 |
setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+', '+targetheight+');', timercnt); |
|
260 |
if ( currentheight >= targetheight ) |
|
261 |
break; |
|
262 |
} |
|
263 |
timercnt = timercnt + ( 100 - slide_speed ); |
|
264 |
setTimeout('jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt); |
|
265 |
var opacstep = jBox_opacity / framecnt; |
|
266 |
var opac = 0; |
|
267 |
var timerstep = 0; |
|
268 |
domObjChangeOpac(0, obj); |
|
269 |
while(true) |
|
270 |
{ |
|
271 |
timerstep += ( 100 - slide_speed ); |
|
272 |
opac += opacstep; |
|
273 |
setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep); |
|
274 |
if ( opac >= jBox_opacity ) |
|
275 |
break; |
|
276 |
} |
|
277 |
} |
|
278 |
||
279 |
function slideIn(obj) |
|
280 |
{ |
|
281 |
if ( obj.style.display != 'block' ) |
|
282 |
return false; |
|
283 |
||
284 |
if ( jBoxSlideBlocker[obj.id] ) |
|
285 |
return false; |
|
286 |
||
287 |
jBoxSlideBlocker[obj.id] = true; |
|
288 |
||
289 |
var targetheight = 0; |
|
290 |
var dim = fetch_dimensions(obj); |
|
291 |
var currentheight = jBoxMenuHeights[obj.id]; |
|
292 |
var origheight = currentheight; |
|
293 |
var inertiabase = inertia_base; |
|
294 |
var inertiainc = inertia_inc; |
|
295 |
domObjChangeOpac(100, obj); |
|
296 |
obj.style.overflow = 'hidden'; |
|
297 |
||
298 |
// Don't edit past here |
|
299 |
var timercnt = 0; |
|
300 |
||
301 |
var seed = Math.floor(Math.random() * 1000000); |
|
302 |
sliderobj[seed] = obj; |
|
303 |
||
304 |
var framecnt = 0; |
|
305 |
||
306 |
for(var j = 0;j<100;j++) // while(true) |
|
307 |
{ |
|
308 |
framecnt++; |
|
309 |
timercnt = timercnt + ( 100 - slide_speed ); |
|
310 |
inertiabase = inertiabase + inertiainc; |
|
311 |
currentheight = currentheight - inertiabase; |
|
312 |
if ( currentheight < targetheight ) |
|
313 |
currentheight = targetheight; |
|
314 |
setTimeout('slideStep(sliderobj['+seed+'], '+currentheight+');', timercnt); |
|
315 |
if ( currentheight <= targetheight ) |
|
316 |
break; |
|
317 |
} |
|
318 |
timercnt += ( 100 - slide_speed ); |
|
319 |
setTimeout('sliderobj['+seed+'].style.display="none";sliderobj['+seed+'].style.height="'+origheight+'px";jBoxSlideBlocker[sliderobj['+seed+'].id] = false;', timercnt); |
|
320 |
||
321 |
var opacstep = jBox_opacity / framecnt; |
|
322 |
var opac = jBox_opacity; |
|
323 |
var timerstep = 0; |
|
324 |
domObjChangeOpac(100, obj); |
|
325 |
while(true) |
|
326 |
{ |
|
327 |
timerstep += ( 100 - slide_speed ); |
|
328 |
opac -= opacstep; |
|
329 |
setTimeout('domObjChangeOpac('+opac+', sliderobj['+seed+']);', timerstep); |
|
330 |
if ( opac <= 0 ) |
|
331 |
break; |
|
332 |
} |
|
333 |
||
334 |
} |
|
335 |
||
336 |
function slideStep(obj, height, maxheight) |
|
337 |
{ |
|
338 |
obj.style.height = height + 'px'; |
|
339 |
//obj.style.clip = 'rect(3px,auto,'+maxheight+'px,auto)'; |
|
340 |
obj.style.overflow = 'hidden'; |
|
341 |
//obj.style.clip = 'rect('+height+'px,0px,'+maxheight+'px,auto);'; |
|
342 |
} |
|
343 |
||
344 |
function isOverObj(obj, bias, event) |
|
345 |
{ |
|
346 |
var fieldUL = new Object(); |
|
347 |
var dim = fetch_dimensions(obj); |
|
348 |
var off = fetch_offset(obj); |
|
349 |
fieldUL['top'] = off['top']; |
|
350 |
fieldUL['left'] = off['left']; |
|
351 |
fieldUL['right'] = off['left'] + dim['w']; |
|
352 |
fieldUL['bottom'] = off['top'] + dim['h']; |
|
353 |
||
394
fbfdcea634a7
Fixed jBox menus failing to appear when window scrolled down
Dan
parents:
128
diff
changeset
|
354 |
var mouseY_local = mouseY + getScrollOffset(); |
fbfdcea634a7
Fixed jBox menus failing to appear when window scrolled down
Dan
parents:
128
diff
changeset
|
355 |
|
fbfdcea634a7
Fixed jBox menus failing to appear when window scrolled down
Dan
parents:
128
diff
changeset
|
356 |
// document.getElementById('debug').innerHTML = '<br />Mouse: x: '+mouseX+', y:' + mouseY + '<br />' + document.getElementById('debug').innerHTML; |
1 | 357 |
|
358 |
if(bias) |
|
359 |
{ |
|
360 |
if ( ( mouseX < fieldUL['left'] + 2 || mouseX > fieldUL['right'] - 5 ) || |
|
394
fbfdcea634a7
Fixed jBox menus failing to appear when window scrolled down
Dan
parents:
128
diff
changeset
|
361 |
( mouseY_local < fieldUL['top'] - 2 || mouseY_local > fieldUL['bottom'] - 2 ) ) |
1 | 362 |
{ |
363 |
return false; |
|
364 |
} |
|
365 |
} |
|
366 |
else |
|
367 |
{ |
|
368 |
if ( ( mouseX < fieldUL['left'] || mouseX > fieldUL['right'] ) || |
|
394
fbfdcea634a7
Fixed jBox menus failing to appear when window scrolled down
Dan
parents:
128
diff
changeset
|
369 |
( mouseY_local < fieldUL['top'] || mouseY_local > fieldUL['bottom'] ) ) |
1 | 370 |
return false; |
371 |
} |
|
372 |
||
373 |
return true; |
|
374 |
} |
|
375 |
||
376 |
function jBoxGarbageCollection(e) |
|
377 |
{ |
|
378 |
setMousePos(e); |
|
379 |
var menus = document.getElementsByClassName('div', 'menu'); |
|
380 |
if ( menus.length > 0 ) |
|
381 |
{ |
|
382 |
for ( var i in menus ) |
|
383 |
{ |
|
384 |
if ( typeof(menus[i]) != 'object') |
|
385 |
continue; // toJSONString() compatibility |
|
386 |
var uls = menus[i].getElementsByTagName('ul'); |
|
387 |
if ( uls.length > 0 ) |
|
388 |
{ |
|
389 |
for ( var j = 0; j < uls.length; j++ ) |
|
390 |
{ |
|
391 |
if ( !isOverObj(uls[j], false, e) ) |
|
392 |
{ |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
393 |
$(uls[j].previousSibling).rmClass('liteselected'); |
1 | 394 |
//uls[j].style.display = 'none'; |
395 |
slideIn(uls[j]); |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
var uls = getElementsByClassName(menus[i], 'divs', 'submenu'); |
|
400 |
if ( uls.length > 0 ) |
|
401 |
{ |
|
402 |
for ( var j = 0; j < uls.length; j++ ) |
|
403 |
{ |
|
404 |
if ( !isOverObj(uls[j], false, e) ) |
|
405 |
{ |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
80
diff
changeset
|
406 |
$(uls[j].previousSibling).rmClass('liteselected'); |
1 | 407 |
//uls[j].style.display = 'none'; |
408 |
slideIn(uls[j]); |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
} |
|
415 |
||
416 |
document.onclick = jBoxGarbageCollection; |
|
417 |
||
418 |
function removeTextNodes(obj) |
|
419 |
{ |
|
420 |
if(obj) |
|
421 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
422 |
if(typeof(obj.tagName) != 'string' || ( String(obj) == '[object Text]' && is_Safari ) ) |
1 | 423 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
424 |
if ( ( obj.nodeType == 3 && obj.data.match(/^([\s]*)$/ig) ) ) // || ( typeof(obj.innerHTML) == undefined && is_Safari ) ) |
1 | 425 |
{ |
426 |
obj.parentNode.removeChild(obj); |
|
427 |
return; |
|
428 |
} |
|
429 |
} |
|
430 |
if(obj.firstChild) |
|
431 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
432 |
for(var i = 0; i < obj.childNodes.length; i++) |
1 | 433 |
{ |
434 |
removeTextNodes(obj.childNodes[i]); |
|
435 |
} |
|
436 |
} |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
var getElementsByClassName = function(parent, type, cls) { |
|
441 |
if(!type) |
|
442 |
type = '*'; |
|
443 |
ret = new Array(); |
|
444 |
el = parent.getElementsByTagName(type); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
445 |
for ( var i = 0; i < el.length; i++ ) |
1 | 446 |
{ |
447 |
if ( typeof(el[i]) != 'object') |
|
448 |
continue; // toJSONString() compatibility |
|
449 |
if(el[i].className) |
|
450 |
{ |
|
451 |
if(el[i].className.indexOf(' ') > 0) |
|
452 |
{ |
|
453 |
classes = el[i].className.split(' '); |
|
454 |
} |
|
455 |
else |
|
456 |
{ |
|
457 |
classes = new Array(); |
|
458 |
classes.push(el[i].className); |
|
459 |
} |
|
460 |
if ( in_array(cls, classes) ) |
|
461 |
ret.push(el[i]); |
|
462 |
} |
|
463 |
} |
|
464 |
return ret; |
|
465 |
} |
|
466 |
||
467 |
document.getElementsByClassName = function(type, cls) { |
|
468 |
return getElementsByClassName(document, type, cls); |
|
469 |
} |
|
470 |
||
471 |
function setMousePos(event) |
|
472 |
{ |
|
473 |
if(IE) |
|
474 |
{ |
|
475 |
if(!event) |
|
476 |
{ |
|
477 |
event = window.event; |
|
478 |
} |
|
479 |
clX = event.clientX; |
|
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
57
diff
changeset
|
480 |
if ( document.body ) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
57
diff
changeset
|
481 |
sL = document.body.scrollLeft; |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
57
diff
changeset
|
482 |
else |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
57
diff
changeset
|
483 |
sL = 0; |
1 | 484 |
mouseX = clX + sL; |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
57
diff
changeset
|
485 |
mouseY = event.clientY + ( document.body ? document.body.scrollTop : 0 ); |
1 | 486 |
return; |
487 |
} |
|
488 |
if( typeof(event.clientX) == 'number' ) |
|
489 |
{ |
|
490 |
mouseX = event.clientX; |
|
491 |
mouseY = event.clientY; |
|
492 |
return; |
|
493 |
} |
|
494 |
else if( typeof(event.layerX) == 'number' ) |
|
495 |
{ |
|
496 |
mouseX = event.layerX; |
|
497 |
mouseY = event.layerY; |
|
498 |
return; |
|
499 |
} |
|
500 |
else if( typeof(event.offsetX) == 'number' ) |
|
501 |
{ |
|
502 |
mouseX = event.offsetX; |
|
503 |
mouseY = event.offsetY; |
|
504 |
return; |
|
505 |
} |
|
506 |
else if( typeof(event.screenX) == 'number' ) |
|
507 |
{ |
|
508 |
mouseX = event.screenX; |
|
509 |
mouseY = event.screenY; |
|
510 |
return; |
|
511 |
} |
|
512 |
else if( typeof(event.x) == 'number' ) |
|
513 |
{ |
|
514 |
mouseX = event.x; |
|
515 |
mouseY = event.y; |
|
516 |
return; |
|
517 |
} |
|
518 |
} |
|
519 |
||
520 |
document.onmousemove = function(e) |
|
521 |
{ |
|
522 |
setMousePos(e); |
|
523 |
}; |
|
524 |
||
525 |
function domObjChangeOpac(opacity, id) { |
|
526 |
var object = id.style; |
|
527 |
object.opacity = (opacity / 100); |
|
528 |
object.MozOpacity = (opacity / 100); |
|
529 |
object.KhtmlOpacity = (opacity / 100); |
|
530 |
object.filter = "alpha(opacity=" + opacity + ")"; |
|
531 |
} |
|
532 |