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