PageSourceSearch

https://www.pkfoot.com/wp-content/themes/salient/js/third-party/superfish.js?ver=1.4.8

js pkfoot.com collected 2026-10-02 04:54:04 UTC 9,470 bytes, 333 lines download raw bytes

1/*
2 * jQuery Superfish Menu Plugin - v1.7.4
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	"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					// tap anywhere on iOS to unfocus a submenu
25					$('html').css('cursor', 'pointer').on('click', $.noop);
26				}
27				return ios;
28			})(),
29			wp7 = (function () {
30				var style = document.documentElement.style;
31				return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent));
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(o.popUpSelector).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(' + o.popUpSelector + ')';
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', o, touchHandler);
76			},
77			touchHandler = function (e) {
78				var $this = $(this),
79					$ul = $this.siblings(e.data.popUpSelector);
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
94				if($(this).parents('.megamenu').length > 0) return;
95					
96				clearTimeout(o.sfTimer);
97				$this.siblings().superfish('hide').end().superfish('show');
98			},
99			out = function () {
100				var $this = $(this),
101					o = getOptions($this);
102				if (ios) {
103					$.proxy(close, $this, o)();
104				}
105				else {
106					clearTimeout(o.sfTimer);
107					o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
108				}
109			},
110			close = function (o) {
111				o.retainPath = ($.inArray(this[0], o.$path) > -1);
112				this.superfish('hide');
113
114				if (!this.parents('.' + o.hoverClass).length) {
115					o.onIdle.call(getMenu(this));
116					if (o.$path.length) {
117						$.proxy(over, o.$path)();
118					}
119				}
120			},
121			getMenu = function ($el) {
122				return $el.closest('.' + c.menuClass);
123			},
124			getOptions = function ($el) {
125				return getMenu($el).data('sf-options');
126			};
127
128		return {
129			// public methods
130			hide: function (instant) {
131				if (this.length) {
132					var $this = this,
133						o = getOptions($this);
134					if (!o) {
135						return this;
136					}
137
138					if($(this).hasClass('menu-item-over') && $(this).hasClass('megamenu')) {
139						return true;
140					}
141
142					var not = (o.retainPath === true) ? o.$path : '',
143						$ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector),
144						speed = o.speedOut;
145
146					if (instant) {
147						$ul.show();
148						speed = 0;
149					}
150					o.retainPath = false;
151					o.onBeforeHide.call($ul);
152
153					if(o.dropdownStyle == 'minimal') {
154						var $this = $(this);
155						o.onHide.call($this);
156					} else {
157
158						$ul.stop(true, true).animate(o.animationOut, speed, function () {
159							var $this = $(this);
160							o.onHide.call($this);
161						});
162					}
163
164					if($(this).parents('.megamenu').length > 0) return;
165
166					//megamenu removes transparent option
167					if($('#header-outer[data-megamenu-rt="1"]').length > 0 && $('#header-outer[data-transparent-header="true"]').length > 0) {
168						
169						if($('#header-outer.scrolled-down').length == 0 && $('#header-outer.small-nav').length == 0 && $('#header-outer.detached').length == 0 && $('#header-outer.fixed-menu').length == 0) {
170							$('#header-outer').addClass('transparent');
171						}
172						if($('#header-outer[data-permanent-transparent="1"][data-transparent-header="true"]').length > 0) {
173							$('#header-outer').addClass('transparent');
174						}
175					
176					}
177				}
178				return this;
179			},
180			show: function () {
181
182				if($(this).parents('.megamenu').length > 0) return;
183
184				var o = getOptions(this);
185				if (!o) {
186					return this;
187				}
188				var $this = this.addClass(o.hoverClass),
189					$ul = $this.children(o.popUpSelector);
190
191
192				//megamenu removes transparent option
193				if($('#header-outer[data-megamenu-rt="1"]').length > 0 && $(this).hasClass('megamenu') && $('#header-outer').attr('data-transparent-header') == 'true' ) {
194					
195					$('#header-outer').addClass('no-transition');
196					$('#header-outer').removeClass('transparent');	
197				
198				}
199				
200				o.onBeforeShow.call($ul);
201
202
203				//make sure the ul has space 
204				if(!$($ul).parents('li').hasClass('megamenu') && !$($ul).parents('ul').hasClass('sub-menu') && $ul.offset()) {
205					
206					$ul.addClass('temp-hidden-display');
207					var docW = $("#top .container").width();
208					var elm = $ul;
209			        var off = elm.offset();
210			        var l = off.left - ($(window).width() - docW)/2;
211			        var w = elm.width();
212					var isEntirelyVisible = (l+w <= $(window).width()-100);
213
214			        if ( ! isEntirelyVisible ) {
215			            $ul.parents('li').addClass('edge');
216			        } else {
217			            $ul.parents('li').removeClass('edge');
218			        }
219					$ul.removeClass('temp-hidden-display');
220					
221				}
222				
223				if(o.dropdownStyle == 'minimal') {
224					o.onShow.call($ul);
225				} else {
226					$ul.stop(true, true).animate(o.animation, o.speed, function () {
227						o.onShow.call($ul);
228					});
229				}
230				
231				//show on left class
232				if( $ul.length > 0 && $ul.parents('.sub-menu').length > 0 && $ul.parents('.sf-menu').length > 0 ) {
233					if($ul.offset().left + $ul.outerWidth() > $(window).width()) {
234						$ul.addClass('on-left-side');
235						$ul.find('ul').addClass('on-left-side');
236					} 
237				}
238
239				
240				return this;
241			},
242			destroy: function () {
243				return this.each(function () {
244					var $this = $(this),
245						o = $this.data('sf-options'),
246						$hasPopUp;
247					if (!o) {
248						return false;
249					}
250					$hasPopUp = $this.find(o.popUpSelector).parent('li');
251					clearTimeout(o.sfTimer);
252					toggleMenuClasses($this, o);
253					toggleAnchorClass($hasPopUp);
254					toggleTouchAction($this);
255					// remove event handlers
256					$this.off('.superfish').off('.hoverIntent');
257					// clear animation's inline display style
258					$hasPopUp.children(o.popUpSelector).attr('style', function (i, style) {
259						return style.replace(/display[^;]+;?/g, '');
260					});
261					// reset 'current' path classes
262					o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass);
263					$this.find('.' + o.hoverClass).removeClass(o.hoverClass);
264					o.onDestroy.call($this);
265					$this.removeData('sf-options');
266				});
267			},
268			init: function (op) {
269				return this.each(function () {
270					var $this = $(this);
271					if ($this.data('sf-options')) {
272						return false;
273					}
274					var o = $.extend({}, $.fn.superfish.defaults, op),
275						$hasPopUp = $this.find(o.popUpSelector).parent('li');
276					o.$path = setPathToCurrent($this, o);
277
278					$this.data('sf-options', o);
279
280					toggleMenuClasses($this, o);
281					toggleAnchorClass($hasPopUp);
282					toggleTouchAction($this);
283					applyHandlers($this, o);
284
285					$hasPopUp.not('.' + c.bcClass).superfish('hide', true);
286
287					o.onInit.call(this);
288				});
289			}
290		};
291	})();
292
293	$.fn.superfish = function (method, args) {
294		if (methods[method]) {
295			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
296		}
297		else if (typeof method === 'object' || ! method) {
298			return methods.init.apply(this, arguments);
299		}
300		else {
301			return $.error('Method ' +  method + ' does not exist on jQuery.fn.superfish');
302		}
303	};
304
305	$.fn.superfish.defaults = {
306		popUpSelector: 'ul,.sf-mega', // within menu context
307		hoverClass: 'sfHover',
308		pathClass: 'overrideThisToUse',
309		pathLevels: 1,
310		delay: 800,
311		animation: {opacity: 'show'},
312		animationOut: {opacity: 'hide'},
313		speed: 'normal',
314		speedOut: 'fast',
315		cssArrows: true,
316		disableHI: false,
317		onInit: $.noop,
318		onBeforeShow: $.noop,
319		onShow: $.noop,
320		onBeforeHide: $.noop,
321		onHide: $.noop,
322		onIdle: $.noop,
323		onDestroy: $.noop,
324		dropdownStyle: ($('body[data-dropdown-style="minimal"]').length > 0) ? 'minimal' : 'classic'
325	};
326
327	// soon to be deprecated
328	$.fn.extend({
329		hideSuperfishUl: methods.hide,
330		showSuperfishUl: methods.show
331	});
332
333})(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.