PageSourceSearch

https://vipre.com/wp-content/plugins/megamenu/js/maxmegamenu.js?ver=3.3.1.2

js vipre.com collected 2026-09-24 09:12:09 UTC 33,714 bytes, 766 lines download raw bytes

1/*jslint browser: true, white: true, this: true, long: true */
2/*global console,jQuery,megamenu,window,navigator*/
3
4/*! Max Mega Menu jQuery Plugin */
5(function ( $ ) {
6    "use strict";
7
8    $.maxmegamenu = function(menu, options) {
9        var plugin = this;
10        var $menu = $(menu);
11        var $toggle_bar = $menu.siblings(".mega-menu-toggle");
12        var html_body_class_timeout;
13
14        var defaults = {
15            event: $menu.attr("data-event"),
16            effect: $menu.attr("data-effect"),
17            effect_speed: parseInt($menu.attr("data-effect-speed")),
18            effect_mobile: $menu.attr("data-effect-mobile"),
19            effect_speed_mobile: parseInt($menu.attr("data-effect-speed-mobile")),
20            panel_width: $menu.attr("data-panel-width"),
21            panel_inner_width: $menu.attr("data-panel-inner-width"),
22            mobile_force_width: $menu.attr("data-mobile-force-width"),
23            mobile_overlay: $menu.attr("data-mobile-overlay"),
24            mobile_state: $menu.attr("data-mobile-state"),
25            second_click: $menu.attr("data-second-click"),
26            vertical_behaviour: $menu.attr("data-vertical-behaviour"),
27            document_click: $menu.attr("data-document-click"),
28            breakpoint: $menu.attr("data-breakpoint"),
29            unbind_events: $menu.attr("data-unbind"),
30            hover_intent_timeout: $menu.attr("data-hover-intent-timeout"),
31            hover_intent_interval: $menu.attr("data-hover-intent-interval")
32        };
33
34        plugin.settings = {};
35
36        var items_with_submenus = $("li.mega-menu-megamenu.mega-menu-item-has-children," +
37                                    "li.mega-menu-flyout.mega-menu-item-has-children," +
38                                    "li.mega-menu-tabbed > ul.mega-sub-menu > li.mega-menu-item-has-children," +
39                                    "li.mega-menu-flyout li.mega-menu-item-has-children", menu);
40
41        var collapse_children_parents = $("li.mega-menu-megamenu li.mega-menu-item-has-children.mega-collapse-children > a.mega-menu-link", menu);
42
43        plugin.addAnimatingClass = function(element) {
44            if (plugin.settings.effect === "disabled") {
45                return;
46            }
47
48            $(".mega-animating").removeClass("mega-animating");
49
50            var timeout = plugin.settings.effect_speed + parseInt(megamenu.timeout, 10);
51
52            element.addClass("mega-animating");
53
54            setTimeout(function() {
55               element.removeClass("mega-animating");
56            }, timeout );
57        };
58
59        plugin.hideAllPanels = function() {
60            $(".mega-toggle-on > a.mega-menu-link", $menu).each(function() {
61                plugin.hidePanel($(this), false);
62            });
63        };
64
65        plugin.expandMobileSubMenus = function() {
66            $(".mega-menu-item-has-children.mega-expand-on-mobile > a.mega-menu-link", $menu).each(function() {
67                plugin.showPanel($(this));
68            });
69
70            if ( plugin.settings.mobile_state == 'expand_all' ) {
71                $(".mega-menu-item-has-children > a.mega-menu-link", $menu).each(function() {
72                    plugin.showPanel($(this));
73                });
74            }
75
76            if ( plugin.settings.mobile_state == 'expand_active' ) {
77                $("li.mega-current-menu-ancestor.mega-menu-item-has-children > a.mega-menu-link," + 
78                  "li.mega-current-menu-item.mega-menu-item-has-children > a.mega-menu-link" + 
79                  "li.mega-current-menu-parent.mega-menu-item-has-children > a.mega-menu-link" + 
80                  "li.mega-current_page_ancestor.mega-menu-item-has-children > a.mega-menu-link" + 
81                  "li.mega-current_page_item.mega-menu-item-has-children > a.mega-menu-link", $menu).each(function() {
82                    plugin.showPanel($(this));
83                });
84            }
85        }
86
87        plugin.hideSiblingPanels = function(anchor, immediate) {
88            anchor.parent().parent().find(".mega-toggle-on").children("a.mega-menu-link").each(function() { // all open children of open siblings
89                plugin.hidePanel($(this), immediate);
90            });
91        };
92
93        plugin.isDesktopView = function() {
94            var width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
95            return width > plugin.settings.breakpoint;
96        };
97
98        plugin.isMobileView = function() {
99            return !plugin.isDesktopView();
100        };
101
102        plugin.showPanel = function(anchor) {
103            if ( anchor.is("li.mega-menu-item") ) {
104                anchor = anchor.find("a.mega-menu-link").first();
105            }
106
107            anchor.parent().triggerHandler("before_open_panel");
108
109            anchor.parent().find("[aria-expanded]").first().attr("aria-expanded", "true");
110
111            $(".mega-animating").removeClass("mega-animating");
112
113            if (plugin.isMobileView() && anchor.parent().hasClass("mega-hide-sub-menu-on-mobile")) {
114                return;
115            }
116
117            if (plugin.isDesktopView() && ( $menu.hasClass("mega-menu-horizontal") || $menu.hasClass("mega-menu-vertical") ) && !anchor.parent().hasClass("mega-collapse-children")) {
118                plugin.hideSiblingPanels(anchor, true);
119            }
120
121            if ((plugin.isMobileView() && $menu.hasClass("mega-keyboard-navigation")) || plugin.settings.vertical_behaviour === "accordion") {
122                plugin.hideSiblingPanels(anchor, false);
123            }
124
125            plugin.calculateDynamicSubmenuWidths(anchor);
126
127            // apply jQuery transition (only if the effect is set to "slide", other transitions are CSS based)
128            if ( anchor.parent().hasClass("mega-collapse-children") || plugin.settings.effect === "slide" || 
129                ( plugin.isMobileView() && ( plugin.settings.effect_mobile === "slide" || plugin.settings.effect_mobile === "slide_left" || plugin.settings.effect_mobile === "slide_right" ) )
130               ) {
131                var speed = plugin.isMobileView() ? plugin.settings.effect_speed_mobile : plugin.settings.effect_speed;
132
133                anchor.siblings(".mega-sub-menu").css("display", "none").animate({"height":"show", "paddingTop":"show", "paddingBottom":"show", "minHeight":"show"}, speed, function() {
134                    $(this).css("display", "");
135                });
136            }
137
138            anchor.parent().addClass("mega-toggle-on").triggerHandler("open_panel");
139        };
140        
141        plugin.hidePanel = function(anchor, immediate) {
142            if ( anchor.is("li.mega-menu-item") ) {
143                anchor = anchor.find("a.mega-menu-link").first();
144            }
145
146            anchor.parent().triggerHandler("before_close_panel");
147
148            anchor.parent().find("[aria-expanded]").first().attr("aria-expanded", "false");
149
150            if ( anchor.parent().hasClass("mega-collapse-children") || ( ! immediate && plugin.settings.effect === "slide" ) || 
151                ( plugin.isMobileView() && ( plugin.settings.effect_mobile === "slide" || plugin.settings.effect_mobile === "slide_left" || plugin.settings.effect_mobile === "slide_right" ) )
152               ) {
153                var speed = plugin.isMobileView() ? plugin.settings.effect_speed_mobile : plugin.settings.effect_speed;
154
155                anchor.siblings(".mega-sub-menu").animate({"height":"hide", "paddingTop":"hide", "paddingBottom":"hide", "minHeight":"hide"}, speed, function() {
156                    anchor.siblings(".mega-sub-menu").css("display", "");
157                    anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
158                });
159
160                return;
161            }
162
163            if (immediate) {
164                anchor.siblings(".mega-sub-menu").css("display", "none").delay(plugin.settings.effect_speed).queue(function(){
165                    $(this).css("display", "").dequeue();
166                });
167            }
168
169            // pause video widget videos
170            anchor.siblings(".mega-sub-menu").find(".widget_media_video video").each(function() {
171                this.player.pause();
172            });
173
174            anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel");
175            plugin.addAnimatingClass(anchor.parent());
176        };
177
178        plugin.calculateDynamicSubmenuWidths = function(anchor) {
179            // apply dynamic width and sub menu position (only to top level mega menus)
180            if (anchor.parent().hasClass("mega-menu-megamenu") && anchor.parent().parent().hasClass("max-mega-menu") && plugin.settings.panel_width && $(plugin.settings.panel_width).length > 0) {
181                if (plugin.isDesktopView()) {
182                    var submenu_offset = $menu.offset();
183                    var target_offset = $(plugin.settings.panel_width).offset();
184
185                    anchor.siblings(".mega-sub-menu").css({
186                        width: $(plugin.settings.panel_width).outerWidth(),
187                        left: (target_offset.left - submenu_offset.left) + "px"
188                    });
189                } else {
190                    anchor.siblings(".mega-sub-menu").css({
191                        width: "",
192                        left: ""
193                    });
194                }
195            }
196
197            // apply inner width to sub menu by adding padding to the left and right of the mega menu
198            if (anchor.parent().hasClass("mega-menu-megamenu") && anchor.parent().parent().hasClass("max-mega-menu") && plugin.settings.panel_inner_width && $(plugin.settings.panel_inner_width).length > 0) {
199                var target_width = 0;
200
201                if ($(plugin.settings.panel_inner_width).length) {
202                    // jQuery selector
203                    target_width = parseInt($(plugin.settings.panel_inner_width).width(), 10);
204                } else {
205                    // we"re using a pixel width
206                    target_width = parseInt(plugin.settings.panel_inner_width, 10);
207                }
208
209                var submenu_width = parseInt(anchor.siblings(".mega-sub-menu").innerWidth(), 10);
210
211                if (plugin.isDesktopView() && target_width > 0 && target_width < submenu_width) {
212                    anchor.siblings(".mega-sub-menu").css({
213                        "paddingLeft": (submenu_width - target_width) / 2 + "px",
214                        "paddingRight": (submenu_width - target_width) / 2 + "px"
215                    });
216                } else {
217                    anchor.siblings(".mega-sub-menu").css({
218                        "paddingLeft": "",
219                        "paddingRight": ""
220                    });
221                }
222            }
223        };
224
225        plugin.bindClickEvents = function() {
226            var dragging = false;
227
228            $(document).on({
229                "touchmove": function(e) { dragging = true; },
230                "touchstart": function(e) { dragging = false; }
231            });
232
233            $(document).on("click touchend", function(e) { // hide menu when clicked away from
234                if (!dragging && plugin.settings.document_click === "collapse" && ! $(e.target).closest(".max-mega-menu li").length && ! $(e.target).closest(".mega-menu-toggle").length ) {
235                    plugin.hideAllPanels();
236                    plugin.hideMobileMenu();
237                }
238                dragging = false;
239            });
240
241            var clickable_parents = $("> a.mega-menu-link", items_with_submenus).add(collapse_children_parents);
242
243            clickable_parents.on("touchend.megamenu", function(e) {
244                if (plugin.settings.event === "hover_intent") {
245                    plugin.unbindHoverIntentEvents();
246                }
247
248                if (plugin.settings.event === "hover") {
249                    plugin.unbindHoverEvents();
250                }
251            });
252
253            clickable_parents.not("[data-has-click-event]").on("click.megamenu", function(e) {
254                if (plugin.isDesktopView() && $(this).parent().hasClass("mega-toggle-on") && $(this).closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
255                    if (plugin.settings.second_click === "go") {
256                        return;
257                    } else {
258                        e.preventDefault();
259                        return;
260                    }
261                }
262                if (dragging) {
263                    return;
264                }
265                if (plugin.isMobileView() && $(this).parent().hasClass("mega-hide-sub-menu-on-mobile")) {
266                    return; // allow all clicks on parent items when sub menu is hidden on mobile
267                }
268                if ((plugin.settings.second_click === "go" || $(this).parent().hasClass("mega-click-click-go")) && $(this).attr("href") !== undefined) { // check for second click
269                    if (!$(this).parent().hasClass("mega-toggle-on")) {
270                        e.preventDefault();
271                        plugin.showPanel($(this));
272                    }
273                } else {
274                    e.preventDefault();
275
276                    if ($(this).parent().hasClass("mega-toggle-on")) {
277                        plugin.hidePanel($(this), false);
278                    } else {
279                        plugin.showPanel($(this));
280                    }
281                }
282            });
283
284            collapse_children_parents.each(function() {
285                $(this).attr("data-has-click-event", "true");
286            });
287
288            if ( plugin.settings.second_click === "disabled" ) {
289                clickable_parents.off("click.megamenu");
290            }
291
292            $(".mega-close-after-click:not(.mega-menu-item-has-children) > a.mega-menu-link", menu).on("click", function() {
293                plugin.hideAllPanels();
294                plugin.hideMobileMenu();
295            });
296        };
297
298        plugin.bindHoverEvents = function() {
299            items_with_submenus.on({
300                "mouseenter.megamenu" : function() {
301                    plugin.unbindClickEvents();
302                    if (! $(this).hasClass("mega-toggle-on")) {
303                        plugin.showPanel($(this).children("a.mega-menu-link"));
304                    }
305                },
306                "mouseleave.megamenu" : function() {
307                    if ($(this).hasClass("mega-toggle-on") && ! $(this).hasClass("mega-disable-collapse") && ! $(this).parent().parent().hasClass("mega-menu-tabbed")) {
308                        plugin.hidePanel($(this).children("a.mega-menu-link"), false);
309                    }
310                }
311            });
312        };
313
314        plugin.bindHoverIntentEvents = function() {
315            items_with_submenus.hoverIntent({
316                over: function () {
317                    plugin.unbindClickEvents();
318                    if (! $(this).hasClass("mega-toggle-on")) {
319                        plugin.showPanel($(this).children("a.mega-menu-link"));
320                    }
321                },
322                out: function () {
323                    if ($(this).hasClass("mega-toggle-on") && ! $(this).hasClass("mega-disable-collapse") && ! $(this).parent().parent().hasClass("mega-menu-tabbed")) {
324                        plugin.hidePanel($(this).children("a.mega-menu-link"), false);
325                    }
326                },
327                timeout: plugin.settings.hover_intent_timeout,
328                interval: plugin.settings.hover_intent_interval
329            });
330        };
331
332        plugin.bindKeyboardEvents = function() {
333            var tab_key = 9;
334            var escape_key = 27;
335            var enter_key = 13;
336            var left_arrow_key = 37;
337            var up_arrow_key = 38;
338            var right_arrow_key = 39;
339            var down_arrow_key = 40;
340            var space_key = 32;
341
342            $menu.parent().on("keyup.megamenu", ".max-mega-menu, .mega-menu-toggle", function(e) {
343                var keyCode = e.keyCode || e.which;
344                var active_link = $(e.target);
345
346                if (keyCode === tab_key) {
347                    $menu.parent().addClass("mega-keyboard-navigation");
348                }
349            });
350
351            $menu.parent().on("keydown.megamenu", "a.mega-menu-link, .mega-indicator, .mega-menu-toggle-block, .mega-menu-toggle-animated-block button", function(e) {
352
353                if ( ! $menu.parent().hasClass("mega-keyboard-navigation") ) {
354                    return;
355                }
356
357                var keyCode = e.keyCode || e.which;
358                var active_link = $(e.target);
359
360                if ( keyCode === space_key && active_link.is(".mega-menu-link") ) {
361                    e.preventDefault();
362
363                    // pressing space on a parent item will always toggle the sub menu
364                    if ( active_link.parent().is(items_with_submenus) ) {
365                        if ( active_link.parent().hasClass("mega-toggle-on") && ! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
366                            plugin.hidePanel(active_link);
367                        } else {
368                            plugin.showPanel(active_link);
369                        }
370                    }
371                }
372
373                if ( keyCode === space_key && active_link.is("mega-indicator") ) {
374                    e.preventDefault();
375
376                    if ( active_link.parent().parent().hasClass("mega-toggle-on") && ! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
377                        plugin.hidePanel(active_link.parent());
378                    } else {
379                        plugin.showPanel(active_link.parent());
380                    }
381                }
382
383                if ( keyCode === escape_key ) {
384                    var submenu_open = $("> .mega-toggle-on", $menu).length !== 0;
385
386                    $("> .mega-toggle-on", $menu).find("[tabindex]:visible").first().focus();
387
388                    plugin.hideAllPanels();
389
390                    if ( plugin.isMobileView() && ! submenu_open ) {
391                        plugin.hideMobileMenu();
392                        $(".mega-menu-toggle-block, button.mega-toggle-animated", $toggle_bar).first().focus();
393                    }
394                }
395
396                if ( keyCode === space_key ) {
397                    e.preventDefault();
398
399                    if ( active_link.is(".mega-menu-toggle-block, .mega-menu-toggle-animated-block button") ) {
400                        if ( $toggle_bar.hasClass("mega-menu-open") ) {
401                            plugin.hideMobileMenu();
402                        } else {
403                            plugin.showMobileMenu();
404                        }
405                    }
406                }
407
408                if ( keyCode === enter_key ) {
409                    if ( active_link.is(".mega-menu-toggle-block") ) {
410                        if ( $toggle_bar.hasClass("mega-menu-open") ) {
411                            plugin.hideMobileMenu();
412                        } else {
413                            plugin.showMobileMenu();
414                        }
415                    }
416
417                    // pressing enter on an arrow will toggle the sub menu
418                    if ( active_link.is(".mega-indicator") ) {
419                        if ( active_link.closest("li.mega-menu-item").hasClass("mega-toggle-on") && ! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
420                            plugin.hidePanel(active_link.parent());
421                        } else {
422                            plugin.showPanel(active_link.parent());
423                        }
424
425                        return;
426                    }
427                    // pressing enter on a parent link
428                    if ( active_link.parent().is(items_with_submenus) ) {
429
430                        // when clicking on the parent of a hidden submenu, follow the link
431                        if ( plugin.isMobileView() && active_link.parent().is(".mega-hide-sub-menu-on-mobile") ) {
432                            return;
433                        }
434
435                        // when the arrow has been moved (i.e. it is clickable and visible, don't show the sub menu - just follow the link)
436                        if ( active_link.is("[href]") && active_link.siblings(".mega-indicator[tabindex]:visible").length !== 0 ) {
437                            return;
438                        }
439
440                        // pressing enter on a parent item without a link 
440will toggle the sub menu
441                        if ( active_link.is("[href]") === false ) {
442                            if ( active_link.parent().hasClass("mega-toggle-on") && ! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
443                                plugin.hidePanel(active_link);
444                            } else {
445                                plugin.showPanel(active_link);
446                            }
447
448                            return;
449                        }
450
451                        // pressing enter on a parent item will first open the sub menu, then follow the link
452                        if ( active_link.parent().hasClass("mega-toggle-on") && ! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") ) {
453                            return;
454                        } else {
455                            e.preventDefault();
456                            plugin.showPanel(active_link);
457                        }
458                    }
459                }
460
461                if ( ( ( keyCode === right_arrow_key && plugin.isDesktopView() ) || ( keyCode === down_arrow_key && plugin.isMobileView() ) ) && $menu.hasClass("mega-menu-horizontal") ) {
462                    e.preventDefault();
463
464                    var next_top_level_item = $("> .mega-toggle-on", $menu).nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
465
466                    if (next_top_level_item.length === 0) {
467                        next_top_level_item = $(":focus", $menu).parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
468                    }
469
470                    if (next_top_level_item.length === 0) {
471                        next_top_level_item = $(":focus", $menu).parent().parent().parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
472                    }
473
474                    plugin.hideAllPanels();
475                    next_top_level_item.focus();
476                }
477
478                if ( ( ( keyCode === left_arrow_key && plugin.isDesktopView() ) || ( keyCode === up_arrow_key && plugin.isMobileView() ) ) && $menu.hasClass("mega-menu-horizontal") ) {
479                    e.preventDefault();
480
481                    var prev_top_level_item = $("> .mega-toggle-on", $menu).prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
482
483                    if (prev_top_level_item.length === 0) {
484                        prev_top_level_item = $(":focus", $menu).parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
485                    }
486
487                    if (prev_top_level_item.length === 0) {
488                        prev_top_level_item = $(":focus", $menu).parent().parent().parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
489                    }
490
491                    plugin.hideAllPanels();
492                    prev_top_level_item.focus();
493                }
494            });
495
496            $menu.parent().on("focusout.megamenu", function(e) {
497                if ( $menu.parent().hasClass("mega-keyboard-navigation") ) {
498                    setTimeout(function() {
499                        var menu_has_focus = $menu.parent().find(":focus").length > 0;
500                        if (! menu_has_focus) {
501                            $menu.parent().removeClass("mega-keyboard-navigation");
502                            plugin.hideAllPanels();
503                            plugin.hideMobileMenu();
504                        }
505                    }, 10);
506                }
507            });
508        };
509
510        plugin.unbindAllEvents = function() {
511            $("ul.mega-sub-menu, li.mega-menu-item, li.mega-menu-row, li.mega-menu-column, a.mega-menu-link, .mega-indicator", menu).off();
512        };
513
514        plugin.unbindClickEvents = function() {
515            // collapsable parents always have a click event
516            $("> a.mega-menu-link", items_with_submenus).not(collapse_children_parents).off("click.megamenu touchend.megamenu");
517        };
518
519        plugin.unbindHoverEvents = function() {
520            items_with_submenus.off("mouseenter.megamenu mouseleave.megamenu");
521        };
522
523        plugin.unbindHoverIntentEvents = function() {
524            items_with_submenus.off("mouseenter mouseleave").removeProp("hoverIntent_t").removeProp("hoverIntent_s"); // hoverintent does not allow namespaced events
525        };
526
527        plugin.unbindKeyboardEvents = function() {
528            $menu.parent().off("keyup.megamenu keydown.megamenu focusout.megamenu");
529        };
530
531        plugin.unbindMegaMenuEvents = function() {
532            if (plugin.settings.event === "hover_intent") {
533                plugin.unbindHoverIntentEvents();
534            }
535
536            if (plugin.settings.event === "hover") {
537                plugin.unbindHoverEvents();
538            }
539
540            plugin.unbindClickEvents();
541            plugin.unbindKeyboardEvents();
542        };
543
544        plugin.bindMegaMenuEvents = function() {
545            plugin.unbindMegaMenuEvents();
546
547            if (plugin.isDesktopView() && plugin.settings.event === "hover_intent") {
548                plugin.bindHoverIntentEvents();
549            }
550
551            if (plugin.isDesktopView() && plugin.settings.event === "hover") {
552                plugin.bindHoverEvents();
553            }
554
555            plugin.bindClickEvents(); // always bind click events for touch screen devices
556            plugin.bindKeyboardEvents();
557        };
558
559        plugin.checkWidth = function() {
560            if ( plugin.isMobileView() && $menu.data("view") === "desktop" ) {
561                plugin.switchToMobile();
562            }
563
564            if ( plugin.isDesktopView() && $menu.data("view") === "mobile" ) {
565                plugin.switchToDesktop();
566            }
567
568            plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
569        };
570
571        plugin.reverseRightAlignedItems = function() {
572            if ( ! $("body").hasClass("rtl") && $menu.hasClass("mega-menu-horizontal") ) {
573                $menu.append($menu.children("li.mega-item-align-right").get().reverse());
574            }
575        };
576
577        plugin.addClearClassesToMobileItems = function() {
578            $(".mega-menu-row", $menu).each(function() {
579                $("> .mega-sub-menu > .mega-menu-column:not(.mega-hide-on-mobile)", $(this)).filter(":even").addClass("mega-menu-clear"); // :even is 0 based
580            });
581        };
582
583        plugin.initDesktop = function() {
584            $menu.data("view", "desktop");
585            plugin.bindMegaMenuEvents();
586            plugin.initIndicators();
587        };
588
589        plugin.switchToDesktop = function() {
590            $menu.data("view", "desktop");
591            plugin.bindMegaMenuEvents();
592            plugin.reverseRightAlignedItems();
593            plugin.hideAllPanels();
594            plugin.hideMobileMenu(true);
595        };
596
597        plugin.initMobile = function() {
598            plugin.switchToMobile();
599        };
600
601        plugin.switchToMobile = function() {
602            $menu.data("view", "mobile");
603            plugin.bindMegaMenuEvents();
604            plugin.initIndicators();
605            plugin.reverseRightAlignedItems();
606            plugin.addClearClassesToMobileItems();
607            plugin.hideAllPanels();
608            plugin.expandMobileSubMenus();
609        };
610
611        plugin.initToggleBar = function() {
612            $toggle_bar.on("click", function(e) {
613                if ( $(e.target).is(".mega-menu-toggle, .mega-menu-toggle-custom-block *, .mega-menu-toggle-block, .mega-menu-toggle-animated-block, .mega-menu-toggle-animated-block *, .mega-toggle-blocks-left, .mega-toggle-blocks-center, .mega-toggle-blocks-right, .mega-toggle-label, .mega-toggle-label span") ) {
614                    e.preventDefault();
615                    
616                    if ($(this).hasClass("mega-menu-open")) {
617                        plugin.hideMobileMenu();
618                    } else {
619                        plugin.showMobileMenu();
620                    }
621                }
622            });
623        };
624
625        plugin.initIndicators = function() {
626            $(".mega-indicator", $menu).not("[data-has-click-event]").on("click.megamenu", function(e) {
627                e.preventDefault();
628                e.stopPropagation();
629
630                if ( $(this).closest(".mega-menu-item").hasClass("mega-toggle-on") ) {
631                    if ( ! $(this).closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed") || plugin.isMobileView() ) {
632                        plugin.hidePanel($(this).parent(), false);
633                    }
634                } else {
635                    plugin.showPanel($(this).parent(), false);
636                }
637            });
638
639            $(".mega-indicator", $menu).each(function() {
640                $(this).attr('data-has-click-event', 'true');
641            });
642        }
643
644        plugin.hideMobileMenu = function(force) {
645            force = force || false;
646
647            if ( ! $toggle_bar.is(":visible") && ! force ) {
648                return;
649            }
650
651            html_body_class_timeout = setTimeout(function() {
652                $("body").removeClass($menu.attr("id") + "-mobile-open");
653                $("html").removeClass($menu.attr("id") + "-off-canvas-open");
654            }, plugin.settings.effect_speed_mobile);
655
656            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "false");
657
658            if (plugin.settings.effect_mobile === "slide" && ! force ) {
659                $menu.animate({"height":"hide"}, plugin.settings.effect_speed_mobile, function() {
660                    $menu.css({
661                        width: "",
662                        left: "",
663                        display: ""
664                    });
665
666                    $toggle_bar.removeClass("mega-menu-open");
667                });
668            } else {
669                $menu.css({
670                    width: "",
671                    left: "",
672                    display: ""
673                });
674                    
675                $toggle_bar.removeClass("mega-menu-open");
676            }
677
678            $menu.triggerHandler("mmm:hideMobileMenu");
679        };
680
681        plugin.showMobileMenu = function() {
682            if ( ! $toggle_bar.is(":visible")) {
683                return;
684            }
685
686            clearTimeout(html_body_class_timeout);
687
688            $("body").addClass($menu.attr("id") + "-mobile-open");
689
690            plugin.expandMobileSubMenus();
691
692            if ( plugin.settings.effect_mobile === "slide_left" || plugin.settings.effect_mobile === "slide_right" ) {
693                $("html").addClass($menu.attr("id") + "-off-canvas-open");
694            }
695
696            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "true");
697
698            if (plugin.settings.effect_mobile === "slide") {
699                $menu.animate({"height":"show"}, plugin.settings.effect_speed_mobile, function() {
700                    $(this).css("display", "");
701                });
702            }
703
704            $toggle_bar.addClass("mega-menu-open");
705
706            plugin.toggleBarForceWidth();
707
708            $menu.triggerHandler("mmm:showMobileMenu");
709        };
710
711        plugin.toggleBarForceWidth = function() {
712            if ($(plugin.settings.mobile_force_width).length && ( plugin.settings.effect_mobile === "slide" || plugin.settings.effect_mobile === "disabled" ) ) {
713                var submenu_offset = $toggle_bar.offset();
714                var target_offset = $(plugin.settings.mobile_force_width).offset();
715
716                $menu.css({
717                    width: $(plugin.settings.mobile_force_width).outerWidth(),
718                    left: (target_offset.left - submenu_offset.left) + "px"
719                });
720            }
721        };
722
723        plugin.init = function() {
724            $menu.triggerHandler("before_mega_menu_init");
725            plugin.settings = $.extend({}, defaults, options);
726            $menu.removeClass("mega-no-js");
727
728            plugin.initToggleBar();
729            
730            if (plugin.settings.unbind_events === "true") {
731                plugin.unbindAllEvents();
732            }
733
734            $(window).on("load", function() {
735                plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
736            });
737
738            if ( plugin.isDesktopView() ) {
739                plugin.initDesktop();
740            } else {
741                plugin.initMobile();
742            }
743
744            $(window).on("resize", function() {
745                plugin.checkWidth();
746            });
747
748            $menu.triggerHandler("after_mega_menu_init");
749        };
750
751        plugin.init();
752    };
753
754    $.fn.maxmegamenu = function(options) {
755        return this.each(function() {
756            if (undefined === $(this).data("maxmegamenu")) {
757                var plugin = new $.maxmegamenu(this, options);
758                $(this).data("maxmegamenu", plugin);
759            }
760        });
761    };
762
763    $(function() {
764        $(".max-mega-menu").maxmegamenu();
765    });
766}( 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.