PageSourceSearch

https://www.boxpartners.com/js/superfish.js

js boxpartners.com collected 2026-10-06 15:22:58 UTC 9,396 bytes, 275 lines download raw bytes

vendor: 9,396 bytes, lines 1-275
1/*
2 * jQuery Superfish Menu Plugin
3 * Copyright (c) 2013 Joel Birch
4 * Version 1.7.6
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 ($, w) {
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			        $(w).on("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			unprefixedPointerEvents = (function () {
36			    return (!!w.PointerEvent);
37			})(),
38			toggleMenuClasses = function ($menu, o) {
39			    var classes = c.menuClass;
40			    if (o.cssArrows) {
41			        classes += ' ' + c.menuArrowClass;
42			    }
43			    $menu.toggleClass(classes);
44			},
45			setPathToCurrent = function ($menu, o) {
46			    return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels)
47					.addClass(o.hoverClass + ' ' + c.bcClass)
48						.filter(function () {
49						    return ($(this).children(o.popUpSelector).hide().show().length);
50						}).removeClass(o.pathClass);
51			},
52			toggleAnchorClass = function ($li) {
53			    $li.children('a').toggleClass(c.anchorClass);
54			},
55			toggleTouchAction = function ($menu) {
56			    var msTouchAction = $menu.css('ms-touch-action');
57			    var touchAction = $menu.css('touch-action');
58			    touchAction = touchAction || msTouchAction;
59			    touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y';
60			    $menu.css({
61			        'ms-touch-action': touchAction,
62			        'touch-action': touchAction
63			    });
64			},
65			applyHandlers = function ($menu, o) {
66			    var targets = 'li:has(' + o.popUpSelector + ')';
67			    if ($.fn.hoverIntent && !o.disableHI) {
68			        $menu.hoverIntent(over, out, targets);
69			    }
70			    else {
71			        $menu
72						.on('mouseenter.superfish', targets, over)
73						.on('mouseleave.superfish', targets, out);
74			    }
75			    var touchevent = 'MSPointerDown.superfish';
76			    if (unprefixedPointerEvents) {
77			        touchevent = 'pointerdown.superfish';
78			    }
79			    if (!ios) {
80			        touchevent += ' touchend.superfish';
81			    }
82			    if (wp7) {
83			        touchevent += ' mousedown.superfish';
84			    }
85			    $menu
86					.on('focusin.superfish', 'li', over)
87					.on('focusout.superfish', 'li', out)
88					.on(touchevent, 'a', o, touchHandler);
89			},
90			touchHandler = function (e) {
91			    var $this = $(this),
92					o = getOptions($this),
93					$ul = $this.siblings(e.data.popUpSelector);
94
95			    if (o.onHandleTouch.call($ul) === false) {
96			        return this;
97			    }
98
99			    if ($ul.length > 0 && $ul.is(':hidden')) {
100			        $this.one('click.superfish', false);
101			        if (e.type === 'MSPointerDown' || e.type === 'pointerdown') {
102			            $this.trigger('focus');
103			        } else {
104			            $.proxy(over, $this.parent('li'))();
105			        }
106			    }
107			},
108			over = function () {
109			    var $this = $(this),
110					o = getOptions($this);
111			    clearTimeout(o.sfTimer);
112			    $this.siblings().superfish('hide').end().superfish('show');
113			},
114			out = function () {
115			    var $this = $(this),
116					o = getOptions($this);
117			    if (ios) {
118			        $.proxy(close, $this, o)();
119			    }
120			    else {
121			        clearTimeout(o.sfTimer);
122			        o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
123			    }
124			},
125			close = function (o) {
126			    o.retainPath = ($.inArray(this[0], o.$path) > -1);
127			    this.superfish('hide');
128
129			    if (!this.parents('.' + o.hoverClass).length) {
130			        o.onIdle.call(getMenu(this));
131			        if (o.$path.length) {
132			            $.proxy(over, o.$path)();
133			        }
134			    }
135			},
136			getMenu = function ($el) {
137			    return $el.closest('.' + c.menuClass);
138			},
139			getOptions = function ($el) {
140			    return getMenu($el).data('sf-options');
141			};
142
143        return {
144            // public methods
145            hide: function (instant) {
146                if (this.length) {
147                    var $this = this,
148						o = getOptions($this);
149                    if (!o) {
150                        return this;
151                    }
152                    var not = (o.retainPath === true) ? o.$path : '',
153						$ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector),
154						speed = o.speedOut;
155
156                    if (instant) {
157                        $ul.show();
158                        speed = 0;
159                    }
160                    o.retainPath = false;
161
162                    if (o.onBeforeHide.call($ul) === false) {
163                        return this;
164                    }
165
166                    $ul.stop(true, true).animate(o.animationOut, speed, function () {
167                        var $this = $(this);
168                        o.onHide.call($this);
169                    });
170                }
171                return this;
172            },
173            show: function () {
174                var o = getOptions(this);
175                if (!o) {
176                    return this;
177                }
178                var $this = this.addClass(o.hoverClass),
179					$ul = $this.children(o.popUpSelector);
180
181                if (o.onBeforeShow.call($ul) === false) {
182                    return this;
183                }
184
185                $ul.stop(true, true).animate(o.animation, o.speed, function () {
186                    o.onShow.call($ul);
187                });
188                return this;
189            },
190            destroy: function () {
191                return this.each(function () {
192                    var $this = $(this),
193						o = $this.data('sf-options'),
194						$hasPopUp;
195                    if (!o) {
196                        return false;
197                    }
198                    $hasPopUp = $this.find(o.popUpSelector).parent('li');
199                    clearTimeout(o.sfTimer);
200                    toggleMenuClasses($this, o);
201                    toggleAnchorClass($hasPopUp);
202                    toggleTouchAction($this);
203                    // remove event handlers
204                    $this.off('.superfish').off('.hoverIntent');
205                    // clear animation's inline display style
206                    $hasPopUp.children(o.popUpSelector).attr('style', function (i, style) {
207                        return style.replace(/display[^;]+;?/g, '');
208                    });
209                    // reset 'current' path classes
210                    o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass);
211                    $this.find('.' + o.hoverClass).removeClass(o.hoverClass);
212                    o.onDestroy.call($this);
213                    $this.removeData('sf-options');
214                });
215            },
216            init: function (op) {
217                return this.each(function () {
218                    var $this = $(this);
219                    if ($this.data('sf-options')) {
220                        return false;
221                    }
222                    var o = $.extend({}, $.fn.superfish.defaults, op),
223						$hasPopUp = $this.find(o.popUpSelector).parent('li');
224                    o.$path = setPathToCurrent($this, o);
225
226                    $this.data('sf-options', o);
227
228                    toggleMenuClasses($this, o);
229                    toggleAnchorClass($hasPopUp);
230                    toggleTouchAction($this);
231                    applyHandlers($this, o);
232
233                    $hasPopUp.not('.' + c.bcClass).superfish('hide', true);
234
235                    o.onInit.call(this);
236                });
237            }
238        };
239    })();
240
241    $.fn.superfish = function (method, args) {
242        if (methods[method]) {
243            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
244        }
245        else if (typeof method === 'object' || !method) {
246            return methods.init.apply(this, arguments);
247        }
248        else {
249            return $.error('Method ' + method + ' does not exist on jQuery.fn.superfish');
250        }
251    };
252
253    $.fn.superfish.defaults = {
254        popUpSelector: 'ul,.sf-mega', // within menu context
255        hoverClass: 'sfHover',
256        pathClass: 'overrideThisToUse',
257        pathLevels: 1,
258        delay: 800,
259        animation: { opacity: 'show' },
260        animationOut: { opacity: 'hide' },
261        speed: 'normal',
262        speedOut: 'fast',
263        cssArrows: true,
264        disableHI: false,
265        onInit: $.noop,
266        onBeforeShow: $.noop,
267        onShow: $.noop,
268        onBeforeHide: $.noop,
269        onHide: $.noop,
270        onIdle: $.noop,
271        onDestroy: $.noop,
272        onHandleTouch: $.noop
273    };
274
275})(jQuery, window);

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.