vendor: 2,869 bytes, lines 1-94
1/* 2 * jQuery Superfish Menu Plugin - v1.7.10 3 * Copyright (c) 2018 Joel Birch 4 * {WPHOOT modified} 5 * 6 * Dual licensed under the MIT and GPL licenses: 7 * http://www.opensource.org/licenses/mit-license.php 8 * http://www.gnu.org/licenses/gpl.html 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 clearTimeout(o.sfTimer); 94 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
vendor: 4,691 bytes, lines 94-274
94 95 }, 96 touchHandler = function (e) { 97 var $this = $(this), 98 o = getOptions($this), 99 $ul = $this.siblings(e.data.popUpSelector); 100 101 if (o.onHandleTouch.call($ul) === false) { 102 return this; 103 } 104 105 if ($ul.length > 0 && $ul.is(':hidden')) { 106 $this.one('click.superfish', false); 107 if (e.type === 'MSPointerDown' || e.type === 'pointerdown') { 108 $this.trigger('focus'); 109 } else { 110 $.proxy(over, $this.parent('li'))(); 111 } 112 } 113 }, 114 applyHandlers = function ($menu, o) { 115 var targets = 'li:has(' + o.popUpSelector + ')'; 116 if ($.fn.hoverIntent && !o.disableHI) { 117 $menu.hoverIntent(over, out, targets); 118 } 119 else { 120 $menu 121 .on('mouseenter.superfish', targets, over) 122 .on('mouseleave.superfish', targets, out); 123 } 124 var touchevent = 'MSPointerDown.superfish'; 125 if (unprefixedPointerEvents) { 126 touchevent = 'pointerdown.superfish'; 127 } 128 if (!ios) { 129 touchevent += ' touchend.superfish'; 130 } 131 if (wp7) { 132 touchevent += ' mousedown.superfish'; 133 } 134 $menu 135 .on('focusin.superfish', 'li', over) 136 .on('focusout.superfish', 'li', out) 137 .on(touchevent, 'a', o, touchHandler); 138 }; 139 140 return { 141 // public methods 142 hide: function (instant) { 143 if (this.length) { 144 var $this = this, 145 o = getOptions($this); 146 if (!o) { 147 return this; 148 } 149 var not = (o.retainPath === true) ? o.$path : '', 150 $ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector), 151 speed = o.speedOut; 152 153 if (instant) { 154 $ul.show(); 155 speed = 0; 156 } 157 o.retainPath = false; 158 159 if (o.onBeforeHide.call($ul) === false) { 160 return this; 161 } 162 163 $ul.stop(true, true).animate(o.animationOut, speed, function () { 164 var $this = $(this); 165 o.onHide.call($this); 166 }); 167 } 168 return this; 169 }, 170 show: function () { 171 var o = getOptions(this); 172 if (!o) { 173 return this; 174 } 175 var $this = this.addClass(o.hoverClass), 176 $ul = $this.children(o.popUpSelector); 177 178 if (o.onBeforeShow.call($ul) === false) { 179 return this; 180 } 181 182 $ul.stop(true, true).animate(o.animation, o.speed, function () { 183 o.onShow.call($ul); 184 }); 185 return this; 186 }, 187 destroy: function () { 188 return this.each(function () { 189 var $this = $(this), 190 o = $this.data('sfOptions'), 191 $hasPopUp; 192 if (!o) { 193 return false; 194 } 195 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 196 clearTimeout(o.sfTimer); 197 toggleMenuClasses($this, o); 198 toggleAnchorClass($hasPopUp); 199 toggleTouchAction($this); 200 // remove event handlers 201 $this.off('.superfish').off('.hoverIntent'); 202 // clear animation's inline display style 203 $hasPopUp.children(o.popUpSelector).attr('style', function (i, style) { 204 if (typeof style !== 'undefined') { 205 return style.replace(/display[^;]+;?/g, ''); 206 } 207 }); 208 // reset 'current' path classes 209 o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass); 210 $this.find('.' + o.hoverClass).removeClass(o.hoverClass); 211 o.onDestroy.call($this); 212 $this.removeData('sfOptions'); 213 }); 214 }, 215 init: function (op) { 216 return this.each(function () { 217 var $this = $(this); 218 if ($this.data('sfOptions')) { 219 return false; 220 } 221 var o = $.extend({}, $.fn.superfish.defaults, op), 222 $hasPopUp = $this.find(o.popUpSelector).parent('li'); 223 o.$path = setPathToCurrent($this, o); 224 225 $this.data('sfOptions', o); 226 227 toggleMenuClasses($this, o, true); 228 toggleAnchorClass($hasPopUp, true); 229 toggleTouchAction($this); 230 applyHandlers($this, o); 231 232 $hasPopUp.not('.' + c.bcClass).superfish('hide', true); 233 234 o.onInit.call(this); 235 }); 236 } 237 }; 238 })(); 239 240 $.fn.superfish = function (method, args) { 241 if (methods[method]) { 242 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 243 } 244 else if (typeof method === 'object' || ! method) { 245 return methods.init.apply(this, arguments); 246 } 247 else { 248 return $.error('Method ' + method + ' does not exist on jQuery.fn.superfish'); 249 } 250 }; 251 252 $.fn.superfish.defaults = { 253 popUpSelector: 'ul,.sf-mega', // within menu context 254 hoverClass: 'sfHover', 255 pathClass: 'overrideThisToUse', 256 pathLevels: 1, 257 delay: 800, 258 animation: {opacity: 'show'}, 259 animationOut: {opacity: 'hide'}, 260 speed: 'normal', 261 speedOut: 'fast', 262 cssArrows: true, 263 disableHI: false, 264 onInit: $.noop, 265 onBeforeShow: $.noop, 266 onShow: $.noop, 267 onBeforeHide: $.noop, 268 onHide: $.noop, 269 onIdle: $.noop, 270 onDestroy: $.noop, 271 onHandleTouch: $.noop 272 }; 273 274})(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.