PageSourceSearch

https://versusevil.com/wp-content/themes/salient/js/superfish.js?ver=1.4.8

js versusevil.com collected 2026-09-25 09:44:05 UTC 9,155 bytes, 329 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					// iOS clicks only bubble as far as body children
25					$(window).load(function () {
26						$('body').children().on('click', $.noop);
27					});
28				}
29				return ios;
30			})(),
31			wp7 = (function () {
32				var style = document.documentElement.style;
33				return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent));
34			})(),
35			toggleMenuClasses = function ($menu, o) {
36				var classes = c.menuClass;
37				if (o.cssArrows) {
38					classes += ' ' + c.menuArrowClass;
39				}
40				$menu.toggleClass(classes);
41			},
42			setPathToCurrent = function ($menu, o) {
43				return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels)
44					.addClass(o.hoverClass + ' ' + c.bcClass)
45						.filter(function () {
46							return ($(this).children(o.popUpSelector).hide().show().length);
47						}).removeClass(o.pathClass);
48			},
49			toggleAnchorClass = function ($li) {
50				$li.children('a').toggleClass(c.anchorClass);
51			},
52			toggleTouchAction = function ($menu) {
53				var touchAction = $menu.css('ms-touch-action');
54				touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y';
55				$menu.css('ms-touch-action', touchAction);
56			},
57			applyHandlers = function ($menu, o) {
58				var targets = 'li:has(' + o.popUpSelector + ')';
59				if ($.fn.hoverIntent && !o.disableHI) {
60					$menu.hoverIntent(over, out, targets);
61				}
62				else {
63					$menu
64						.on('mouseenter.superfish', targets, over)
65						.on('mouseleave.superfish', targets, out);
66				}
67				var touchevent = 'MSPointerDown.superfish';
68				if (!ios) {
69					touchevent += ' touchend.superfish';
70				}
71				if (wp7) {
72					touchevent += ' mousedown.superfish';
73				}
74				$menu
75					.on('focusin.superfish', 'li', over)
76					.on('focusout.superfish', 'li', out)
77					.on(touchevent, 'a', o, touchHandler);
78			},
79			touchHandler = function (e) {
80				var $this = $(this),
81					$ul = $this.siblings(e.data.popUpSelector);
82
83				if ($ul.length > 0 && $ul.is(':hidden')) {
84					$this.one('click.superfish', false);
85					if (e.type === 'MSPointerDown') {
86						$this.trigger('focus');
87					} else {
88						$.proxy(over, $this.parent('li'))();
89					}
90				}
91			},
92			over = function () {
93				var $this = $(this),
94					o = getOptions($this);
95
96				if($(this).parents('.megamenu').length > 0) return;
97					
98				clearTimeout(o.sfTimer);
99				$this.siblings().superfish('hide').end().superfish('show');
100			},
101			out = function () {
102				var $this = $(this),
103					o = getOptions($this);
104				if (ios) {
105					$.proxy(close, $this, o)();
106				}
107				else {
108					clearTimeout(o.sfTimer);
109					o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
110				}
111			},
112			close = function (o) {
113				o.retainPath = ($.inArray(this[0], o.$path) > -1);
114				this.superfish('hide');
115
116				if (!this.parents('.' + o.hoverClass).length) {
117					o.onIdle.call(getMenu(this));
118					if (o.$path.length) {
119						$.proxy(over, o.$path)();
120					}
121				}
122			},
123			getMenu = function ($el) {
124				return $el.closest('.' + c.menuClass);
125			},
126			getOptions = function ($el) {
127				return getMenu($el).data('sf-options');
128			};
129
130		return {
131			// public methods
132			hide: function (instant) {
133				if (this.length) {
134					var $this = this,
135						o = getOptions($this);
136					if (!o) {
137						return this;
138					}
139
140					var not = (o.retainPath === true) ? o.$path : '',
141						$ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector),
142						speed = o.speedOut;
143
144					if (instant) {
145						$ul.show();
146						speed = 0;
147					}
148					o.retainPath = false;
149					o.onBeforeHide.call($ul);
150
151					if(o.dropdownStyle == 'minimal') {
152						var $this = $(this);
153						o.onHide.call($this);
154					} else {
155
156						$ul.stop(true, true).animate(o.animationOut, speed, function () {
157							var $this = $(this);
158							o.onHide.call($this);
159						});
160					}
161
162					if($(this).parents('.megamenu').length > 0) return;
163
164					//megamenu removes transparent option
165					if($('#header-outer[data-megamenu-rt="1"]').length > 0 && $('#header-outer[data-transparent-header="true"]').length > 0) {
166						
167						if($('#header-outer.scrolled-down').length == 0 && $('#header-outer.small-nav').length == 0 && $('#header-outer.detached').length == 0) {
168							$('#header-outer').addClass('transparent');
169						}
170					
171					}
172				}
173				return this;
174			},
175			show: function () {
176
177				if($(this).parents('.megamenu').length > 0) return;
178
179				var o = getOptions(this);
180				if (!o) {
181					return this;
182				}
183				var $this = this.addClass(o.hoverClass),
184					$ul = $this.children(o.popUpSelector);
185
186
187				//megamenu removes transparent option
188				if($('#header-outer[data-megamenu-rt="1"]').length > 0 && $(this).hasClass('megamenu')) {
189					
190					$('#header-outer').addClass('no-transition');
191					$('#header-outer').removeClass('transparent');	
192				
193				}
194				
195				o.onBeforeShow.call($ul);
196
197
198				//make sure the ul has space 
199				if(!$($ul).parents('li').hasClass('megamenu') && !$($ul).parents('ul').hasClass('sub-menu') && $ul.offset()) {
200					
201					$ul.addClass('temp-hidden-display');
202					var docW = $("#top .container").width();
203					var elm = $ul;
204			        var off = elm.offset();
205			        var l = off.left - ($(window).width() - docW)/2;
206			        var w = elm.width();
207					var isEntirelyVisible = (l+w <= $(window).width()-100);
208
209			        if ( ! isEntirelyVisible ) {
210			            $ul.parents('li').addClass('edge');
211			        } else {
212			            $ul.parents('li').removeClass('edge');
213			        }
214					$ul.removeClass('temp-hidden-display');
215					
216				}
217				
218				if(o.dropdownStyle == 'minimal') {
219					o.onShow.call($ul);
220				} else {
221					$ul.stop(true, true).animate(o.animation, o.speed, function () {
222						o.onShow.call($ul);
223					});
224				}
225				
226				//show on left class
227				if($ul.length > 0 && $ul.parents('.sub-menu').length > 0 && $ul.parent().parent().parent().parent().hasClass('sf-menu')) {
228					
229					if($ul.offset().left + $ul.outerWidth() > $(window).width()) {
230						$ul.addClass('on-left-side');
231						$ul.find('ul').addClass('on-left-side');
232					} 
233				}
234
235				
236				return this;
237			},
238			destroy: function () {
239				return this.each(function () {
240					var $this = $(this),
241						o = $this.data('sf-options'),
242						$hasPopUp;
243					if (!o) {
244						return false;
245					}
246					$hasPopUp = $this.find(o.popUpSelector).parent('li');
247					clearTimeout(o.sfTimer);
248					toggleMenuClasses($this, o);
249					toggleAnchorClass($hasPopUp);
250					toggleTouchAction($this);
251					// remove event handlers
252					$this.off('.superfish').off('.hoverIntent');
253					// clear animation's inline display style
254					$hasPopUp.children(o.popUpSelector).attr('style', function (i, style) {
255						return style.replace(/display[^;]+;?/g, '');
256					});
257					// reset 'current' path classes
258					o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass);
259					$this.find('.' + o.hoverClass).removeClass(o.hoverClass);
260					o.onDestroy.call($this);
261					$this.removeData('sf-options');
262				});
263			},
264			init: function (op) {
265				return this.each(function () {
266					var $this = $(this);
267					if ($this.data('sf-options')) {
268						return false;
269					}
270					var o = $.extend({}, $.fn.superfish.defaults, op),
271						$hasPopUp = $this.find(o.popUpSelector).parent('li');
272					o.$path = setPathToCurrent($this, o);
273
274					$this.data('sf-options', o);
275
276					toggleMenuClasses($this, o);
277					toggleAnchorClass($hasPopUp);
278					toggleTouchAction($this);
279					applyHandlers($this, o);
280
281					$hasPopUp.not('.' + c.bcClass).superfish('hide', true);
282
283					o.onInit.call(this);
284				});
285			}
286		};
287	})();
288
289	$.fn.superfish = function (method, args) {
290		if (methods[method]) {
291			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
292		}
293		else if (typeof method === 'object' || ! method) {
294			return methods.init.apply(this, arguments);
295		}
296		else {
297			return $.error('Method ' +  method + ' does not exist on jQuery.fn.superfish');
298		}
299	};
300
301	$.fn.superfish.defaults = {
302		popUpSelector: 'ul,.sf-mega', // within menu context
303		hoverClass: 'sfHover',
304		pathClass: 'overrideThisToUse',
305		pathLevels: 1,
306		delay: 800,
307		animation: {opacity: 'show'},
308		animationOut: {opacity: 'hide'},
309		speed: 'normal',
310		speedOut: 'fast',
311		cssArrows: true,
312		disableHI: false,
313		onInit: $.noop,
314		onBeforeShow: $.noop,
315		onShow: $.noop,
316		onBeforeHide: $.noop,
317		onHide: $.noop,
318		onIdle: $.noop,
319		onDestroy: $.noop,
320		dropdownStyle: ($('body[data-dropdown-style="minimal"]').length > 0) ? 'minimal' : 'classic'
321	};
322
323	// soon to be deprecated
324	$.fn.extend({
325		hideSuperfishUl: methods.hide,
326		showSuperfishUl: methods.show
327	});
328
329})(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.