1var blinding = false; 2 3// stores our timer id for the menu disappearing 4var timers = new Hash(); 5 6// go through each one and add the relevant styles and events 7Event.observe(window, 'load', applyFunkyJSToSubmenus); 8 9// on resize, make sure they stay where they're supposed to be 10Event.observe(window, 'resize', repositionSubmenus); 11Event.observe(window, 'load', function() { window.setTimeout(repositionSubmenus, 200); }); // and position them now 12 13function showMenu(item) { 14 // reset the "hide" timer 15 16 if (blinding === true) { // if we're blinding we only want to clear our own timer on mouseover 17 18 if (timers.get(item.identify())) // if the timer exists 19 window.clearTimeout(timers.unset(item.identify())); // removes the id from the hash and tells the window to clear it :) 20 21 } else { // not blinding, we need to clear them all and hide them all 22 timers.values().each(function(timer) { window.clearTimeout(timer); }); // clear all the timeouts 23 timers = new Hash(); // easiest way to clear the timers I think! 24 25 $$('.subnav').select(function(menu) { 26 return menu.identify() != item.identify(); 27 }).invoke('hide'); // and hide them all except this one 28 29 } 30 31 // show the menu 32 if (item.style.display == 'none') { 33 if (blinding === true) Effect.BlindDown(item, { duration: 0.4 }); // blinding doesn't work very well for some reason 34 else item.show(); 35 } 36} 37 38function hideMenu(item) { 39 if (item.style.display != 'none') 40 timers.set(item.identify(), window.setTimeout(function() { 41 if (blinding === true) Effect.BlindUp(item, { duration: 0.4 }); // blinding doesn't work very well for some reason 42 else item.hide(); 43 }, 250)); 44} 45 46function repositionSubmenus() { 47 $$('.subnav').each(function(item) { 48 var parentPos = item.up().cumulativeOffset(); // the containing <li> 49 50 item.setStyle({ 51 left: parentPos.left + -'18' + 'px', 52 top: (parentPos.top + item.up().offsetHeight + 0) + 'px' 53 }); 54 }); 55} 56 57function applyFunkyJSToSubmenus() { 58 $$('.subnav').each(function(item) { 59 var pn = item.up(); // the containing <li> 60 61 // fix ie6 spacing problems 62 item.cleanWhitespace(); 63 item.descendants().each(function(item) { if (item.cleanWhitespace) item.cleanWhitespace(); }); 64 65 item.hide(); 66 67 if (!Prototype.Browser.IE) 68 item.setOpacity(0.8); 69 70 // make it show the submenu on mouseover 71 pn.observe('mouseover', function() { showMenu(item); }); 72 pn.observe('mouseout', function() { hideMenu(item); }); 73 }); 74}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.