vendor: 7,616 bytes, lines 1-279
1/* 2 * jQuery Superfish Menu Plugin - v1.7.10 3 * Copyright (c) 2018 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; 11(function ($, w) { 12 "use strict"; 13 14 var methods = (function () { 15 // private properties and methods go here 16 var c = { 17 bcClass: 'sf-breadcrumb', 18 menuClass: 'sf-js-enabled', 19 anchorClass: 'sf-with-ul', 20 menuArrowClass: 'sf-arrows' 21 }, 22 ios = (function () { 23 var ios = /^(?![\w\W]*Windows Phone)[\w\W]*(iPhone|iPad|iPod)/i.test(navigator.userAgent); 24 if (ios) { 25 // tap anywhere on iOS to unfocus a submenu 26 $('html').css('cursor', 'pointer').on('click', $.noop); 27 } 28 return ios; 29 })(), 30 wp7 = (function () { 31 var style = document.documentElement.style; 32 return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent)); 33 })(), 34 unprefixedPointerEvents = (function () { 35 return (!!w.PointerEvent); 36 })(), 37 toggleMenuClasses = function ($menu, o, add) { 38 var classes = c.menuClass, 39 method; 40 if (o.cssArrows) { 41 classes += ' ' + c.menuArrowClass; 42 } 43 method = (add) ? 'addClass' : 'removeClass'; 44 $menu[method](classes); 45 }, 46 setPathToCurrent = function ($menu, o) { 47 return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels) 48 .addClass(o.hoverClass + ' ' + c.bcClass) 49 .filter(function () { 50 return ($(this).children(o.popUpSelector).hide().show().length); 51 }).removeClass(o.pathClass); 52 }, 53 toggleAnchorClass = function ($li, add) { 54 var method = (add) ? 'addClass' : 'removeClass'; 55 $li.children('a')[method](c.anchorClass); 56 }, 57 toggleTouchAction = function ($menu) { 58 var msTouchAction = $menu.css('ms-touch-action'); 59 var touchAction = $menu.css('touch-action'); 60 touchAction = touchAction || msTouchAction; 61 touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y'; 62 $menu.css({ 63 'ms-touch-action': touchAction, 64 'touch-action': touchAction 65 }); 66 }, 67 getMenu = function ($el) { 68 return $el.closest('.' + c.menuClass); 69 }, 70 getOptions = function ($el) { 71 return getMenu($el).data('sfOptions'); 72 }, 73 over = function () { 74 var $this = $(this), 75 o = getOptions($this); 76 clearTimeout(o.sfTimer); 77 $this.siblings().superfish('hide').end().superfish('show'); 78 }, 79 close = function (o) { 80 o.retainPath = ($.inArray(this[0], o.$path) > -1); 81 this.superfish('hide'); 82 83 if (!this.parents('.' + o.hoverClass).length) { 84 o.onIdle.call(getMenu(this)); 85 if (o.$path.length) { 86 $.proxy(over, o.$path)(); 87 } 88 } 89 }, 90 out = function () { 91 var $this = $(this), 92 o = getOptions($this); 93 if (ios) { 94 $.proxy(close, $this, o)(); 95 } else { 96 clearTimeout(o.sfTimer); 97 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay); 98 } 99 }, 100 touchHandler = function (e) { 101 var $this = $(this), 102 o = getOptions($this), 103 $ul = $this.siblings(e.data.popUpSelector); 104 105 if (o.onHandleTouch.call($ul) === false) { 106 return this; 107 } 108 109 if ($ul.length > 0 && $ul.is(':hidden')) { 110 $this.one('click.superfish', false); 111 if (e.type === 'MSPointerDown' || e.type === 'pointerdown') { 112 $this.trigger('focus'); 113 } else { 114 $.proxy(over, $this.parent('li'))(); 115 } 116 } 117 }, 118 applyHandlers = function ($menu, o) { 119 var targets = 'li:has(' + o.popUpSelector + ')'; 120 if ($.fn.hoverIntent && !o.disableHI) { 121 $menu.hoverIntent(over, out, targets); 122 } else { 123 $menu 124 .on('mouseenter.superfish', targets, over) 125 .on('mouseleave.superfish', targets, out); 126 } 127 var touchevent = 'MSPointerDown.superfish'; 128 if (unprefixedPointerEvents) { 129 touchevent = 'pointerdown.superfish'; 130 } 131 if (!ios) { 132 touchevent += ' touchend.superfish'; 133 } 134 if (wp7) { 135 touchevent += ' mousedown.superfish'; 136 } 137 $menu 138 .on('focusin.superfish', 'li', over) 139 .on('focusout.superfish', 'li', out) 140 .on(touchevent, 'a', o, touchHandler); 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('sfOptions'), 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 if (typeof style !== 'undefined') { 208 return style.replace(/display[^;]+;?/g, ''); 209 } 210 }); 211 // reset 'current' path classes 212 o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass); 213 $this.find('.' + o.hoverClass).removeClass(o.hoverClass); 214 o.onDestroy.call($this); 215 $this.removeData('sfOptions'); 216 }); 217 }, 218 init: function (op) { 219 return this.each(function () { 220 var $this = $(this); 221 if ($this.data('sfOptions')) { 222 return false; 223 } 224 var o = $.extend({}, $.fn.superfish.defaults, op), 225 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 226 o.$path = setPathToCurrent($this, o); 227 228 $this.data('sfOptions', o); 229 230 toggleMenuClasses($this, o, true); 231 toggleAnchorClass($hasPopUp, true); 232 toggleTouchAction($this); 233 applyHandlers($this, o); 234 235 $hasPopUp.not('.' + c.bcClass).superfish('hide', true); 236 237 o.onInit.call(this); 238 }); 239 } 240 }; 241 })(); 242 243 $.fn.superfish = function (method, args) { 244 if (methods[method]) { 245 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 246 } else if (typeof method === 'object' || !method) { 247 return methods.init.apply(this, arguments); 248 } else { 249 return $.error('Method ' + method + ' does not exist on jQuery.fn.superfish'); 250 } 251 }; 252 253 $.fn.superfish.defaults = { 254 popUpSelector: 'ul,.c-menu-type-mega', // within menu context 255 hoverClass: 'sfHover', 256 pathClass: 'overrideThisToUse', 257 pathLevels: 1, 258 delay: 800, 259 animation: { 260 opacity: 'show' 261 }, 262 animationOut: { 263 opacity: 'hide' 264 }, 265 speed: 'normal', 266 speedOut: 'fast', 267 cssArrows: true, 268 disableHI: false, 269 onInit: $.noop, 270 onBeforeShow: $.noop, 271 onShow: $.noop, 272 onBeforeHide: $.noop, 273 onHide: $.noop, 274 onIdle: $.noop, 275 onDestroy: $.noop, 276 onHandleTouch: $.noop 277 }; 278 279})(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.