PageSourceSearch

https://www.ordemdemaltaportugal.org/wp-content/plugins/megamenu/js/maxmegamenu.js?ver=2.7.7

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