##// END OF EJS Templates
HTML select tags are no longer hidden with IE7 when showing navigation drop-down menu....
Jean-Philippe Lang -
r497:10a49d476d93
parent child
Show More
@@ -1,556 +1,556
1 1 //*****************************************************************************
2 2 // Do not remove this notice.
3 3 //
4 4 // Copyright 2000-2004 by Mike Hall.
5 5 // See http://www.brainjar.com for terms of use.
6 6 //*****************************************************************************
7 7
8 8 //----------------------------------------------------------------------------
9 9 // Emulation de la fonction push pour IE5.0
10 10 //----------------------------------------------------------------------------
11 11 if(!Array.prototype.push){Array.prototype.push=function(){for(var i=0;i<arguments.length;i++)this[this.length]=arguments[i];};};
12 12
13 13 //----------------------------------------------------------------------------
14 14 // Code to determine the browser and version.
15 15 //----------------------------------------------------------------------------
16 16
17 17 function Browser() {
18 18
19 19 var ua, s, i;
20 20
21 21 this.isIE = false; // Internet Explorer
22 22 this.isOP = false; // Opera
23 23 this.isNS = false; // Netscape
24 24 this.version = null;
25 25 //-- debut ajout ci ----
26 26 this.isIE5mac = false; // Internet Explorer 5 mac
27 27 //-- fin ajout ci ----
28 28
29 29 ua = navigator.userAgent;
30 30
31 31 //-- debut ajout ci ----
32 32 if (ua.indexOf("Opera")==-1 && ua.indexOf("MSIE 5")>-1 && ua.indexOf("Mac")>-1) {
33 33 this.isIE5mac = true;
34 34 this.version = "";
35 35 return;
36 36 }
37 37 //-- fin ajout ci ----
38 38
39 39 s = "Opera";
40 40 if ((i = ua.indexOf(s)) >= 0) {
41 41 this.isOP = true;
42 42 this.version = parseFloat(ua.substr(i + s.length));
43 43 return;
44 44 }
45 45
46 46 s = "Netscape6/";
47 47 if ((i = ua.indexOf(s)) >= 0) {
48 48 this.isNS = true;
49 49 this.version = parseFloat(ua.substr(i + s.length));
50 50 return;
51 51 }
52 52
53 53 // Treat any other "Gecko" browser as Netscape 6.1.
54 54
55 55 s = "Gecko";
56 56 if ((i = ua.indexOf(s)) >= 0) {
57 57 this.isNS = true;
58 58 this.version = 6.1;
59 59 return;
60 60 }
61 61
62 62 s = "MSIE";
63 63 if ((i = ua.indexOf(s))) {
64 64 this.isIE = true;
65 65 this.version = parseFloat(ua.substr(i + s.length));
66 66 return;
67 67 }
68 68 }
69 69
70 70 var browser = new Browser();
71 71
72 72 //----------------------------------------------------------------------------
73 73 // Code for handling the menu bar and active button.
74 74 //----------------------------------------------------------------------------
75 75
76 76 var activeButton = null;
77 77
78 78
79 79 function buttonClick(event, menuId) {
80 80
81 81 var button;
82 82
83 83 // Get the target button element.
84 84
85 85 if (browser.isIE)
86 86 button = window.event.srcElement;
87 87 else
88 88 button = event.currentTarget;
89 89
90 90 // Blur focus from the link to remove that annoying outline.
91 91
92 92 button.blur();
93 93
94 94 // Associate the named menu to this button if not already done.
95 95 // Additionally, initialize menu display.
96 96
97 97 if (button.menu == null) {
98 98 button.menu = document.getElementById(menuId);
99 99 if (button.menu.isInitialized == null)
100 100 menuInit(button.menu);
101 101 }
102 102
103 103 // Set mouseout event handler for the button, if not already done.
104 104
105 105 if (button.onmouseout == null)
106 106 button.onmouseout = buttonOrMenuMouseout;
107 107
108 108 // Exit if this button is the currently active one.
109 109
110 110 if (button == activeButton)
111 111 return false;
112 112
113 113 // Reset the currently active button, if any.
114 114
115 115 if (activeButton != null)
116 116 resetButton(activeButton);
117 117
118 118 // Activate this button, unless it was the currently active one.
119 119
120 120 if (button != activeButton) {
121 121 depressButton(button);
122 122 activeButton = button;
123 123 }
124 124 else
125 125 activeButton = null;
126 126
127 127 return false;
128 128 }
129 129
130 130 function buttonMouseover(event, menuId) {
131 131
132 132 var button;
133 133 //-- debut ajout ci ----
134 134 if (!browser.isIE5mac) {
135 135 //-- fin ajout ci ----
136 136
137 137 //-- debut ajout ci ----
138 138 cicacheselect();
139 139 //-- fin ajout ci ----
140 140
141 141 // Activates this button's menu if no other is currently active.
142 142
143 143 if (activeButton == null) {
144 144 buttonClick(event, menuId);
145 145 return;
146 146 }
147 147
148 148 // Find the target button element.
149 149
150 150 if (browser.isIE)
151 151 button = window.event.srcElement;
152 152 else
153 153 button = event.currentTarget;
154 154
155 155 // If any other button menu is active, make this one active instead.
156 156
157 157 if (activeButton != null && activeButton != button)
158 158 buttonClick(event, menuId);
159 159 //-- debut ajout ci ----
160 160 }
161 161 //-- fin ajout ci ----
162 162
163 163 }
164 164
165 165 function depressButton(button) {
166 166
167 167 var x, y;
168 168
169 169 // Update the button's style class to make it look like it's
170 170 // depressed.
171 171
172 172 button.className += " menuButtonActive";
173 173
174 174 // Set mouseout event handler for the button, if not already done.
175 175
176 176 if (button.onmouseout == null)
177 177 button.onmouseout = buttonOrMenuMouseout;
178 178 if (button.menu.onmouseout == null)
179 179 button.menu.onmouseout = buttonOrMenuMouseout;
180 180
181 181 // Position the associated drop down menu under the button and
182 182 // show it.
183 183
184 184 x = getPageOffsetLeft(button);
185 185 y = getPageOffsetTop(button) + button.offsetHeight - 1;
186 186
187 187 // For IE, adjust position.
188 188
189 189 if (browser.isIE) {
190 190 x += button.offsetParent.clientLeft;
191 191 y += button.offsetParent.clientTop;
192 192 }
193 193
194 194 button.menu.style.left = x + "px";
195 195 button.menu.style.top = y + "px";0
196 196 button.menu.style.visibility = "visible";
197 197 }
198 198
199 199 function resetButton(button) {
200 200
201 201 // Restore the button's style class.
202 202
203 203 removeClassName(button, "menuButtonActive");
204 204
205 205 // Hide the button's menu, first closing any sub menus.
206 206
207 207 if (button.menu != null) {
208 208 closeSubMenu(button.menu);
209 209 button.menu.style.visibility = "hidden";
210 210 }
211 211 }
212 212
213 213 //----------------------------------------------------------------------------
214 214 // Code to handle the menus and sub menus.
215 215 //----------------------------------------------------------------------------
216 216
217 217 function menuMouseover(event) {
218 218
219 219 var menu;
220 220 //-- debut ajout ci ----
221 221 if (!browser.isIE5mac) {
222 222 //-- fin ajout ci ----
223 223 //-- debut ajout ci ----
224 224 cicacheselect();
225 225 //-- fin ajout ci ----
226 226
227 227 // Find the target menu element.
228 228 if (browser.isIE)
229 229 menu = getContainerWith(window.event.srcElement, "DIV", "menu");
230 230 else
231 231 menu = event.currentTarget;
232 232
233 233 // Close any active sub menu.
234 234
235 235 if (menu.activeItem != null)
236 236 closeSubMenu(menu);
237 237 //-- debut ajout ci ----
238 238 }
239 239 //-- fin ajout ci ----
240 240 }
241 241
242 242 function menuItemMouseover(event, menuId) {
243 243
244 244 var item, menu, x, y;
245 245 //-- debut ajout ci ----
246 246 cicacheselect();
247 247 //-- fin ajout ci ----
248 248
249 249 // Find the target item element and its parent menu element.
250 250
251 251 if (browser.isIE)
252 252 item = getContainerWith(window.event.srcElement, "A", "menuItem");
253 253 else
254 254 item = event.currentTarget;
255 255 menu = getContainerWith(item, "DIV", "menu");
256 256
257 257 // Close any active sub menu and mark this one as active.
258 258
259 259 if (menu.activeItem != null)
260 260 closeSubMenu(menu);
261 261 menu.activeItem = item;
262 262
263 263 // Highlight the item element.
264 264
265 265 item.className += " menuItemHighlight";
266 266
267 267 // Initialize the sub menu, if not already done.
268 268
269 269 if (item.subMenu == null) {
270 270 item.subMenu = document.getElementById(menuId);
271 271 if (item.subMenu.isInitialized == null)
272 272 menuInit(item.subMenu);
273 273 }
274 274
275 275 // Set mouseout event handler for the sub menu, if not already done.
276 276
277 277 if (item.subMenu.onmouseout == null)
278 278 item.subMenu.onmouseout = buttonOrMenuMouseout;
279 279
280 280 // Get position for submenu based on the menu item.
281 281
282 282 x = getPageOffsetLeft(item) + item.offsetWidth;
283 283 y = getPageOffsetTop(item);
284 284
285 285 // Adjust position to fit in view.
286 286
287 287 var maxX, maxY;
288 288
289 289 if (browser.isIE) {
290 290 maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
291 291 (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
292 292 maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
293 293 (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
294 294 }
295 295 if (browser.isOP) {
296 296 maxX = document.documentElement.scrollLeft + window.innerWidth;
297 297 maxY = document.documentElement.scrollTop + window.innerHeight;
298 298 }
299 299 if (browser.isNS) {
300 300 maxX = window.scrollX + window.innerWidth;
301 301 maxY = window.scrollY + window.innerHeight;
302 302 }
303 303 maxX -= item.subMenu.offsetWidth;
304 304 maxY -= item.subMenu.offsetHeight;
305 305
306 306 if (x > maxX)
307 307 x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
308 308 + (menu.offsetWidth - item.offsetWidth));
309 309 y = Math.max(0, Math.min(y, maxY));
310 310
311 311 // Position and show the sub menu.
312 312
313 313 item.subMenu.style.left = x + "px";
314 314 item.subMenu.style.top = y + "px";
315 315 item.subMenu.style.visibility = "visible";
316 316
317 317 // Stop the event from bubbling.
318 318
319 319 if (browser.isIE)
320 320 window.event.cancelBubble = true;
321 321 else
322 322 event.stopPropagation();
323 323 }
324 324
325 325 function closeSubMenu(menu) {
326 326
327 327 if (menu == null || menu.activeItem == null)
328 328 return;
329 329
330 330 // Recursively close any sub menus.
331 331
332 332 if (menu.activeItem.subMenu != null) {
333 333 closeSubMenu(menu.activeItem.subMenu);
334 334 menu.activeItem.subMenu.style.visibility = "hidden";
335 335 menu.activeItem.subMenu = null;
336 336 }
337 337 removeClassName(menu.activeItem, "menuItemHighlight");
338 338 menu.activeItem = null;
339 339 }
340 340
341 341
342 342 function buttonOrMenuMouseout(event) {
343 343
344 344 var el;
345 345
346 346 // If there is no active button, exit.
347 347
348 348 if (activeButton == null)
349 349 return;
350 350
351 351 // Find the element the mouse is moving to.
352 352
353 353 if (browser.isIE)
354 354 el = window.event.toElement;
355 355 else if (event.relatedTarget != null)
356 356 el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);
357 357
358 358 // If the element is not part of a menu, reset the active button.
359 359
360 360 if (getContainerWith(el, "DIV", "menu") == null) {
361 361 resetButton(activeButton);
362 362 activeButton = null;
363 363 //-- debut ajout ci ----
364 364 cimontreselect();
365 365 //-- fin ajout ci ----
366 366 }
367 367 }
368 368
369 369
370 370 //----------------------------------------------------------------------------
371 371 // Code to initialize menus.
372 372 //----------------------------------------------------------------------------
373 373
374 374 function menuInit(menu) {
375 375
376 376 var itemList, spanList;
377 377 var textEl, arrowEl;
378 378 var itemWidth;
379 379 var w, dw;
380 380 var i, j;
381 381
382 382 // For IE, replace arrow characters.
383 383
384 384 if (browser.isIE) {
385 385 menu.style.lineHeight = "2.5ex";
386 386 spanList = menu.getElementsByTagName("SPAN");
387 387 for (i = 0; i < spanList.length; i++)
388 388 if (hasClassName(spanList[i], "menuItemArrow")) {
389 389 spanList[i].style.fontFamily = "Webdings";
390 390 spanList[i].firstChild.nodeValue = "4";
391 391 }
392 392 }
393 393
394 394 // Find the width of a menu item.
395 395
396 396 itemList = menu.getElementsByTagName("A");
397 397 if (itemList.length > 0)
398 398 itemWidth = itemList[0].offsetWidth;
399 399 else
400 400 return;
401 401
402 402 // For items with arrows, add padding to item text to make the
403 403 // arrows flush right.
404 404
405 405 for (i = 0; i < itemList.length; i++) {
406 406 spanList = itemList[i].getElementsByTagName("SPAN");
407 407 textEl = null;
408 408 arrowEl = null;
409 409 for (j = 0; j < spanList.length; j++) {
410 410 if (hasClassName(spanList[j], "menuItemText"))
411 411 textEl = spanList[j];
412 412 if (hasClassName(spanList[j], "menuItemArrow"))
413 413 arrowEl = spanList[j];
414 414 }
415 415 if (textEl != null && arrowEl != null) {
416 416 textEl.style.paddingRight = (itemWidth
417 417 - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
418 418 // For Opera, remove the negative right margin to fix a display bug.
419 419 if (browser.isOP)
420 420 arrowEl.style.marginRight = "0px";
421 421 }
422 422 }
423 423
424 424 // Fix IE hover problem by setting an explicit width on first item of
425 425 // the menu.
426 426
427 427 if (browser.isIE) {
428 428 w = itemList[0].offsetWidth;
429 429 itemList[0].style.width = w + "px";
430 430 dw = itemList[0].offsetWidth - w;
431 431 w -= dw;
432 432 itemList[0].style.width = w + "px";
433 433 }
434 434
435 435 // Mark menu as initialized.
436 436
437 437 menu.isInitialized = true;
438 438 }
439 439
440 440 //----------------------------------------------------------------------------
441 441 // General utility functions.
442 442 //----------------------------------------------------------------------------
443 443
444 444 function getContainerWith(node, tagName, className) {
445 445
446 446 // Starting with the given node, find the nearest containing element
447 447 // with the specified tag name and style class.
448 448
449 449 while (node != null) {
450 450 if (node.tagName != null && node.tagName == tagName &&
451 451 hasClassName(node, className))
452 452 return node;
453 453 node = node.parentNode;
454 454 }
455 455
456 456 return node;
457 457 }
458 458
459 459 function hasClassName(el, name) {
460 460
461 461 var i, list;
462 462
463 463 // Return true if the given element currently has the given class
464 464 // name.
465 465
466 466 list = el.className.split(" ");
467 467 for (i = 0; i < list.length; i++)
468 468 if (list[i] == name)
469 469 return true;
470 470
471 471 return false;
472 472 }
473 473
474 474 function removeClassName(el, name) {
475 475
476 476 var i, curList, newList;
477 477
478 478 if (el.className == null)
479 479 return;
480 480
481 481 // Remove the given class name from the element's className property.
482 482
483 483 newList = new Array();
484 484 curList = el.className.split(" ");
485 485 for (i = 0; i < curList.length; i++)
486 486 if (curList[i] != name)
487 487 newList.push(curList[i]);
488 488 el.className = newList.join(" ");
489 489 }
490 490
491 491 function getPageOffsetLeft(el) {
492 492
493 493 var x;
494 494
495 495 // Return the x coordinate of an element relative to the page.
496 496
497 497 x = el.offsetLeft;
498 498 if (el.offsetParent != null)
499 499 x += getPageOffsetLeft(el.offsetParent);
500 500
501 501 return x;
502 502 }
503 503
504 504 function getPageOffsetTop(el) {
505 505
506 506 var y;
507 507
508 508 // Return the x coordinate of an element relative to the page.
509 509
510 510 y = el.offsetTop;
511 511 if (el.offsetParent != null)
512 512 y += getPageOffsetTop(el.offsetParent);
513 513
514 514 return y;
515 515 }
516 516
517 517 //-- debut ajout ci ----
518 518 function cicacheselect(){
519 if (browser.isIE) {
519 if (browser.isIE && browser.version < 7) {
520 520 oSelects = document.getElementsByTagName('SELECT');
521 521 if (oSelects.length > 0) {
522 522 for (i = 0; i < oSelects.length; i++) {
523 523 oSlt = oSelects[i];
524 524 if (oSlt.style.visibility != 'hidden') {oSlt.style.visibility = 'hidden';}
525 525 }
526 526 }
527 527 oSelects = document.getElementsByName('masquable');
528 528 if (oSelects.length > 0) {
529 529 for (i = 0; i < oSelects.length; i++) {
530 530 oSlt = oSelects[i];
531 531 if (oSlt.style.visibility != 'hidden') {oSlt.style.visibility = 'hidden';}
532 532 }
533 533 }
534 534 }
535 535 }
536 536
537 537 function cimontreselect(){
538 if (browser.isIE) {
538 if (browser.isIE && browser.version < 7) {
539 539 oSelects = document.getElementsByTagName('SELECT');
540 540 if (oSelects.length > 0) {
541 541 for (i = 0; i < oSelects.length; i++) {
542 542 oSlt = oSelects[i];
543 543 if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';}
544 544 }
545 545 }
546 546 oSelects = document.getElementsByName('masquable');
547 547 if (oSelects.length > 0) {
548 548 for (i = 0; i < oSelects.length; i++) {
549 549 oSlt = oSelects[i];
550 550 if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';}
551 551 }
552 552 }
553 553 }
554 554 }
555 555
556 556 //-- fin ajout ci ----
General Comments 0
You need to be logged in to leave comments. Login now