1 2/* 3 * Superfish v1.6.9 - jQuery menu widget 4 * Copyright (c) 2013 Joel Birch 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 12;(function($) { 13 $.fn.superfish = function(op) { 14 15 var sf = $.fn.superfish, 16 c = sf.c, 17 $arrow = $('<span class="' + c.arrowClass + '"> »</span>'), 18 over = function() { 19 var $this = $(this), 20 o = getOptions($this); 21 22 clearTimeout(o.sfTimer); 23 $this.showSuperfishUl().siblings().hideSuperfishUl(); 24 }, 25 out = function(e) { 26 var $this = $(this), 27 o = getOptions($this); 28 29 if (e.type === 'click' || sf.ios) { 30 $.proxy(close, $this, o)(); 31 } 32 else { 33 clearTimeout(o.sfTimer); 34 o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay); 35 } 36 }, 37 close = function(o) { 38 o.retainPath = ( $.inArray(this[0], o.$path) > -1); 39 this.hideSuperfishUl(); 40 41 if (!this.parents('.' + o.hoverClass).length) { 42 o.onIdle.call(getMenu(this)); 43 if (o.$path.length) { 44 $.proxy(over, o.$path)(); 45 } 46 } 47 }, 48 getMenu = function($el) { 49 return $el.closest('.' + c.menuClass); 50 }, 51 getOptions = function($el) { 52 return getMenu($el).data('sf-options'); 53 }, 54 applyTouchAction = function($menu) { 55 // needed by MS pointer events 56 $menu.css('ms-touch-action', 'none'); 57 }, 58 applyHandlers = function($menu,o) { 59 var targets = 'li:has(ul)'; 60 61 if (!o.useClick) { 62 if ($.fn.hoverIntent && !o.disableHI) { 63 $menu.hoverIntent(over, out, targets); 64 } 65 else { 66 $menu 67 .on('mouseenter', targets, over) 68 .on('mouseleave', targets, out); 69 } 70 } 71 var touchstart = 'MSPointerDown'; 72 73 if (!sf.ios) { 74 touchstart += ' touchstart'; 75 } 76 if (sf.wp7) { 77 touchstart += ' mousedown'; 78 } 79 $menu 80 .on('focusin', 'li', over) 81 .on('focusout', 'li', out) 82 .on('click', 'a', o, clickHandler) 83 .on(touchstart, 'a', touchHandler); 84 }, 85 touchHandler = function(e) { 86 var $this = $(this), 87 $ul = $this.siblings('ul'); 88 89 if ($ul.length > 0 && $ul.is(':hidden')) { 90 $this.data('follow', false); 91 if (e.type === 'MSPointerDown') { 92 $this.trigger('focus'); 93 return false; 94 } 95 } 96 }, 97 clickHandler = function(e) { 98 var $a = $(this), 99 o = e.data, 100 $submenu = $a.siblings('ul'), 101 follow = ($a.data('follow') === false) ? false : true; 102 103 if ($submenu.length && (o.useClick || !follow)) { 104 e.preventDefault(); 105 if ($submenu.is(':hidden')) { 106 $.proxy(over, $a.parent('li'))(); 107 } 108 else if (o.useClick && follow) { 109 $.proxy(out, $a.parent('li'), e)(); 110 } 111 } 112 }, 113 setPathToCurrent = function($menu, o) { 114 return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels) 115 .addClass(o.hoverClass + ' ' + c.bcClass) 116 .filter(function() { 117 return ($(this).children('ul').hide().show().length); 118 }).removeClass(o.pathClass); 119 }, 120 addArrows = function($li, o) { 121 if (o.autoArrows) { 122 $li.children('a').each(function() { 123 addArrow( $(this) ); 124 }); 125 } 126 }, 127 addArrow = function($a) { 128 $a.addClass(c.anchorClass).append($arrow.clone()); 129 }; 130 131 sf.getOptions = getOptions; 132 133 return this.addClass(c.menuClass).each(function() { 134 var $this = $(this), 135 o = $.extend({}, sf.defaults, op), 136 $liHasUl = $this.find('li:has(ul)'); 137 138 o.$path = setPathToCurrent($this, o); 139 140 $this.data('sf-options', o); 141 142 addArrows($liHasUl, o); 143 applyTouchAction($this); 144 applyHandlers($this, o); 145 146 $liHasUl.not('.' + c.bcClass).hideSuperfishUl(true); 147 148 o.onInit.call(this); 149 }); 150 }; 151 152 var sf = $.fn.superfish; 153 sf.o = []; 154 sf.op = {}; 155 156 sf.c = { 157 bcClass: 'sf-breadcrumb', 158 menuClass: 'sf-js-enabled', 159 anchorClass: 'sf-with-ul', 160 arrowClass: 'sf-sub-indicator' 161 }; 162 sf.defaults = { 163 hoverClass: 'sfHover', 164 pathClass: 'overrideThisToUse', 165 pathLevels: 1, 166 delay: 800, 167 animation: {opacity:'show'}, 168 animationOut: {opacity:'hide'}, 169 speed: 'normal', 170 speedOut: 'fast', 171 autoArrows: true, 172 disableHI: false, // true disables hoverIntent detection 173 useClick: false, 174 onInit: $.noop, // callback functions 175 onBeforeShow: $.noop, 176 onShow: $.noop, 177 onBeforeHide: $.noop, 178 onHide: $.noop, 179 onIdle: $.noop 180 }; 181 sf.ios = /iPhone|iPad|iPod/i.test(navigator.userAgent); 182 sf.wp7 = (function() { 183 var style = document.documentElement.style; 184 return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent)); 185 })(); 186 $.fn.extend({ 187 hideSuperfishUl: function(instant) { 188 if (this.length) { 189 var $this = this, 190 o = sf.getOptions($this), 191 not = (o.retainPath === true) ? o.$path : '', 192 $ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children('ul'), 193 speed = o.speedOut; 194 195 if (instant) { 196 $ul.show(); 197 speed = 0; 198 } 199 o.retainPath = false; 200 o.onBeforeHide.call($ul); 201 $ul.stop(true, true).animate(o.animationOut, speed, function() { 202 var $this = $(this); 203 o.onHide.call($this); 204 if (o.useClick) { 205 $this.siblings('a').data('follow', false); 206 } 207 }); 208 } 209 return this; 210 }, 211 showSuperfishUl: function() { 212 var o = sf.getOptions(this), 213 $this = this.addClass(o.hoverClass), 214 $ul = $this.children('ul'); 215 216 o.onBeforeShow.call($ul); 217 $ul.stop(true, true).animate(o.animation, o.speed, function() { 218 o.onShow.call($ul); 219 $this.children('a').data('follow', true); 220 }); 221 return this; 222 } 223 }); 224 225 if (sf.ios) { 226 // iOS click won't bubble to body, attach to closest possible 227 $(window).load(function() { 228 $('body').children().on('click', $.noop); 229 }); 230 } 231 232})(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.