PageSourceSearch

https://wardtires.com/wp-content/themes/tirecraft/js/jquery.slimmenu.js

js wardtires.com collected 2026-10-04 05:42:50 UTC 5,757 bytes, 149 lines download raw bytes

1/**
2 * jquery.slimmenu.js
3 * http://adnantopal.github.io/slimmenu/
4 * Author: @adnantopal
5 * Copyright 2013-2015, Adnan Topal (adnan.co)
6 * Licensed under the MIT license.
7 */
8(function ($, window, document, undefined) {
9    "use strict";
10
11    var pluginName = 'slimmenu',
12        oldWindowWidth = 0,
13        defaults = {
14            resizeWidth: '767',
15            initiallyVisible: false,
16            collapserTitle: 'Main Menu',
17            animSpeed: 'fast',
18            easingEffect: null,
19            indentChildren: false,
20            childrenIndenter: '  ',
21            expandIcon: '<i>&#9660;</i>',
22            collapseIcon: '<i>&#9650;</i>'
23        };
24
25    function Plugin(element, options) {
26        this.element = element;
27        this.$elem = $(this.element);
28        this.options = $.extend(defaults, options);
29        this.init();
30    }
31
32    Plugin.prototype = {
33
34        init: function () {
35            var $window = $(window),
36                options = this.options,
37                $menu = this.$elem,
38                $collapser = '<div class="menu-collapser">' + options.collapserTitle + '<div class="collapse-button"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></div></div>',
39                $menuCollapser;
40
41            $menu.before($collapser);
42            $menuCollapser = $menu.prev('.menu-collapser');
43
44            $menu.on('click', '.sub-toggle', function (e) {
45                e.preventDefault();
46                e.stopPropagation();
47
48                var $parentLi = $(this).closest('li');
49
50                if ($(this).hasClass('expanded')) {
51                    $(this).removeClass('expanded').html(options.expandIcon);
52                    $parentLi.find('>ul').slideUp(options.animSpeed, options.easingEffect);
53                } else {
54                    $(this).addClass('expanded').html(options.collapseIcon);
55                    $parentLi.find('>ul').slideDown(options.animSpeed, options.easingEffect);
56                }
57            });
58
59            $menuCollapser.on('click', '.collapse-button', function (e) {
60                e.preventDefault();
61                $menu.slideToggle(options.animSpeed, options.easingEffect);
62            });
63
64            this.resizeMenu();
65            $window.on('resize', this.resizeMenu.bind(this));
66            $window.trigger('resize');
67        },
68
69        resizeMenu: function () {
70            var self = this,
71                $window = $(window),
72                windowWidth = $window.width(),
73                $options = this.options,
74                $menu = $(this.element),
75                $menuCollapser = $('body').find('.menu-collapser');
76
77            if (window['innerWidth'] !== undefined) {
78                if (window['innerWidth'] > windowWidth) {
79                    windowWidth = window['innerWidth'];
80                }
81            }
82
83            if (windowWidth != oldWindowWidth) {
84                oldWindowWidth = windowWidth;
85
86                $menu.find('li').each(function () {
87                    if ($(this).has('ul').length) {
88                        if ($(this).addClass('has-submenu').has('.sub-toggle').length) {
89                            $(this).children('.sub-toggle').html($options.expandIcon);
90                        } else {
91                            $(this).addClass('has-submenu').append('<span class="sub-toggle">' + $options.expandIcon + '</span>');
92                        }
93                    }
94
95                    $(this).children('ul').hide().end().find('.sub-toggle').removeClass('expanded').html($options.expandIcon);
96                });
97
98                if ($options.resizeWidth >= windowWidth) {
99                    if ($options.indentChildren) {
100                        $menu.find('ul').each(function () {
101                            var $depth = $(this).parents('ul').length;
102                            if (!$(this).children('li').children('a').has('i').length) {
103                                $(this).children('li').children('a').prepend(self.indent($depth, $options));
104                            }
105                        });
106                    }
107
108                    $menu.addClass('collapsed').find('li').has('ul').off('mouseenter mouseleave');
109                    $menuCollapser.show();
110
111                    if (!$options.initiallyVisible) {
112                        $menu.hide();
113                    }
114                } else {
115                    $menu.find('li').has('ul')
116                        .on('mouseenter', function () {
117                            $(this).find('>
117ul').stop().slideDown($options.animSpeed, $options.easingEffect);
118                        })
119                        .on('mouseleave', function () {
120                            $(this).find('>ul').stop().slideUp($options.animSpeed, $options.easingEffect);
121                        });
122
123                    $menu.find('li > a > i').remove();
124                    $menu.removeClass('collapsed').show();
125                    $menuCollapser.hide();
126                }
127            }
128        },
129
130        indent: function (num, options) {
131            var i = 0,
132                $indent = '';
133            for (; i < num; i++) {
134                $indent += options.childrenIndenter;
135            }
136            return '<i>' + $indent + '</i> ';
137        }
138    };
139
140    $.fn[pluginName] = function (options) {
141        return this.each(function () {
142            if (!$.data(this, 'plugin_' + pluginName)) {
143                $.data(this, 'plugin_' + pluginName,
144                    new Plugin(this, options));
145            }
146        });
147    };
148
149}(jQuery, window, document));

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.