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