PageSourceSearch

https://www.jetserver.net/wp-content/themes/jv-hosting/library/assets/js/maxmegamenu.js?ver=1.8.0

js jetserver.net collected 2026-10-05 09:46:52 UTC 6,672 bytes, 174 lines download raw bytes

1/*jslint browser: true, white: true */
2/*global console,jQuery,megamenu,window,navigator*/
3
4/**
5 * Max Mega Menu jQuery Plugin
6 */
7(function($) {
8
9    "use strict";
10
11    $.maxmegamenu = function(menu, options) {
12
13        var plugin = this;
14        var $menu = $(menu);
15
16        var defaults = {
17            event: $menu.attr('data-event'),
18            effect: $menu.attr('data-effect'),
19            panel_width: $menu.attr('data-panel-width'),
20            second_click: $menu.attr('data-second-click'),
21            breakpoint: $menu.attr('data-breakpoint')
22        };
23
24        plugin.settings = {};
25
26        var isTouchDevice = function() {
27            return ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
28        };
29
30        plugin.closePanels = function() {
31            $('.mega-toggle-on > a', $menu).each(function() {
32                plugin.hidePanel($(this), true);
33            });
34        };
35
36        plugin.hidePanel = function(anchor, immediate) {
37            if (immediate) {
38                anchor.siblings('.mega-sub-menu').removeClass('mega-toggle-on');
39                anchor.parent().removeClass('mega-toggle-on').triggerHandler("close_panel");
40            } else {
41                if ( megamenu.effect[plugin.settings.effect] ) {
42                    var effect = megamenu.effect[plugin.settings.effect]['out'];
43
44                    if (effect.css) {
45                        anchor.siblings('.mega-sub-menu').css(effect.css);
46                    }
47
48                    if (effect.animate) {
49                        anchor.siblings('.mega-sub-menu').animate(effect.animate, 'slow', function() {
50                            anchor.parent().removeClass('mega-toggle-on').triggerHandler("close_panel");
51                        });
52                    } else {
53                        anchor.parent().removeClass('mega-toggle-on').triggerHandler("close_panel");
54                    }
55                } else {
56                    anchor.parent().removeClass('mega-toggle-on').triggerHandler("close_panel");
57                }
58            }
59        };
60
61        plugin.showPanel = function(anchor) {
62            // automatically hide open panels, but only for desktop.
63            if ( $(window).width() > plugin.settings.breakpoint ) {
64                // all open children of open siblings
65                anchor.parent().siblings().find('.mega-toggle-on').andSelf().children('a').each(function() { 
66                    plugin.hidePanel($(this), true);
67                });
68            }
69
70            // apply dynamic width and sub menu position
71            if ( anchor.parent().hasClass('mega-menu-megamenu') && $(plugin.settings.panel_width).length ) {
72                var submenu_offset = $menu.offset();
73                var target_offset = $(plugin.settings.panel_width).offset();
74
75                anchor.siblings('.mega-sub-menu').css({
76                    width: $(plugin.settings.panel_width).outerWidth(),
77                    left: (target_offset.left - submenu_offset.left) + "px"
78                });
79            }
80
81            if ( megamenu.effect[plugin.settings.effect] ) {
82                var effect = megamenu.effect[plugin.settings.effect]['in'];
83
84                if (effect.css) {
85                    anchor.siblings('.mega-sub-menu').css(effect.css);
86                }
87
88                if (effect.animate) {
89                    anchor.siblings('.mega-sub-menu').animate(effect.animate, 'fast', 'swing', function() {
90                        $(this).css('visiblity', 'visible');
91                    });
92                }
93            }
94
95            anchor.parent().addClass('mega-toggle-on').triggerHandler("open_panel");
96        };
97
98        var openOnClick = function() {
99            // hide menu when clicked away from
100            $(document).on('click', function(event) {
101                if (!$(event.target).closest('.mega-menu li').length) {
102                    plugin.closePanels();
103                }
104            });
105
106            $('li.mega-menu-megamenu.mega-menu-item-has-children > a, li.mega-menu-flyout.mega-menu-item-has-children > a, li.mega-menu-flyout li.mega-menu-item-has-children > a', menu).on({
107                click: function(e) {
108                    // check for second click
109                    if ( plugin.settings.second_click == 'go' || $(this).parent().hasClass("mega-click-click-go") ) {
110                        if ( ! $(this).parent().hasClass("mega-toggle-on") ) {
111                            e.preventDefault();
112                            plugin.showPanel($(this));
113                        }
114                    } else {
115                        e.preventDefault();
116
117                        if ( $(this).parent().hasClass("mega-toggle-on") ) {
118                            plugin.hidePanel($(this), false);                            
119                        } else {
120                            plugin.showPanel($(this));
121                        }
122                    }
123                }
124            });
125        };
126
127        var openOnHover = function() {
128            $('li.mega-menu-megamenu.mega-menu-item-has-children, li.mega-menu-flyout.mega-menu-item-has-children, li.mega-menu-flyout li.mega-menu-item', menu).hoverIntent({
129                over: function () {
130                    plugin.showPanel($(this).children('a'));
131                },
132                out: function () {
133                    if ($(this).hasClass("mega-toggle-on")) {
134                        plugin.hidePanel($(this).children('a'), false);
135                    }
136                },
137                timeout: megamenu.timeout
138            });
139        };
140
141        plugin.init = function() {
142            plugin.settings = $.extend({}, defaults, options);
143
144            $menu.removeClass('mega-no-js');
145
146            $menu.siblings('.mega-menu-toggle').on('click', function() {
147                $(this).toggleClass('mega-menu-open');
148            });
149
150            if ( !isTouchDevice() && plugin.settings.event === 'click') {
151                openOnClick();
152            } else {
153                openOnHover();
154            }
155        };
156
157        plugin.init();
158
159    };
160
161    $.fn.maxmegamenu = function(options) {
162        return this.each(function() {
163            if (undefined === $(this).data('maxmegamenu')) {
164                var plugin = new $.maxmegamenu(this, options);
165                $(this).data('maxmegamenu', plugin);
166            }
167        });
168    };
169
170    $(function() {
171        $(".mega-menu").maxmegamenu();
172    });
173
174})(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.