author | Dan |
Sun, 02 Dec 2007 16:00:56 -0500 | |
changeset 310 | 199b9708f4a2 |
parent 128 | 01955bf53f96 |
child 394 | fbfdcea634a7 |
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 |
||
354 |
//document.getElementById('debug').innerHTML = '<br /><br /><br /><br /><br />Mouse: x: '+mouseX+', y:' + mouseY + '<br />'; // + document.getElementById('debug').innerHTML; |
|
355 |
||
356 |
if(bias) |
|
357 |
{ |
|
358 |
if ( ( mouseX < fieldUL['left'] + 2 || mouseX > fieldUL['right'] - 5 ) || |
|
359 |
( mouseY < fieldUL['top'] - 2 || mouseY > fieldUL['bottom'] - 2 ) ) |
|
360 |
{ |
|
361 |
return false; |
|
362 |
} |
|
363 |
} |
|
364 |
else |
|
365 |
{ |
|
366 |
if ( ( mouseX < fieldUL['left'] || mouseX > fieldUL['right'] ) || |
|
367 |
( mouseY < fieldUL['top'] || mouseY > fieldUL['bottom'] ) ) |
|
368 |
return false; |
|
369 |
} |
|
370 |
||
371 |
return true; |
|
372 |
||
373 |
/* |
|
374 |
var tgt = event.target; |
|
375 |
if ( !tgt ) |
|
376 |
return false; |
|
377 |
do { |
|
378 |
if ( tgt == obj ) |
|
379 |
return true; |
|
380 |
tgt = tgt.parentNode; |
|
381 |
} while (tgt.tagName.toLowerCase() != 'body' ); |
|
382 |
return false; |
|
383 |
*/ |
|
384 |
} |
|
385 |
||
386 |
function jBoxGarbageCollection(e) |
|
387 |
{ |
|
388 |
setMousePos(e); |
|
389 |
var menus = document.getElementsByClassName('div', 'menu'); |
|
390 |
if ( menus.length > 0 ) |
|
391 |
{ |
|
392 |
for ( var i in menus ) |
|
393 |
{ |
|
394 |
if ( typeof(menus[i]) != 'object') |
|
395 |
continue; // toJSONString() compatibility |
|
396 |
var uls = menus[i].getElementsByTagName('ul'); |
|
397 |
if ( uls.length > 0 ) |
|
398 |
{ |
|
399 |
for ( var j = 0; j < uls.length; j++ ) |
|
400 |
{ |
|
401 |
if ( !isOverObj(uls[j], false, e) ) |
|
402 |
{ |
|
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
|
403 |
$(uls[j].previousSibling).rmClass('liteselected'); |
1 | 404 |
//uls[j].style.display = 'none'; |
405 |
slideIn(uls[j]); |
|
406 |
} |
|
407 |
} |
|
408 |
} |
|
409 |
var uls = getElementsByClassName(menus[i], 'divs', 'submenu'); |
|
410 |
if ( uls.length > 0 ) |
|
411 |
{ |
|
412 |
for ( var j = 0; j < uls.length; j++ ) |
|
413 |
{ |
|
414 |
if ( !isOverObj(uls[j], false, e) ) |
|
415 |
{ |
|
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
|
416 |
$(uls[j].previousSibling).rmClass('liteselected'); |
1 | 417 |
//uls[j].style.display = 'none'; |
418 |
slideIn(uls[j]); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
425 |
||
426 |
document.onclick = jBoxGarbageCollection; |
|
427 |
||
428 |
function removeTextNodes(obj) |
|
429 |
{ |
|
430 |
if(obj) |
|
431 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
432 |
if(typeof(obj.tagName) != 'string' || ( String(obj) == '[object Text]' && is_Safari ) ) |
1 | 433 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
434 |
if ( ( obj.nodeType == 3 && obj.data.match(/^([\s]*)$/ig) ) ) // || ( typeof(obj.innerHTML) == undefined && is_Safari ) ) |
1 | 435 |
{ |
436 |
obj.parentNode.removeChild(obj); |
|
437 |
return; |
|
438 |
} |
|
439 |
} |
|
440 |
if(obj.firstChild) |
|
441 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
442 |
for(var i = 0; i < obj.childNodes.length; i++) |
1 | 443 |
{ |
444 |
removeTextNodes(obj.childNodes[i]); |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
var getElementsByClassName = function(parent, type, cls) { |
|
451 |
if(!type) |
|
452 |
type = '*'; |
|
453 |
ret = new Array(); |
|
454 |
el = parent.getElementsByTagName(type); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
22
diff
changeset
|
455 |
for ( var i = 0; i < el.length; i++ ) |
1 | 456 |
{ |
457 |
if ( typeof(el[i]) != 'object') |
|
458 |
continue; // toJSONString() compatibility |
|
459 |
if(el[i].className) |
|
460 |
{ |
|
461 |
if(el[i].className.indexOf(' ') > 0) |
|
462 |
{ |
|
463 |
classes = el[i].className.split(' '); |
|
464 |
} |
|
465 |
else |
|
466 |
{ |
|
467 |
classes = new Array(); |
|
468 |
classes.push(el[i].className); |
|
469 |
} |
|
470 |
if ( in_array(cls, classes) ) |
|
471 |
ret.push(el[i]); |
|
472 |
} |
|
473 |
} |
|
474 |
return ret; |
|
475 |
} |
|
476 |
||
477 |
document.getElementsByClassName = function(type, cls) { |
|
478 |
return getElementsByClassName(document, type, cls); |
|
479 |
} |
|
480 |
||
481 |
function setMousePos(event) |
|
482 |
{ |
|
483 |
if(IE) |
|
484 |
{ |
|
485 |
if(!event) |
|
486 |
{ |
|
487 |
event = window.event; |
|
488 |
} |
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
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
|
493 |
sL = 0; |
1 | 494 |
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
|
495 |
mouseY = event.clientY + ( document.body ? document.body.scrollTop : 0 ); |
1 | 496 |
return; |
497 |
} |
|
498 |
if( typeof(event.clientX) == 'number' ) |
|
499 |
{ |
|
500 |
mouseX = event.clientX; |
|
501 |
mouseY = event.clientY; |
|
502 |
return; |
|
503 |
} |
|
504 |
else if( typeof(event.layerX) == 'number' ) |
|
505 |
{ |
|
506 |
mouseX = event.layerX; |
|
507 |
mouseY = event.layerY; |
|
508 |
return; |
|
509 |
} |
|
510 |
else if( typeof(event.offsetX) == 'number' ) |
|
511 |
{ |
|
512 |
mouseX = event.offsetX; |
|
513 |
mouseY = event.offsetY; |
|
514 |
return; |
|
515 |
} |
|
516 |
else if( typeof(event.screenX) == 'number' ) |
|
517 |
{ |
|
518 |
mouseX = event.screenX; |
|
519 |
mouseY = event.screenY; |
|
520 |
return; |
|
521 |
} |
|
522 |
else if( typeof(event.x) == 'number' ) |
|
523 |
{ |
|
524 |
mouseX = event.x; |
|
525 |
mouseY = event.y; |
|
526 |
return; |
|
527 |
} |
|
528 |
} |
|
529 |
||
530 |
document.onmousemove = function(e) |
|
531 |
{ |
|
532 |
setMousePos(e); |
|
533 |
}; |
|
534 |
||
535 |
function domObjChangeOpac(opacity, id) { |
|
536 |
var object = id.style; |
|
537 |
object.opacity = (opacity / 100); |
|
538 |
object.MozOpacity = (opacity / 100); |
|
539 |
object.KhtmlOpacity = (opacity / 100); |
|
540 |
object.filter = "alpha(opacity=" + opacity + ")"; |
|
541 |
} |
|
542 |