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