PageSourceSearch

https://adventurediary.co/wp-content/plugins/megamenu/js/maxmegamenu.js?ver=2.8

js adventurediary.co collected 2026-10-04 21:17:51 UTC 28,364 bytes, 650 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            if ( plugin.isMobileView() ) {
419                var collapse_children_parents = $("li.mega-menu-megamenu li.mega-menu-item-has-children.mega-collapse-children > a.mega-menu-link"); // these are always activated on click
420                collapse_children_parents.off("click.megamenu touchend.megamenu");
421            }
422        };
423
424        plugin.unbindHoverEvents = function() {
425            items_with_submenus.unbind("mouseenter.megamenu mouseleave.megamenu");
426        };
427
428        plugin.unbindHoverIntentEvents = function() {
429            items_with_submenus.unbind("mouseenter mouseleave").removeProp("hoverIntent_t").removeProp("hoverIntent_s"); // hoverintent does not allow namespaced events
430        };
431
432        plugin.unbindKeyboardEvents = function() {
433            $menu.parent().off("keyup.megamenu keydown.megamenu focusout.megamenu");
434        };
435
436        plugin.unbindMegaMenuEvents = function() {
437            if (plugin.settings.event === "hover_intent") {
438                plugin.unbindHoverIntentEvents();
439            }
440
441            if (plugin.settings.event === "hover") {
442                plugin.unbindHoverEvents();
443            }
444
445            plugin.unbindClickEvents();
446            plugin.unbindKeyboardEvents();
447        };
448
449
450        plugin.bindMegaMenuEvents = function() {
451            if (plugin.isDesktopView() && plugin.settings.event === "hover_intent") {
452                bindHoverIntentEvents();
453            }
454
455            if (plugin.isDesktopView() && plugin.settings.event === "hover") {
456                bindHoverEvents();
457            }
458
459            bindClickEvents(); // always bind click events for touch screen devices
460            bindKeyboardEvents();
461        };
462
463        plugin.monitorView = function() {
464            if (plugin.isDesktopView()) {
465                $menu.data("view", "desktop");
466            } else {
467                $menu.data("view", "mobile");
468                plugin.switchToMobile();
469            }
470
471            plugin.checkWidth();
472
473            $(window).resize(function() {
474                plugin.checkWidth();
475            });
476        };
477
478        plugin.checkWidth = function() {
479            if ( plugin.isMobileView() && $menu.data("view") === "desktop" ) {
480                $menu.data("view", "mobile");
481                plugin.switchToMobile();
482            }
483
484            if ( plugin.isDesktopView() && $menu.data("view") === "mobile" ) {
485                $menu.data("view", "desktop");
486                plugin.switchToDesktop();
487            }
488
489            plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
490        };
491
492        plugin.reverseRightAlignedItems = function() {
493            if ( ! $("body").hasClass("rtl") ) {
494                $menu.append($menu.children("li.mega-item-align-right").get().reverse());
495            }
496        };
497
498        plugin.addClearClassesToMobileItems = function() {
499            $(".mega-menu-row", $menu).each(function() {
500                $("> .mega-sub-menu > .mega-menu-column:not(.mega-hide-on-mobile)", $(this)).filter(":even").addClass("mega-menu-clear"); // :even is 0 based
501            });
502        };
503
504        plugin.switchToMobile = function() {
505            plugin.unbindMegaMenuEvents();
506            plugin.bindMegaMenuEvents();
507            plugin.reverseRightAlignedItems();
508            plugin.addClearClassesToMobileItems();
509            plugin.hideAllPanels();
510        };
511
512        plugin.switchToDesktop = function() {
513            plugin.unbindMegaMenuEvents();
514            plugin.bindMegaMenuEvents();
515            plugin.reverseRightAlignedItems();
516            plugin.hideAllPanels();
517
518            $menu.css({
519                width: "",
520                left: "",
521                display: ""
522            });
523
524            $toggle_bar.removeClass("mega-menu-open");
525        };
526
527        plugin.initToggleBar = function() {
528            // mobile menu
529            $toggle_bar.on("click", function(e) {
530                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") ) {
531                    if ($(this).hasClass("mega-menu-open")) {
532                        plugin.hideMobileMenu();
533                    } else {
534                        plugin.showMobileMenu();
535                    }
536                }
537            });
538        };
539
540        plugin.hideMobileMenu = function() {
541            if ( ! $toggle_bar.is(":visible")) {
542                return;
543            }
544
545            html_body_class_timeout = setTimeout(function() {
546                $("body").removeClass($menu.attr("id") + "-mobile-open");
547                $("html").removeClass($menu.attr("id") + "-off-canvas-open");
548            }, plugin.settings.effect_speed_mobile);
549
550            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "false");
551
552            if (plugin.settings.effect_mobile === "slide") {
553                $menu.animate({"height":"hide"}, plugin.settings.effect_speed_mobile, function() {
554                    $menu.css({
555                        width: "",
556                        left: "",
557                        display: ""
558                    });
559                });
560            }
561
562            $toggle_bar.removeClass("mega-menu-open");
563        };
564
565        plugin.showMobileMenu = function() {
566            if ( ! $toggle_bar.is(":visible")) {
567                return;
568            }
569
570            clearTimeout(html_body_class_timeout);
571
572            $("body").addClass($menu.attr("id") + "-mobile-open");
573
574            if ( plugin.settings.effect_mobile === "slide_left" || plugin.settings.effect_mobile === "slide_right" ) {
575                $("html").addClass($menu.attr("id") + "-off-canvas-open");
576            }
577
578            $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "true");
579
580            plugin.toggleBarForceWidth();
581
582            if (plugin.settings.effect_mobile === "slide") {
583                $menu.animate({"height":"show"}, plugin.settings.effect_speed_mobile);
584            }
585
586            $toggle_bar.addClass("mega-menu-open");
587        };
588
589        plugin.toggleBarForceWidth = function() {
590
591            if ($(plugin.settings.mobile_force_width).length && ( plugin.settings.effect_mobile == 'slide' || plugin.settings.effect_mobile == 'disabled' ) ) {
592                var submenu_offset = $toggle_bar.offset();
593                var target_offset = $(plugin.settings.mobile_force_width).offset();
594
595                $menu.css({
596                    width: $(plugin.settings.mobile_force_width).outerWidth(),
597                    left: (target_offset.left - submenu_offset.left) + "px"
598                });
599            }
600        };
601
602        plugin.init = function() {
603            $menu.triggerHandler("before_mega_menu_init");
604            plugin.settings = $.extend({}, defaults, options);
605            $menu.removeClass("mega-no-js");
606
607            plugin.initToggleBar();
608            
609            if (plugin.settings.unbind_events === "true") {
610                plugin.unbindAllEvents();
611            }
612
613            $("span.mega-indicator", $menu).on("click.megamenu", function(e) {
614                e.preventDefault();
615                e.stopPropagation();
616
617                if ( $(this).parent().parent().hasClass("mega-toggle-on") ) {
618                    if ( ! $(this).parent().parent().parent().parent().hasClass("mega-menu-tabbed") || plugin.isMobileView() ) {
619                        plugin.hidePanel($(this).parent(), false);
620                    }
621                } else {
622                    plugin.showPanel($(this).parent(), false);
623                }
624            });
625
626            $(window).on("load", function() {
627                plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
628            });
629
630            plugin.bindMegaMenuEvents();
631            plugin.monitorView();
632            $menu.triggerHandler("after_mega_menu_init");
633        };
634
635        plugin.init();
636    };
637
638    $.fn.maxmegamenu = function(options) {
639        return this.each(function() {
640            if (undefined === $(this).data("maxmegamenu")) {
641                var plugin = new $.maxmegamenu(this, options);
642                $(this).data("maxmegamenu", plugin);
643            }
644        });
645    };
646
647    $(function() {
648        $(".max-mega-menu").maxmegamenu();
649    });
650}( 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.