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