PageSourceSearch

https://www.nespapool.org/Portals/_default/skins/nespa/js/jquery.slimmenu.js?cdv=361

js nespapool.org collected 2026-09-28 08:41:26 UTC 5,837 bytes, 153 lines download raw bytes

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