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