1/* 2 * Superfish v1.7.0 - 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 touchstart = 'MSPointerDown.superfish'; 66 if (!ios) { 67 touchstart += ' touchstart.superfish'; 68 } 69 if (wp7) { 70 touchstart += ' mousedown.superfish'; 71 } 72 $menu 73 .on('focusin.superfish', 'li', over) 74 .on('focusout.superfish', 'li', out) 75 .on('click.superfish', 'a', o, clickHandler) 76 .on(touchstart, 'a', touchHandler); 77 }, 78 over = function() { 79 var $this = $(this), 80 o = getOptions($this); 81 clearTimeout(o.sfTimer); 82 $this.siblings().superfish('hide').end().superfish('show'); 83 }, 84 out = function(e) { 85 var $this = $(this), 86 o = getOptions($this); 87 if (ios) { 88 $.proxy(close, $this, o)(); 89 } 90 else { 91 clearTimeout(o.sfTimer); 92 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay); 93 } 94 }, 95 close = function(o) { 96 o.retainPath = ( $.inArray(this[0], o.$path) > -1); 97 this.superfish('hide'); 98 99 if (!this.parents('.' + o.hoverClass).length) { 100 o.onIdle.call(getMenu(this)); 101 if (o.$path.length) { 102 $.proxy(over, o.$path)(); 103 } 104 } 105 }, 106 clickHandler = function(e) { 107 var $a = $(this), 108 o = e.data, 109 $submenu = $a.siblings('ul'), 110 follow = ($a.data('follow') === false) ? false : true; 111 112 if ($submenu.length && !follow) { 113 e.preventDefault(); 114 if ($submenu.is(':hidden')) { 115 $.proxy(over, $a.parent('li'))(); 116 } 117 } 118 }, 119 getMenu = function($el) { 120 return $el.closest('.' + c.menuClass); 121 }, 122 getOptions = function($el) { 123 return getMenu($el).data('sf-options'); 124 }, 125 touchHandler = function(e) { 126 var $this = $(this), 127 $ul = $this.siblings('ul'); 128 129 if ($ul.length > 0 && $ul.is(':hidden')) { 130 $this.data('follow', false); 131 if (e.type === 'MSPointerDown') { 132 $this.trigger('focus'); 133 return false; 134 } 135 } 136 }; 137 138 return { 139 hide: function(instant) { 140 if (this.length) { 141 var $this = this, 142 o = getOptions($this), 143 not = (o.retainPath === true) ? o.$path : '', 144 $ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children('ul'), 145 speed = o.speedOut; 146 147 if (instant) { 148 $ul.show(); 149 speed = 0; 150 } 151 o.retainPath = false;
152 o.onBeforeHide.call($ul); 153 $ul.stop(true, true).animate(o.animationOut, speed, function() { 154 var $this = $(this); 155 o.onHide.call($this); 156 }); 157 } 158 return this; 159 }, 160 show: function() { 161 var o = getOptions(this), 162 $this = this.addClass(o.hoverClass), 163 $ul = $this.children('ul'); 164 165 o.onBeforeShow.call($ul); 166 $ul.stop(true, true).animate(o.animation, o.speed, function() { 167 o.onShow.call($ul); 168 $this.children('a').data('follow', true); 169 }); 170 return this; 171 }, 172 destroy: function() { 173 return this.each(function(){ 174 var $this = $(this), 175 o = getOptions($this), 176 $liHasUl = $this.find('li:has(ul)'); 177 clearTimeout(o.sfTimer); 178 toggleMenuClasses($this, o); 179 toggleAnchorClass($liHasUl); 180 toggleTouchAction($this); 181 // Remove event handlers 182 $this.off('.superfish').off('.hoverIntent'); 183 // Clear animation's inline display style 184 $liHasUl.children('ul').attr('style', function(i, style){ 185 return style.replace(/display[^;]+;?/g, ''); 186 }); 187 // Reset 'current' path classes 188 o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass); 189 $this.find('.' + o.hoverClass).removeClass(o.hoverClass); 190 $this.find('a').removeData('follow'); 191 $this.removeData('sf-options'); 192 }); 193 }, 194 init: function(op){ 195 return this.each(function() { 196 var $this = $(this); 197 if ($this.data('sf-options')) { 198 return false; 199 } 200 var o = $.extend({}, $.fn.superfish.defaults, op), 201 $liHasUl = $this.find('li:has(ul)'); 202 o.$path = setPathToCurrent($this, o); 203 204 $this.data('sf-options', o); 205 206 toggleMenuClasses($this, o); 207 toggleAnchorClass($liHasUl); 208 toggleTouchAction($this); 209 applyHandlers($this, o); 210 211 $liHasUl.not('.' + c.bcClass).superfish('hide',true); 212 213 o.onInit.call(this); 214 }); 215 } 216 }; 217 })(); 218 219 $.fn.superfish = function(method, args) { 220 if (methods[method]) { 221 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 222 } 223 else if (typeof method === 'object' || ! method) { 224 return methods.init.apply(this, arguments); 225 } 226 else { 227 $.error('Method ' + method + ' does not exist on jQuery.fn.superfish'); 228 } 229 }; 230 231 $.fn.superfish.defaults = { 232 hoverClass: 'sfHover', 233 pathClass: 'overrideThisToUse', 234 pathLevels: 1, 235 delay: 800, 236 animation: {opacity:'show'}, 237 animationOut: {opacity:'hide'}, 238 speed: 'normal', 239 speedOut: 'fast', 240 cssArrows: true, 241 disableHI: false, 242 onInit: $.noop, 243 onBeforeShow: $.noop, 244 onShow: $.noop, 245 onBeforeHide: $.noop, 246 onHide: $.noop, 247 onIdle: $.noop, 248 onDestroy: $.noop 249 }; 250 251 //soon to be deprecated 252 $.fn.extend({ 253 hideSuperfishUl: methods.hide, 254 showSuperfishUl: methods.show 255 }); 256 257})(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.