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