PageSourceSearch

https://www.chiesadimilano.it/wp-content/plugins/megamenu/js/maxmegamenu.js?ver=3.1.1

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