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