1// page init 2jQuery(function(){ 3 initTabNav(); 4 initNavigation(); 5}); 6 7// navigation init 8function initNavigation() { 9 jQuery('ul#primary-menu').animDropdown(); 10 jQuery('ul#primary-menu').animDropdown({ 11 effect: 'fade', 12 delay: 5 13 }); 14} 15 16// "tab" key handling 17function initTabNav() { 18 jQuery('.main-menu').tabNav({ 19 items: 'li' 20 }); 21} 22 23/* 24 * Accessible TAB navigation 25 */ 26;(function($){ 27 var isWindowsPhone = /Windows Phone/.test(navigator.userAgent); 28 var isTouchDevice = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; 29 30 $.fn.tabNav = function(opt) { 31 var options = $.extend({ 32 hoverClass: 'hover', 33 items: 'li', 34 opener: '>a', 35 delay: 10 36 },opt); 37 38 if(isWindowsPhone || isTouchDevice) { 39 return this; 40 } 41 42 return this.each(function() { 43 var nav = $(this), items = nav.find(options.items); 44 45 items.each(function(index, navItem) { 46 var item = $(this), navActive, touchNavActive; 47 var link = item.find(options.opener), timer; 48 49 link.bind('focus', function() { 50 navActive = nav.hasClass('js-nav-active'); 51 touchNavActive = window.TouchNav && TouchNav.isActiveOn(navItem); 52 if(!navActive || touchNavActive) { 53 initSimpleNav(); 54 } 55 item.trigger(navActive && touchNavActive ? 'itemhover' : 'mouseenter'); 56 }).bind('blur', function() { 57 item.trigger(navActive && touchNavActive ? 'itemleave' : 'mouseleave'); 58 }); 59 60 var initSimpleNav = function() { 61 if(!initSimpleNav.done) { 62 initSimpleNav.done = true; 63 item.hover(function() { 64 clearTimeout(timer); 65 timer = setTimeout(function() { 66 item.addClass(options.hoverClass); 67 }, options.delay); 68 }, function() { 69 clearTimeout(timer); 70 timer = setTimeout(function() { 71 item.removeClass(options.hoverClass); 72 }, options.delay); 73 }); 74 } 75 }; 76 }); 77 }); 78 }; 79}(jQuery)); 80 81/* 82 * jQuery Dropdown plugin 83 */ 84;(function($){ 85 $.fn.animDropdown = function(o){ 86 // default options 87 var options = $.extend({ 88 hoverClass:'hover', 89 dropClass:'drop-active', 90 items: 'li', 91 drop: '>ul', 92 delay: 100, 93 animSpeed: 300, 94 effect: 'fade' 95 },o); 96 97 return this.each(function(){ 98 // options 99 var nav = $(this); 100 items = nav.find(options.items); 101 102 items.addClass(options.hoverClass).each(function(){ 103 var item = $(this), delayTimer; 104 var drop = item.find(options.drop); 105 item.data('drop', drop); 106 if(drop.length) { 107 dropdownEffects[options.effect].prepare({item:item,drop:drop}); 108 } 109 110 item.bind('mouseenter', function(){ 111 hideAllDropdowns(item); 112 item.addClass(options.hoverClass); 113 clearTimeout(delayTimer); 114 delayTimer = setTimeout(function(){ 115 if(drop.length && item.hasClass(options.hoverClass)) { 116 item.addClass(options.dropClass); 117 dropdownEffects[options.effect].animate({drop:drop, state:true, speed:options.animSpeed, complete:function(){ 118 // callback 119 }}); 120 } 121 }, options.delay); 122 item.data('timer', delayTimer); 123 }).bind('mouseleave', function(){ 124 if(!item.hasClass(options.dropClass)) { 125 item.removeClass(options.hoverClass); 126 } 127 clearTimeout(delayTimer); 128 delayTimer = setTimeout(function(){ 129 if(drop.length && item.hasClass(options.dropClass)) { 130 dropdownEffects[options.effect].animate({drop:drop, state:false, speed:options.animSpeed, complete:function(){ 131 // callback 132 item.removeClass(options.hoverClass); 133 item.removeClass(options.dropClass); 134 }}); 135 } 136 }, options.delay); 137 item.data('timer', delayTimer); 138 }); 139 }); 140 141 // hide dropdowns 142 items.removeClass(options.hoverClass); 143 if(dropdownEffects[options.effect].postProcess) { 144 items.each(function(){ 145 dropdownEffects[options.effect].postProcess({item: $(this)}); 146 }); 147 } 148 149 // hide current level dropdowns 150 function hideAllDropdowns(except) { 151 var siblings = except.siblings();
152 siblings.removeClass(options.hoverClass).each(function(){ 153 var item = $(this); 154 clearTimeout(item.data('timer')); 155 }); 156 siblings.filter('.' + options.dropClass).each(function(){ 157 var item = jQuery(this).removeClass(options.dropClass); 158 if(item.data('drop').length) { 159 dropdownEffects[options.effect].animate({drop:item.data('drop'), state:false, speed:options.animSpeed}); 160 } 161 }); 162 } 163 }); 164 } 165 166 // dropdown effects 167 var dropdownEffects = { 168 fade: { 169 prepare: function(o) { 170 o.drop.css({opacity:0,visibility:'none'}); 171 }, 172 animate: function(o) { 173 o.drop.stop().show().animate({opacity: o.state ? 1 : 0},{duration: o.speed || 0, complete: function(){ 174 if(o.state) { 175 o.drop.css({opacity:''}); 176 } else { 177 o.drop.css({opacity:0,display:'none'}); 178 } 179 if(typeof o.complete === 'function') { 180 o.complete.call(o.drop); 181 } 182 }}); 183 } 184 }, 185 slide: { 186 prepare: function(o) { 187 var elementHeight = o.drop.show().outerHeight(true); 188 var elementWidth = o.drop.show().outerWidth(true); 189 var elementWrap = o.drop.wrap('<div class="drop-slide-wrapper">').parent(); 190 elementWrap.css({ 191 height:elementHeight, 192 width: elementWidth, 193 position:'absolute', 194 overflow:'hidden', 195 top: o.drop.css('top'), 196 left: o.drop.css('left') 197 }); 198 o.drop.css({ 199 position:'static', 200 display:'block', 201 top: 'auto', 202 left: 'auto' 203 }); 204 o.drop.data('height', elementHeight).data('wrap', elementWrap).css({marginTop: -elementHeight}); 205 }, 206 animate: function(o) { 207 o.drop.data('wrap').show().css({overflow:'hidden'}); 208 o.drop.stop().animate({marginTop: o.state ? 0 : -o.drop.data('height')},{duration: o.speed || 0, complete: function(){ 209 if(o.state) { 210 o.drop.css({marginTop:''}); 211 o.drop.data('wrap').css({overflow:''}); 212 } else { 213 o.drop.data('wrap').css({display:'none'}); 214 } 215 if(typeof o.complete === 'function') { 216 o.complete.call(o.drop); 217 } 218 }}); 219 }, 220 postProcess: function(o) { 221 if(o.item.data('drop').length) { 222 o.item.data('drop').data('wrap').css({display:'none'}); 223 } 224 } 225 } 226 } 227}(jQuery));
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.