PageSourceSearch

https://www.afrisson.com/wp-content/plugins/megamenu/js/maxmegamenu.js?ver=2.9.1

js afrisson.com collected 2026-09-24 21:17:02 UTC 28,841 bytes, 663 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        var collapse_children_parents = $("li.mega-menu-megamenu li.mega-menu-item-has-children.mega-collapse-children > a.mega-menu-link", menu);
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        plugin.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 clickable_parents = $("> a.mega-menu-link", items_with_submenus).add(collapse_children_parents);
210
211            clickable_parents.on("touchend.megamenu", function(e) {
212                plugin.unbindHoverEvents();
213                plugin.unbindHoverIntentEvents();
214            });
215
216            clickable_parents.not("[data-has-click-event]").on("click.megamenu", function(e) {
217                if (plugin.isDesktopView() && $(this).parent().hasClass("mega-toggle-on") && $(this).parent().parent().parent().hasClass("mega-menu-tabbed") ) {
218                    if (plugin.settings.second_click === "go") {
219                        return;
220                    } else {
221                        e.preventDefault();
222                        return;
223                    }
224                }
225                if (dragging) {
226                    return;
227                }
228                if (plugin.isMobileView() && $(this).parent().hasClass("mega-hide-sub-menu-on-mobile")) {
229                    return; // allow all clicks on parent items when sub menu is hidden on mobile
230                }
231                if ((plugin.settings.second_click === "go" || $(this).parent().hasClass("mega-click-click-go")) && $(this).attr("href") !== undefined) { // check for second click
232                    if (!$(this).parent().hasClass("mega-toggle-on")) {
233                        e.preventDefault();
234                        plugin.showPanel($(this));
235                    }
236                } else {
237                    e.preventDefault();
238
239                    if ($(this).parent().hasClass("mega-toggle-on")) {
240                        plugin.hidePanel($(this), false);
241                    } else {
242                        plugin.showPanel($(this));
243                    }
244                }
245            });
246
247            collapse_children_parents.each(function() {
248                $(this).attr('data-has-click-event', 'true');
249            });
250        };
251
252        plugin.bindHoverEvents = function() {
253            items_with_submenus.on({
254                "mouseenter.megamenu" : function() {
255                    plugin.unbindClickEvents();
256                    if (! $(this).hasClass("mega-toggle-on")) {
257                        plugin.showPanel($(this).children("a.mega-menu-link"));
258                    }
259                },
260                "mouseleave.megamenu" : function() {
261                    if ($(this).hasClass("mega-toggle-on") && ! $(this).hasClass("mega-disable-collapse") && ! $(this).parent().parent().hasClass("mega-menu-tabbed")) {
262                        plugin.hidePanel($(this).children("a.mega-menu-link"), false);
263                    }
264                }
265            });
266        };
267
268        plugin.bindHoverIntentEvents = function() {
269            items_with_submenus.hoverIntent({
270                over: function () {
271                    plugin.unbindClickEvents();
272                    if (! $(this).hasClass("mega-toggle-on")) {
273                        plugin.showPanel($(this).children("a.mega-menu-link"));
274                    }
275                },
276                out: function () {
277                    if ($(this).hasClass("mega-toggle-on") && ! $(this).hasClass("mega-disable-collapse") && ! $(this).parent().parent().hasClass("mega-menu-tabbed")) {
278                        plugin.hidePanel($(this).children("a.mega-menu-link"), false);
279                    }
280                },
281                timeout: plugin.settings.hover_intent_timeout,
282                interval: plugin.settings.hover_intent_interval
283            });
284        };
285
286        plugin.bindKeyboardEvents = function() {
287            var tab_key = 9;
288            var escape_key = 27;
289            var enter_key = 13;
290            var left_arrow_key = 37;
291            var right_arrow_key = 39;
292            var space_key = 32;
293
294            $menu.parent().on("keyup.megamenu", function(e) {
295                var keyCode = e.keyCode || e.which;
296
297                if (keyCode === tab_key) {
298                    $menu.parent().addClass("mega-keyboard-navigation");
299                }
300            });
301
302            $menu.parent().on("keydown.megamenu", function(e) {
303                var keyCode = e.keyCode || e.which;
304                var active_link = $(e.target);
305
306                if ( keyCode === space_key && active_link.is(".mega-menu-link") && $menu.parent().hasClass("mega-keyboard-navigation") ) {
307                    e.preventDefault();
308
309                    // pressing space on a parent item will always toggle the sub menu
310                    if ( active_link.parent().is(items_with_submenus) ) {
311                        if ( active_link.parent().hasClass("mega-toggle-on") && ! active_link.parent().parent().parent().hasClass("mega-menu-tabbed") ) {
312                            plugin.hidePanel(active_link);
313                        } else {
314                            plugin.showPanel(active_link);
315                        }
316                    }
317                }
318            });
319
320            $menu.parent().on("keyup.megamenu", function(e) {
321                var keyCode = e.keyCode || e.which;
322                var active_link = $(e.target);
323                
324                if ( keyCode === tab_key && $menu.parent().hasClass("mega-keyboard-navigation") ) {
325                    if ( active_link.parent().is(items_with_submenus) && active_link.is("[href]") !== false ) {
326                        plugin.showPanel(active_link);
327                    } else {
328                        if ( ! active_link.parent().parent().parent().hasClass("mega-menu-tabbed") ) {
329                            plugin.hideSiblingPanels(active_link);
330                        }
331                    }
332                }
333
334                if ( keyCode === escape_key && $menu.parent().hasClass("mega-keyboard-navigation") ) {
335                    var submenu_open = $("> .mega-toggle-on", $menu).length !== 0;
336
337                    $("> .mega-toggle-on > a.mega-menu-link", $menu).focus();
338
339                    plugin.hideAllPanels();
340
341                    if ( plugin.isMobileView() && ! submenu_open ) {
342                        plugin.hideMobileMenu();
343                        $(".mega-menu-toggle-block, button.mega-toggle-animated", $toggle_bar).first().focus();
344                    }
345                }
346
347                if ( keyCode === enter_key && $menu.parent().hasClass("mega-keyboard-navigation") ) {
348                    if ( active_link.hasClass("mega-menu-toggle-block") ) {
349                        if ( $toggle_bar.hasClass("mega-menu-open") ) {
350                            plugin.hideMobileMenu();
351                        } else {
352                            plugin.showMobileMenu();
353                        }
354                    }
355
356                    // pressing enter on a parent item without a link 
356will toggle the sub menu
357                    if ( active_link.parent().is(items_with_submenus) && active_link.is("[href]") === false ) {
358                        if ( active_link.parent().hasClass("mega-toggle-on") && ! active_link.parent().parent().parent().hasClass("mega-menu-tabbed") ) {
359                            plugin.hidePanel(active_link);
360                        } else {
361                            plugin.showPanel(active_link);
362                        }
363                    }
364                }
365
366                if ( keyCode === right_arrow_key && plugin.isDesktopView() && $menu.parent().hasClass("mega-keyboard-navigation") && $menu.hasClass("mega-menu-horizontal") ) {
367                    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();
368
369                    if (next_top_level_item.length === 0) {
370                        next_top_level_item = $(":focus", $menu).parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").first();
371                    }
372
373                    next_top_level_item.focus();
374
375                    if ( next_top_level_item.parent().is(items_with_submenus) && next_top_level_item.is("[href]") !== false ) {
376                        plugin.showPanel(next_top_level_item);
377                    } else {
378                        plugin.hideSiblingPanels(next_top_level_item);
379                    }
380                }
381
382                if ( keyCode === left_arrow_key && plugin.isDesktopView() && $menu.parent().hasClass("mega-keyboard-navigation") && $menu.hasClass("mega-menu-horizontal") ) {
383                    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();
384
385                    if (prev_top_level_item.length === 0) {
386                        prev_top_level_item = $(":focus", $menu).parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").last();
387                    }
388
389                    prev_top_level_item.focus();
390
391                    if ( prev_top_level_item.parent().is(items_with_submenus) && prev_top_level_item.is("[href]") !== false  ) {
392                        plugin.showPanel(prev_top_level_item);
393                    } else {
394                        plugin.hideSiblingPanels(prev_top_level_item);
395                    }
396                }
397
398            });
399
400            $menu.parent().on("focusout.megamenu", function(e) {
401                if ( $menu.parent().hasClass("mega-keyboard-navigation") ) {
402                    setTimeout(function() {
403                        var menu_has_focus = $menu.parent().find(":focus").length > 0;
404                        if (! menu_has_focus) {
405                            $menu.parent().removeClass("mega-keyboard-navigation");
406                            plugin.hideAllPanels();
407                            plugin.hideMobileMenu();
408                        }
409                    }, 10);
410                }
411            });
412        };
413
414        plugin.unbindAllEvents = function() {
415            $("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();
416        };
417
418        plugin.unbindClickEvents = function() {
419            // collapsable parents always have a click event
420            $("> a.mega-menu-link", items_with_submenus).not(collapse_children_parents).off("click.megamenu touchend.megamenu");
421        };
422
423        plugin.unbindHoverEvents = function() {
424            items_with_submenus.unbind("mouseenter.megamenu mouseleave.megamenu");
425        };
426
427        plugin.unbindHoverIntentEvents = function() {
428            items_with_submenus.unbind("mouseenter mouseleave").removeProp("hoverIntent_t").removeProp("hoverIntent_s"); // hoverintent does not allow namespaced events
429        };
430
431        plugin.unbindKeyboardEvents = function() {
432            $menu.parent().off("keyup.megamenu keydown.megamenu focusout.megamenu");
433        };
434
435        plugin.unbindMegaMenuEvents = function() {
436            if (plugin.settings.event === "hover_intent") {
437                plugin.unbindHoverIntentEvents();
438            }
439
440            if (plugin.settings.event === "hover") {
441                plugin.unbindHoverEvents();
442            }
443
444            plugin.unbindClickEvents();
445            plugin.unbindKeyboardEvents();
446        };
447
448        plugin.bindMegaMenuEvents = function() {
449            plugin.unbindMegaMenuEvents();
450
451            if (plugin.isDesktopView() && plugin.settings.event === "hover_intent") {
452                plugin.bindHoverIntentEvents();
453            }
454
455            if (plugin.isDesktopView() && plugin.settings.event === "hover") {
456                plugin.bindHoverEvents();
457            }
458
459            plugin.bindClickEvents(); // always bind click events for touch screen devices
460            plugin.bindKeyboardEvents();
461        };
462
463        plugin.checkWidth = function() {
464            if ( plugin.isMobileView() && $menu.data("view") === "desktop" ) {
465                plugin.switchToMobile();
466            }
467
468            if ( plugin.isDesktopView() && $menu.data("view") === "mobile" ) {
469                plugin.switchToDesktop();
470            }
471
472            plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
473        };
474
475        plugin.reverseRightAlignedItems = function() {
476            if ( ! $("body").hasClass("rtl") ) {
477                $menu.append($menu.children("li.mega-item-align-right").get().reverse());
478            }
479        };
480
481        plugin.addClearClassesToMobileItems = function() {
482            $(".mega-menu-row", $menu).each(function() {
483                $("> .mega-sub-menu > .mega-menu-column:not(.mega-hide-on-mobile)", $(this)).filter(":even").addClass("mega-menu-clear"); // :even is 0 based
484            });
485        };
486
487        plugin.initDesktop = function() {
488            $menu.data("view", "desktop");
489            plugin.bindMegaMenuEvents();
490            plugin.initIndicators();
491        };
492
493        plugin.switchToDesktop = function() {
494            $menu.data("view", "desktop");
495            plugin.bindMegaMenuEvents();
496            plugin.reverseRightAlignedItems();
497            plugin.hideAllPanels();
498            plugin.hideMobileMenu(true);
499        };
500
501        plugin.initMobile = function() {
502            plugin.switchToMobile();
503        };
504
505        plugin.switchToMobile = function() {
506            $menu.data("view", "mobile");
507            plugin.bindMegaMenuEvents();
508            plugin.initIndicators();
509            plugin.reverseRightAlignedItems();
510            plugin.addClearClassesToMobileItems();
511            plugin.hideAllPanels();
512        };
513
514        plugin.initToggleBar = function() {
515            $toggle_bar.on("click", function(e) {
516                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") ) {
517                    e.preventDefault();
518                    
519                    if ($(this).hasClass("mega-menu-open")) {
520                        plugin.hideMobileMenu();
521                    } else {
522                        plugin.showMobileMenu();
523                    }
524                }
525            });
526        };
527
528        plugin.initIndicators = function() {
529            $("span.mega-indicator", $menu).not("[data-has-click-event]").on("click.megamenu", function(e) {
530                e.preventDefault();
531                e.stopPropagation();
532
533                if ( $(this).parent().parent().hasClass("mega-toggle-on") ) {
534                    if ( ! $(this).parent().parent().parent().parent().hasClass("mega-menu-tabbed") || plugin.isMobileView() ) {
535                        plugin.hidePanel($(this).parent(), false);
536                    }
537                } else {
538                    plugin.showPanel($(this).parent(), false);
539                }
540            });
541
542            $("span.mega-indicator", $menu).each(function() {
543                $(this).attr('data-has-click-event', 'true');
544            });
545        }
546
547        plugin.hideMobileMenu = function(force) {
548            force = force || false;
549
550            if ( ! $toggle_bar.is(":visible") && ! force ) {
551                return;
552            }
553
554            html_body_class_timeout = setTimeout(function() {
555                $("body").removeClass($menu.attr("id") + "-mobile-open");
556                $("html").removeClass($menu.attr("id") + "-off-canvas-open");
557            }, plugin.settings.effect_speed_mobile);
558
559            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "false");
560
561            if (plugin.settings.effect_mobile === "slide" && ! force ) {
562                $menu.animate({"height":"hide"}, plugin.settings.effect_speed_mobile, function() {
563                    $menu.css({
564                        width: "",
565                        left: "",
566                        display: ""
567                    });
568                });
569            }
570
571            $menu.css({
572                width: "",
573                left: "",
574                display: ""
575            });
576                
577            $toggle_bar.removeClass("mega-menu-open");
578
579            $menu.triggerHandler("mmm:hideMobileMenu");
580        };
581
582        plugin.showMobileMenu = function() {
583            if ( ! $toggle_bar.is(":visible")) {
584                return;
585            }
586
587            clearTimeout(html_body_class_timeout);
588
589            $("body").addClass($menu.attr("id") + "-mobile-open");
590
591            if ( plugin.settings.effect_mobile === "slide_left" || plugin.settings.effect_mobile === "slide_right" ) {
592                $("html").addClass($menu.attr("id") + "-off-canvas-open");
593            }
594
595            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "true");
596
597            plugin.toggleBarForceWidth();
598
599            if (plugin.settings.effect_mobile === "slide") {
600                $menu.animate({"height":"show"}, plugin.settings.effect_speed_mobile);
601            }
602
603            $toggle_bar.addClass("mega-menu-open");
604
605            $menu.triggerHandler("mmm:showMobileMenu");
606        };
607
608        plugin.toggleBarForceWidth = function() {
609            if ($(plugin.settings.mobile_force_width).length && ( plugin.settings.effect_mobile === "slide" || plugin.settings.effect_mobile === "disabled" ) ) {
610                var submenu_offset = $toggle_bar.offset();
611                var target_offset = $(plugin.settings.mobile_force_width).offset();
612
613                $menu.css({
614                    width: $(plugin.settings.mobile_force_width).outerWidth(),
615                    left: (target_offset.left - submenu_offset.left) + "px"
616                });
617            }
618        };
619
620        plugin.init = function() {
621            $menu.triggerHandler("before_mega_menu_init");
622            plugin.settings = $.extend({}, defaults, options);
623            $menu.removeClass("mega-no-js");
624
625            plugin.initToggleBar();
626            
627            if (plugin.settings.unbind_events === "true") {
628                plugin.unbindAllEvents();
629            }
630
631            $(window).on("load", function() {
632                plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
633            });
634
635            if ( plugin.isDesktopView() ) {
636                plugin.initDesktop();
637            } else {
638                plugin.initMobile();
639            }
640
641            $(window).resize(function() {
642                plugin.checkWidth();
643            });
644
645            $menu.triggerHandler("after_mega_menu_init");
646        };
647
648        plugin.init();
649    };
650
651    $.fn.maxmegamenu = function(options) {
652        return this.each(function() {
653            if (undefined === $(this).data("maxmegamenu")) {
654                var plugin = new $.maxmegamenu(this, options);
655                $(this).data("maxmegamenu", plugin);
656            }
657        });
658    };
659
660    $(function() {
661        $(".max-mega-menu").maxmegamenu();
662    });
663}( 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.