1/* 2 * jQuery Superfish Menu Plugin - v1.7.4 3 * Copyright (c) 2013 Joel Birch 4 * 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 */ 9 10;(function ($) { 11 "use strict"; 12 13 14 $(window).on('resize',function(){ 15 $('.sf-menu ul.tracked-pos').removeClass('tracked-pos'); 16 }); 17 18 var methods = (function () { 19 // private properties and methods go here 20 var c = { 21 bcClass: 'sf-breadcrumb', 22 menuClass: 'sf-js-enabled', 23 anchorClass: 'sf-with-ul', 24 menuArrowClass: 'sf-arrows' 25 }, 26 ios = (function () { 27 var ios = /iPhone|iPad|iPod/i.test(navigator.userAgent); 28 if (ios) { 29 // tap anywhere on iOS to unfocus a submenu 30 $('html').css('cursor', 'pointer').on('click', $.noop); 31 } 32 return ios; 33 })(), 34 wp7 = (function () { 35 var style = document.documentElement.style; 36 return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent)); 37 })(), 38 toggleMenuClasses = function ($menu, o) { 39 var classes = c.menuClass; 40 if (o.cssArrows) { 41 classes += ' ' + c.menuArrowClass; 42 } 43 $menu.toggleClass(classes); 44 }, 45 setPathToCurrent = function ($menu, o) { 46 return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels) 47 .addClass(o.hoverClass + ' ' + c.bcClass) 48 .filter(function () { 49 return ($(this).children(o.popUpSelector).hide().show().length); 50 }).removeClass(o.pathClass); 51 }, 52 toggleAnchorClass = function ($li) { 53 $li.children('a').toggleClass(c.anchorClass); 54 }, 55 toggleTouchAction = function ($menu) { 56 var touchAction = $menu.css('ms-touch-action'); 57 touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y'; 58 $menu.css('ms-touch-action', touchAction); 59 }, 60 applyHandlers = function ($menu, o) { 61 var targets = 'li:has(' + o.popUpSelector + ')'; 62 if ($.fn.hoverIntent && !o.disableHI) { 63 $menu.hoverIntent(over, out, targets); 64 } 65 else { 66 $menu 67 .on('mouseenter.superfish', targets, over) 68 .on('mouseleave.superfish', targets, out); 69 } 70 var touchevent = 'MSPointerDown.superfish'; 71 if (!ios) { 72 touchevent += ' touchend.superfish'; 73 } 74 if (wp7) { 75 touchevent += ' mousedown.superfish'; 76 } 77 $menu 78 .on('focusin.superfish', 'li', over) 79 .on('focusout.superfish', 'li', out) 80 .on(touchevent, 'a', o, touchHandler); 81 }, 82 touchHandler = function (e) { 83 var $this = $(this), 84 $ul = $this.siblings(e.data.popUpSelector); 85 86 if ($ul.length > 0 && $ul.is(':hidden')) { 87 $this.one('click.superfish', false); 88 if (e.type === 'MSPointerDown') { 89 $this.trigger('focus'); 90 } else { 91 $.proxy(over, $this.parent('li'))(); 92 } 93 } 94 }, 95 over = function () { 96 var $this = $(this), 97 o = getOptions($this); 98 99 if($(this).parents('.megamenu').length > 0) return; 100 101 clearTimeout(o.sfTimer); 102 $this.siblings().superfish('hide').end().superfish('show'); 103 }, 104 out = function () { 105 var $this = $(this), 106 o = getOptions($this); 107 if (ios) { 108 $.proxy(close, $this, o)(); 109 } 110 else { 111 clearTimeout(o.sfTimer); 112 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay); 113 } 114 }, 115 close = function (o) { 116 o.retainPath = ($.inArray(this[0], o.$path) > -1); 117 this.superfish('hide'); 118 119 if (!this.parents('.' + o.hoverClass).length) { 120 o.onIdle.call(getMenu(this)); 121 if (o.$path.length) { 122 $.proxy(over, o.$path)(); 123 } 124 } 125 }, 126 getMenu = function ($el) { 127 return $el.closest('.' + c.menuClass); 128 }, 129 getOptions = function ($el) { 130 return getMenu($el).data('sf-options'); 131 }; 132 133 return { 134 // public methods 135 hide: function (instant) { 136 if (this.length) { 137 var $this = this, 138 o = getOptions($this); 139 if (!o) { 140 return this; 141 } 142 143 if($(this).hasClass('menu-item-over') && $(this).hasClass('megamenu')) { 144 return true; 145 } 146 147 var not = (o.retainPath === true) ? o.$path : '', 148 $ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector), 149 speed = o.speedOut; 150 151 if (instant) { 152 $ul.show(); 153 speed = 0; 154 } 155 o.retainPath = false; 156 o.onBeforeHide.call($ul); 157 158 if(o.dropdownStyle == 'minimal') { 159 var $this = $(this); 160 o.onHide.call($this); 161 } else { 162 163 $ul.stop(true, true).animate(o.animationOut, speed, function () { 164 var $this = $(this); 165 o.onHide.call($this); 166 });
167 } 168 169 if($(this).parents('.megamenu').length > 0) return; 170 171 //megamenu removes transparent option 172 if($('#header-outer[data-megamenu-rt="1"]').length > 0 && $('#header-outer[data-transparent-header="true"]').length > 0) { 173 174 if($('#header-outer.scrolled-down').length == 0 && $('#header-outer.small-nav').length == 0 && $('#header-outer.detached').length == 0 && $('#header-outer.fixed-menu').length == 0) { 175 $('#header-outer').addClass('transparent'); 176 } 177 if($('#header-outer[data-permanent-transparent="1"][data-transparent-header="true"]').length > 0) { 178 $('#header-outer').addClass('transparent'); 179 } 180 181 } 182 } 183 return this; 184 }, 185 show: function () { 186 187 if($(this).parents('.megamenu').length > 0) return; 188 189 var o = getOptions(this); 190 if (!o) { 191 return this; 192 } 193 var $this = this.addClass(o.hoverClass), 194 $ul = $this.children(o.popUpSelector); 195 196 197 //megamenu removes transparent option 198 if($('#header-outer[data-megamenu-rt="1"]').length > 0 && 199 $(this).hasClass('megamenu') && 200 !$(this).hasClass('width-75') && 201 !$(this).hasClass('width-50') && 202 $('#header-outer').attr('data-transparent-header') == 'true' ) { 203 204 $('#header-outer').addClass('no-transition'); 205 $('#header-outer').removeClass('transparent'); 206 207 } 208 209 o.onBeforeShow.call($ul); 210 211 212 //make sure the ul has space 213 if(!$ul.hasClass('tracked-pos') && 214 !$($ul).parents('li').hasClass('megamenu') && 215 !$($ul).parents('ul').hasClass('sub-menu') && 216 $ul.offset() ) { 217 218 $ul.addClass('temp-hidden-display'); 219 var docW = $("#top .container").width(); 220 var elm = $ul; 221 var off = elm.offset(); 222 var l = off.left - ($(window).width() - docW)/2; 223 var w = elm.width(); 224 var isEntirelyVisible = (l+w <= $(window).width()-100); 225 226 if ( ! isEntirelyVisible ) { 227 $ul.parents('li').addClass('edge'); 228 } else { 229 $ul.parents('li').removeClass('edge'); 230 } 231 232 $ul.removeClass('temp-hidden-display'); 233 234 } 235 236 if(o.dropdownStyle == 'minimal') { 237 o.onShow.call($ul); 238 } else { 239 $ul.stop(true, true).animate(o.animation, o.speed, function () { 240 o.onShow.call($ul); 241 }); 242 } 243 244 //show on left class 245 if( !$ul.hasClass('tracked-pos') ) { 246 if( $ul.length > 0 && $ul.parents('.sub-menu').length > 0 && $ul.parents('.sf-menu').length > 0 ) { 247 if($ul.offset().left + $ul.outerWidth() > $(window).width()) { 248 $ul.addClass('on-left-side'); 249 $ul.find('ul').addClass('on-left-side'); 250 } 251 } 252 } 253 254 $ul.addClass('tracked-pos'); 255 256 return this; 257 }, 258 destroy: function () { 259 return this.each(function () { 260 var $this = $(this), 261 o = $this.data('sf-options'), 262 $hasPopUp; 263 if (!o) { 264 return false; 265 } 266 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 267 clearTimeout(o.sfTimer); 268 toggleMenuClasses($this, o); 269 toggleAnchorClass($hasPopUp); 270 toggleTouchAction($this); 271 // remove event handlers 272 $this.off('.superfish').off('.hoverIntent'); 273 // clear animation's inline display style 274 $hasPopUp.children(o.popUpSelector).attr('style', function (i, style) { 275 return style.replace(/display[^;]+;?/g, ''); 276 }); 277 // reset 'current' path classes 278 o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass); 279 $this.find('.' + o.hoverClass).removeClass(o.hoverClass); 280 o.onDestroy.call($this); 281 $this.removeData('sf-options'); 282 }); 283 }, 284 init: function (op) { 285 return this.each(function () { 286 var $this = $(this); 287 if ($this.data('sf-options')) { 288 return false; 289 } 290 var o = $.extend({}, $.fn.superfish.defaults, op), 291 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 292 o.$path = setPathToCurrent($this, o); 293 294 $this.data('sf-options', o); 295 296 toggleMenuClasses($this, o); 297 toggleAnchorClass($hasPopUp); 298 toggleTouchAction($this); 299 applyHandlers($this, o); 300 301 $hasPopUp.not('.' + c.bcClass).superfish('hide', true); 302 303 o.onInit.call(this); 304 }); 305 } 306 }; 307 })(); 308 309 $.fn.superfish = function (method, args) { 310 if (methods[method]) { 311 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 312 } 313 else if (typeof method === 'object' || ! method) { 314 return methods.init.apply(this, arguments); 315 } 316 else { 317 return $.error('Method ' + method + ' does not exist on jQuery.fn.superfish'); 318 } 319 }; 320 321 $.fn.superfish.defaults = { 322 popUpSelector: 'ul,.sf-mega', // within menu context 323 hoverClass: 'sfHover', 324 pathClass: 'overrideThisToUse', 325 pathLevels: 1, 326 delay: 800, 327 animation: {opacity: 'show'}, 328 animationOut: {opacity: 'hide'}, 329 speed: 'normal', 330 speedOut: 'fast', 331 cssArrows: true, 332 disableHI: false, 333 onInit: $.noop, 334 onBeforeShow: $.noop, 335 onShow: $.noop, 336 onBeforeHide: $.noop, 337 onHide: $.noop, 338 onIdle: $.noop, 339 onDestroy: $.noop, 340 dropdownStyle: ($('body[data-dropdown-style="minimal"]').length > 0) ? 'minimal' : 'classic' 341 }; 342 343 // soon to be deprecated 344 $.fn.extend({ 345 hideSuperfishUl: methods.hide, 346 showSuperfishUl: methods.show 347 }); 348 349})(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.