vendor: 8,526 bytes, lines 1-275
1/* 2 * jQuery Superfish Menu Plugin - v1.7.7 3 * Copyright (c) 2015 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 ($, w) { 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 = /^(?![\w\W]*Windows Phone)[\w\W]*(iPhone|iPad|iPod)/i.test(navigator.userAgent); 23 if (ios) { 24 // tap anywhere on iOS to unfocus a submenu 25 $('html').css('cursor', 'pointer').on('click', $.noop); 26 } 27 return ios; 28 })(), 29 wp7 = (function () { 30 var style = document.documentElement.style; 31 return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent)); 32 })(), 33 unprefixedPointerEvents = (function () { 34 return (!!w.PointerEvent); 35 })(), 36 toggleMenuClasses = function ($menu, o) { 37 var classes = c.menuClass; 38 if (o.cssArrows) { 39 classes += ' ' + c.menuArrowClass; 40 } 41 $menu.toggleClass(classes); 42 }, 43 setPathToCurrent = function ($menu, o) { 44 return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels) 45 .addClass(o.hoverClass + ' ' + c.bcClass) 46 .filter(function () { 47 return ($(this).children(o.popUpSelector).hide().show().length); 48 }).removeClass(o.pathClass); 49 }, 50 toggleAnchorClass = function ($li) { 51 $li.children('a').toggleClass(c.anchorClass); 52 $li.children('span.active').toggleClass(c.anchorClass); 53 }, 54 toggleTouchAction = function ($menu) { 55 var msTouchAction = $menu.css('ms-touch-action'); 56 var touchAction = $menu.css('touch-action'); 57 touchAction = touchAction || msTouchAction; 58 touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y'; 59 $menu.css({ 60 'ms-touch-action': touchAction, 61 'touch-action': touchAction 62 }); 63 }, 64 applyHandlers = function ($menu, o) { 65 var targets = 'li:has(' + o.popUpSelector + ')'; 66 if ($.fn.hoverIntent && !o.disableHI) { 67 $menu.hoverIntent(over, out, targets); 68 } 69 else { 70 $menu 71 .on('mouseenter.superfish', targets, over) 72 .on('mouseleave.superfish', targets, out); 73 } 74 var touchevent = 'MSPointerDown.superfish'; 75 if (unprefixedPointerEvents) { 76 touchevent = 'pointerdown.superfish'; 77 } 78 if (!ios) { 79 touchevent += ' touchend.superfish'; 80 } 81 if (wp7) { 82 touchevent += ' mousedown.superfish'; 83 } 84 $menu 85 .on('focusin.superfish', 'li', over) 86 .on('focusout.superfish', 'li', out) 87 .on(touchevent, 'a', o, touchHandler) 88 .on(touchevent, 'span.active', o, touchHandler); 89 }, 90 touchHandler = function (e) { 91 var $this = $(this), 92 o = getOptions($this), 93 $ul = $this.siblings(e.data.popUpSelector); 94 95 if (o.onHandleTouch.call($ul) === false) { 96 return this; 97 } 98 99 if ($ul.length > 0 && $ul.is(':hidden')) { 100 $this.one('click.superfish', false); 101 if (e.type === 'MSPointerDown' || e.type === 'pointerdown') { 102 $this.trigger('focus'); 103 } else { 104 $.proxy(over, $this.parent('li'))(); 105 } 106 } 107 }, 108 over = function () { 109 var $this = $(this), 110 o = getOptions($this); 111 clearTimeout(o.sfTimer); 112 $this.siblings().superfish('hide').end().superfish('show'); 113 }, 114 out = function () { 115 var $this = $(this), 116 o = getOptions($this); 117 if (ios) { 118 $.proxy(close, $this, o)(); 119 } 120 else { 121 clearTimeout(o.sfTimer); 122 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay); 123 } 124 }, 125 close = function (o) { 126 o.retainPath = ($.inArray(this[0], o.$path) > -1); 127 this.superfish('hide'); 128 129 if (!this.parents('.' + o.hoverClass).length) { 130 o.onIdle.call(getMenu(this)); 131 if (o.$path.length) { 132 $.proxy(over, o.$path)(); 133 } 134 } 135 }, 136 getMenu = function ($el) { 137 return $el.closest('.' + c.menuClass); 138 }, 139 getOptions = function ($el) { 140 return getMenu($el).data('sf-options'); 141 }; 142 143 return { 144 // public methods 145 hide: function (instant) { 146 if (this.length) { 147 var $this = this, 148 o = getOptions($this); 149 if (!o) { 150 return this; 151 } 152 var not = (o.retainPath === true) ? o.$path : '', 153 $ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector), 154 speed = o.speedOut; 155 156 if (instant) { 157 $ul.show(); 158 speed = 0; 159 } 160 o.retainPath = false; 161 162 if (o.onBeforeHide.call($ul) === false) { 163 return this; 164 } 165 166 $ul.stop(true, true).animate(o.animationOut, speed, function () { 167 var $this = $(this); 168 o.onHide.call($this); 169 }); 170 } 171 return this; 172 }, 173 show: function () { 174 var o = getOptions(this); 175 if (!o) { 176 return this; 177 } 178 var $this = this.addClass(o.hoverClass), 179 $ul = $this.children(o.popUpSelector); 180 181 if (o.onBeforeShow.call($ul) === false) { 182 return this; 183 } 184 185 $ul.stop(true, true).animate(o.animation, o.speed, function () { 186 o.onShow.call($ul); 187 }); 188 return this; 189 }, 190 destroy: function () { 191 return this.each(function () { 192 var $this = $(this), 193 o = $this.data('sf-options'), 194 $hasPopUp; 195 if (!o) { 196 return false; 197 } 198 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 199 clearTimeout(o.sfTimer); 200 toggleMenuClasses($this, o); 201 toggleAnchorClass($hasPopUp); 202 toggleTouchAction($this); 203 // remove event handlers 204 $this.off('.superfish').off('.hoverIntent'); 205 // clear animation's inline display style 206 $hasPopUp.children(o.popUpSelector).attr('style', function (i, style) { 207 return style.replace(/display[^;]+;?/g, ''); 208 }); 209 // reset 'current' path classes 210 o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass); 211 $this.find('.' + o.hoverClass).removeClass(o.hoverClass); 212 o.onDestroy.call($this); 213 $this.removeData('sf-options'); 214 }); 215 }, 216 init: function (op) { 217 return this.each(function () { 218 var $this = $(this); 219 if ($this.data('sf-options')) { 220 return false; 221 } 222 var o = $.extend({}, $.fn.superfish.defaults, op), 223 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 224 o.$path = setPathToCurrent($this, o); 225 226 $this.data('sf-options', o); 227 228 toggleMenuClasses($this, o); 229 toggleAnchorClass($hasPopUp); 230 toggleTouchAction($this); 231 applyHandlers($this, o); 232 233 $hasPopUp.not('.' + c.bcClass).superfish('hide', true); 234 235 o.onInit.call(this); 236 }); 237 } 238 }; 239 })(); 240 241 $.fn.superfish = function (method, args) { 242 if (methods[method]) { 243 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 244 } 245 else if (typeof method === 'object' || ! method) { 246 return methods.init.apply(this, arguments); 247 } 248 else { 249 return $.error('Method ' + method + ' does not exist on jQuery.fn.superfish'); 250 } 251 }; 252 253 $.fn.superfish.defaults = { 254 popUpSelector: 'ul,.sf-mega', // within menu context 255 hoverClass: 'sfHover', 256 pathClass: 'overrideThisToUse', 257 pathLevels: 1, 258 delay: 800, 259 animation: {opacity: 'show'}, 260 animationOut: {opacity: 'hide'}, 261 speed: 'normal', 262 speedOut: 'fast', 263 cssArrows: true, 264 disableHI: false, 265 onInit: $.noop, 266 onBeforeShow: $.noop, 267 onShow: $.noop, 268 onBeforeHide: $.noop, 269 onHide: $.noop, 270 onIdle: $.noop, 271 onDestroy: $.noop, 272 onHandleTouch: $.noop 273 }; 274 275})(jQuery, window);
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.