PageSourceSearch

https://www.peraton.com/wp-content/plugins/megamenu-pro/assets/public.js?ver=2.2.3

js peraton.com collected 2026-09-24 18:15:55 UTC 24,201 bytes, 668 lines download raw bytes

1/*jslint browser: true, white: true */
2/*global console,jQuery,megamenu,window,navigator*/
3
4/**
5 * EDD Ajax Cart
6 */
7(function($) {
8    "use strict";
9
10    $(function() {
11        $('body').on('edd_cart_item_added', function(event, data) {
12            $('.mega-menu-edd-cart-total').html(data.total);
13            $('.mega-menu-edd-cart-count').html(data.cart_quantity);
14        });
15    });
16
17    $(".max-mega-menu").on("after_mega_menu_init", function() {
18        $('li.mega-menu-megamenu').on('open_panel', function() {
19            // reset default
20            var placeholder = $(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder");
21            var default_src = placeholder.attr('data-default-src');
22            placeholder.attr('src', default_src);
23
24            // preload
25            $('.mega-sub-menu [data-image-swap-url]', $(this) ).not(['data-preloaded']).each( function() {
26                $('<img/>')[0].src = $(this).attr('data-image-swap-url');
27                $(this).attr('data-preloaded', 'true');
28            });
29        });
30
31        $('.mega-sub-menu [data-image-swap-url]').hoverIntent({
32            over: function () {
33                var placeholder = $(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder");
34                var new_src = $(this).attr('data-image-swap-url');
35                placeholder.attr('src', new_src);
36            },
37            out: function() {}
38        });
39    });
40
41})(jQuery);
42
43/**
44 * Searchbox jQuery plugin
45 */
46(function($) {
47    "use strict";
48
49    $.maxmegamenu_searchbox = function(form, options) {
50
51        var plugin = this;
52        var form = $(form);
53        var $menu = form.parents('.max-mega-menu');
54        var $wrap = $menu.parent();
55        var breakpoint = $menu.attr('data-breakpoint');
56        var input = $('input[type=text]', form);
57        var icon = $('.search-icon', form);
58
59        plugin.isDesktopView = function() {
60            return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars
61        };
62
63        plugin.monitorView = function() {
64            if (typeof $menu.data("view") === 'undefined') {
65                if (plugin.isDesktopView()) {
66                    $menu.data("view", "desktop");
67                } else {
68                    $menu.data("view", "mobile");
69                }
70            }
71
72            plugin.checkWidth();
73
74            $(window).resize(function() {
75                plugin.checkWidth();
76            });
77        };
78
79        plugin.checkWidth = function() {
80            var expanding_search = $("li.mega-menu-item .mega-search.expand-to-left input[type=text], li.mega-menu-item .mega-search.expand-to-right input[type=text]", $menu);
81
82            if ( $menu.data("view") === "mobile" ) {
83                var placeholder = expanding_search.attr('data-placeholder');
84                expanding_search.attr('placeholder', placeholder);
85            }
86
87            if ( $menu.data("view") === "desktop" ) {
88                expanding_search.attr('placeholder', '');
89            }
90        };
91
92        plugin.close_search = function() {
93            input.val("");
94            input.attr('placeholder', '');
95            form.removeClass('mega-search-open');
96            form.addClass('mega-search-closed');
97        }
98
99        plugin.open_search = function() {
100            input.attr('placeholder', input.attr('data-placeholder'));
101            form.removeClass('mega-search-closed');
102            form.addClass('mega-search-open');
103        }
104
105        plugin.detect_background_click = function() {
106            var dragging = false;
107
108            $(document).on({
109                "touchmove": function(e) { dragging = true; },
110                "touchstart": function(e) { dragging = false; }
111            });
112
113            $(document).on("click touchend", function(e) { // hide menu when clicked away from
114                if ( form.parent().hasClass('mega-static') ) {
115                    return;
116                }
117                if ( ! dragging && ! $(e.target).closest(".max-mega-menu li").length && ! $(e.target).closest(".mega-menu-toggle").length ) {
118                    plugin.close_search();
119                }
120                dragging = false;
121            });
122        }
123
124        plugin.init_replacements_search = function() {
125
126            input.val("");
127
128            if ( $menu.data("view") === "mobile" ) {
129                $(".search-icon", $menu).on('click', function(e) {
130                    $(this).parents(".mega-search").submit();
131                });
132            }
133
134            if ( $menu.data("view") === "desktop" ) {
135                input.on('focus', function(e) {
136                    if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $wrap.hasClass('mega-keyboard-navigation') ) {
137                        plugin.open_search();
138                    }
139                });
140
141                input.on('blur', function(e) {
142                    if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $wrap.hasClass('mega-keyboard-navigation') ) {
143                        plugin.close_search();
144                    }
145                });
146
147                icon.on('click', function(e) {
148                    if (form.parent().hasClass('mega-static') ) {
149                        form.submit();
150                        return;
151                    }
152                    
153                    if (form.hasClass('mega-search-closed')) {
154                        plugin.open_search();
155                        input.focus();
156                    } else if ( input.val() == '' ) {
157                        plugin.close_search();
158                    } else {
159                        form.submit();
160                    }
161                });
162            }
163        };
164
165        plugin.monitorView();
166        plugin.init_replacements_search();
167        plugin.detect_background_click();
168    };
169
170    $.fn.maxmegamenu_searchbox = function(options) {
171        return this.each(function() {
172            if (undefined === $(this).data('maxmegamenu_searchbox')) {
173                var plugin = new $.maxmegamenu_searchbox(this, options);
174                $(this).data('maxmegamenu_searchbox', plugin);
175            }
176        });
177    };
178
179    $(function() {
180        $(".max-mega-menu .mega-search").maxmegamenu_searchbox();
181    });
182})(jQuery);
183
184
185/**
186 * Searchbox jQuery plugin
187 */
188(function($) {
189    "use strict";
190
191    $.maxmegamenu_toggle_searchbox = function(form, options) {
192
193        var plugin = this;
194        var form = $(form);
195        var $wrap = form.parents('.mega-menu-wrap');
196        var input = $("input[type=text]", form);
197        var icon = $(".search-icon", form);
198        
199        plugin.open_search = function() {
200            input.attr('placeholder', input.attr('data-placeholder'));
201            form.removeClass('mega-search-closed');
202            form.addClass('mega-search-open');
203        }
204
205        plugin.close_search = function() {
206            input.attr('placeholder', '');
207            form.removeClass('mega-search-open');
208            form.addClass('mega-search-closed');
209        }
210
211        plugin.init_toggle_search = function() {
212
213            input.val("");
214
215            input.on('focus', function(e) {
216                if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $wrap.hasClass('mega-keyboard-navigation') ) {
217                    plugin.open_search();
218                }
219            });
220
221            input.on('blur', function(e) {
222                if ( ! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $wrap.hasClass('mega-keyboard-navigation') ) {
223                    plugin.close_search();
224                }
225            });
226
227            icon.on('click', function(e) {
228                if (form.hasClass('static') ) {
229                    form.submit();
230                } else if (form.hasClass('mega-search-closed')) {
231                    input.focus();
232                    plugin.open_search();
233                } else if ( input.val() == '' ) {
234                    plugin.close_search();
235                } else {
236                    form.submit();
237                }
238            });
239
240        };
241
242        plugin.init_toggle_search();
243
244    };
245
246    $.fn.maxmegamenu_toggle_searchbox = function(options) {
247        return this.each(function() {
248            if (undefined === $(this).data('maxmegamenu_toggle_searchbox')) {
249                var plugin = new $.maxmegamenu_toggle_searchbox(this, options);
250                $(this).data('maxmegamenu_toggle_searchbox', plugin);
251            }
252        });
253    };
254
255    $(function() {
256        $(".mega-menu-toggle .mega-search").maxmegamenu_toggle_searchbox();
257    });
258})(jQuery);
259
260/**
261 * Sticky jQuery Plugin
262 */
263(function($) {
264
265    "use strict";
266
267    $.maxmegamenu_sticky = function(menu, options) {
268        var plugin = this;
269        var $menu = $(menu);
270        var $wrap = $menu.parent();
271        var breakpoint = $menu.attr('data-breakpoint');
272        var sticky_on_mobile = $menu.attr('data-sticky-mobile');
273        var sticky_on_desktop = $menu.attr('data-sticky-desktop');
274        var sticky_expand = $menu.attr('data-sticky-expand');
275        var sticky_expand_mobile = $menu.attr('data-sticky-expand-mobile');
276        var sticky_offset = isNaN(parseInt($menu.attr('data-sticky-offset'))) ? 0 : parseInt($menu.attr('data-sticky-offset'));
277        var sticky_hide_until_scroll_up = $menu.attr('data-sticky-hide');
278        var sticky_hide_until_scroll_up_tolerance = isNaN(parseInt($menu.attr('data-sticky-hide-tolerance'))) ? 0 : parseInt($menu.attr('data-sticky-hide-tolerance'));
279        var sticky_hide_until_scroll_up_offset = isNaN(parseInt($menu.attr('data-sticky-hide-offset'))) ? 0 : parseInt($menu.attr('data-sticky-hide-offset'));
280        var sticky_transition = $menu.attr('data-sticky-transition');
281        var sticky_menu_offset_top;
282        var sticky_menu_offset_left;
283        var sticky_menu_width;
284        var sticky_menu_width_round_up;
285        var sticky_menu_height;
286        var is_stuck = false;
287        var admin_bar_height = 0;
288        var last_scroll_top = 0;
289        var saved_scroll_top = 0;
290        var is_vertical = $menu.hasClass('mega-menu-vertical') || $menu.hasClass('mega-menu-accordion');
291
292        plugin.isDesktopView = function() {
293            return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars
294        };
295
296        var sticky_hide_until_scroll_up_enabled = function() {
297            return $menu.hasClass('mega-menu-horizontal') && sticky_hide_until_scroll_up == "true";
298        }
299
300        var sticky_enabled = function() {
301            if ( plugin.isDesktopView() ) {
302                return sticky_on_desktop === 'true';
303            } else {
304                return sticky_on_mobile === 'true';
305            }
306
307            return false;
308        };
309
310        plugin.calculate_menu_position = function() {
311            sticky_menu_offset_top = $wrap.offset().top;
312
313            if ($('body').hasClass('admin-bar') && $("#wpadminbar").is(":visible") && $("#wpadminbar").css('top') == '0px' && $("#wpadminbar").css('position') == 'fixed') {
314                admin_bar_height = $('#wpadminbar').height();
315                sticky_menu_offset_top = sticky_menu_offset_top - admin_bar_height;
316            }
317
318            if (sticky_offset < 0) {
319                sticky_menu_offset_top = sticky_menu_offset_top + sticky_offset;
320            } else {
321                sticky_menu_offset_top = sticky_menu_offset_top - sticky_offset;
322            }
323
324            sticky_menu_offset_left = $menu.parent().offset().left;
325            sticky_menu_width = window.getComputedStyle($wrap[0]).width;
326            sticky_menu_width_round_up = Math.ceil(parseFloat(sticky_menu_width));
327            sticky_menu_height = $wrap.height();
328        };
329
330        plugin.stick_menu = function() {
331            is_stuck = true;
332
333            var total_offset = parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10);
334
335            if (sticky_offset < 0) {
336                total_offset = parseInt(admin_bar_height, 10);
337            }
338
339            var placeholder = $("<div />").addClass("mega-sticky-wrapper").css({
340                'height' : sticky_menu_height + 'px',
341                'position' :'static'
342            });
343
344            $wrap.addClass('mega-sticky').wrap(placeholder).css({
345                'margin-top' : total_offset + 'px'
346            });
347
348            $("body").addClass($menu.attr("id") + "-mega-sticky");
349
350            $menu.css({
351                'max-width' : sticky_menu_width_round_up + 'px'
352            });
353
354            if (sticky_menu_offset_left > 0) {
355                $menu.css({
356                    'margin-left' : sticky_menu_offset_left + 'px'
357                });
358            }
359
360            if (is_vertical || sticky_expand === 'false') {
361                $wrap.css({
362                    'margin-left' : '0',
363                    'margin-right' : '0',
364                    'width' : sticky_menu_width_round_up + 'px',
365                    'left' : sticky_menu_offset_left + 'px'
366                });
367
368                $menu.css({
369                    'margin-left' : '0'
370                });
371            }
372
373            if ( $(window).width() <= breakpoint ) {
374                $wrap.css({
375                    'width' : sticky_menu_width_round_up + 'px'
376                });
377
378                if (sticky_expand_mobile === 'true') {
379                   $wrap.css({
380                        'margin-left' : '',
381                        'margin-right' : '',
382                        'width' : '',
383                        'left' : ''
384                    });
385
386                    $menu.css({
387                        'max-width' : '',
388                        'margin-left' : '',
389                        'width' : '',
390                        'left' : ''
391                    });
392                }
393            }
394
395            $wrap.delay(0).queue(function(next){
396                $(this).addClass('mega-stuck');
397                next();
398            });
399        };
400
401        plugin.unstick_menu = function(doing_resize) {
402            doing_resize = doing_resize || false;
403            is_stuck = false;
404            
405            $wrap.removeClass('mega-sticky').removeClass('mega-hide').css({
406                'margin' : '',
407                'width' : '',
408                'left': ''
409            });
410
411            $("body").removeClass($menu.attr("id") + "-mega-sticky");
412
413            if ( ! doing_resize ) { // this class is used for the height transition, do not remove it if we are simply resizing the window
414                $wrap.delay(0).queue(function(next){
415                    $(this).removeClass('mega-stuck');
416                    next();
417                });
418            }
419
420            $menu.css({
421                'margin-left' : '',
422                'max-width' : '',
423                'left' : '',
424                'width' : ''
425            });
426
427            if (sticky_transition == 'true' && ! doing_resize ) {
428                var delay = 250; // allows the transiton to complete before unwrapping the menu
429            } else {
430                var delay = 0;
431            }
432
433            $wrap.delay(delay).queue(function(next){
434                $(this).unwrap();
435                next();
436            });
437        };
438
439        plugin.mega_sticky_on_scroll = function(){
440            if ( ! sticky_enabled() ) {
441                return;
442            }
443
444            var scroll_top = $(window).scrollTop();
445
446            if (scroll_top > sticky_menu_offset_top) {
447                if (!is_stuck) {
448                    plugin.stick_menu();
449                }
450            } else {
451                if (is_stuck) {
452                    plugin.unstick_menu();
453                }
454            }
455        };
456
457        var mega_hide_on_scroll_up = function() {
458            if (sticky_hide_until_scroll_up_enabled()) {
459
460                if ( $menu.data("view") === "mobile" && $('.mega-menu-toggle', $wrap).hasClass('mega-menu-open') ) {
461                    return;
462                }
463
464                var scroll_top = $(window).scrollTop();
465                
466                if ( scroll_top < sticky_hide_until_scroll_up_offset ) {
467                    $wrap.removeClass('mega-hide');
468                    $("body").removeClass($menu.attr("id") + "-mega-hide");
469                }
470                
471                saved_scroll_top = last_scroll_top;
472
473                if (scroll_top < last_scroll_top) {
474                    // scroll up
475                    if (saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance) {
476                        $wrap.removeClass('mega-hide');
477                        $("body").removeClass($menu.attr("id") + "-mega-hide");
478                    }
479                } else {
480                    // scroll down
481                    if (is_stuck && scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance) {
482                        $wrap.addClass('mega-hide');
483                        $("body").addClass($menu.attr("id") + "-mega-hide");
484                    }
485                }
486
487                last_scroll_top = scroll_top;
488            }
489        }
490
491        plugin.mega_sticky_on_resize = function() {
492            if ($('input', $wrap).is(':focus')) {
493                return;
494            }
495
496            if ( sticky_enabled() ) {
497                if (is_stuck) {
498                    plugin.unstick_menu(true);
499                    plugin.calculate_menu_position();
500                    plugin.stick_menu();
501                } else {
502                    plugin.calculate_menu_position();
503                    plugin.mega_sticky_on_scroll();
504                }
505            } else {
506                if (is_stuck) {
507                    plugin.unstick_menu();
508                }
509            }
510        };
511
512        plugin.init = function() {
513            plugin.calculate_menu_position();
514            plugin.mega_sticky_on_scroll();
515
516            $('.mega-menu-accordion li.mega-menu-item').on('open_panel', function() {
517                plugin.calculate_menu_position();
518            });
519
520            var $window = $(window);
521
522            $window.scroll(function() {
523                 plugin.mega_sticky_on_scroll();
524                 mega_hide_on_scroll_up();
525            });
526
527            var windowWidth = $window.width();
528            var resizeTimer;
529
530            $window.resize(function() {
531                clearTimeout(resizeTimer);
532                resizeTimer = setTimeout(function(){    
533                    windowWidth = $window.width();
534                    plugin.mega_sticky_on_resize();
535                }, 100);
536            });
537        };
538
539        plugin.init();
540    };
541
542    $.fn.maxmegamenu_sticky = function(options) {
543
544        return this.each(function() {
545            if (undefined === $(this).data('maxmegamenu_sticky')) {
546                var plugin = new $.maxmegamenu_sticky(this, options);
547                $(this).data('maxmegamenu_sticky', plugin);
548            }
549        });
550
551    };
552
553    $(window).on('load', function (e) {
554        $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky();
555    });
556
557})(jQuery);
558
559/**
560 * Handle tabbed functionality
561 */
562(function($) {
563    $(function() {
564
565        var calculate_tabbed_sub_menu_widths = function( menu_item ) {
566            var menu = menu_item.parents('.max-mega-menu');
567
568            if( $(menu.attr('data-panel-inner-width')).length > 0 ) {
569                if ( menu.data("view") === "desktop" ) {
570                    $('> ul.mega-sub-menu', menu_item).each(function() {
571                        var tab_content = $(this);
572                        var parent_submenu_content_width = parseInt(tab_content.width());
573                        var parent_submenu_left_padding = parseInt(tab_content.css('paddingLeft'));
574                        var tabs_width = $(this).find('a.mega-menu-link').first().outerWidth();
575
576                        $('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function() {
577                            $(this).css('width', parent_submenu_content_width - tabs_width + 'px');
578                            $(this).css('left', parent_submenu_left_padding + tabs_width + 'px'); 
579                        });
580                    });
581                } else {
582                    $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() {
583                        $(this).css('width', '');
584                        $(this).css('left', ''); 
585                    });
586                }
587            }
588        }
589
590        var calculate_tabbed_sub_menu_heights = function( menu_item ) {
591
592            var menu = menu_item.parents('.max-mega-menu');
593            var max_height = 0;
594
595            if ( menu.data("view") === "desktop" ) {
596
597                $('> ul.mega-sub-menu', menu_item).css('minHeight', '');
598                
599                $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() {
600                    var tab_content = $(this);
601                    var this_height = parseInt(tab_content.css('height'));
602
603                    if (this_height > max_height) {
604                        max_height = this_height;
605                    }
606                });
607
608                var border_top_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderTopWidth'),10);
609                var border_bottom_width = parseInt($('> ul.mega-sub-menu', menu_item).css('borderBottomWidth'),10);
610                
611                $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height + border_bottom_width + border_top_width);
612            } else {
613                $('> ul.mega-sub-menu', menu_item).css('minHeight', '');
614            }
615        }
616
617        var $window = $(window);
618
619        var windowWidth = $window.width();
620
621        $window.resize(function() {
622            if ($window.width() != windowWidth) {
623                calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed'));
624                calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed'));
625            }            
626        });
627
628        $('li.mega-menu-tabbed, li.mega-menu-tabbed li.mega-collapse-children').on('open_panel', function() {
629            var menu = $(this).parents('.max-mega-menu');
630            var menu_item = $(this).closest(".mega-menu-tabbed");
631
632            calculate_tabbed_sub_menu_widths( menu_item );
633
634            $(">
634 ul.mega-sub-menu", $(this)).promise().done(function(){ // wait until slide animation has completed
635                calculate_tabbed_sub_menu_heights( menu_item );
636            });
637
638            if ( menu.data('view') == 'desktop' ) {
639                if ($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length == 0 ) {
640                    
641
642                    if ( $('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).length ) {
643                        $('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).first().addClass('mega-toggle-on');
644                    } else if ( $('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).length ) {
645                        $('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).first().addClass('mega-toggle-on');
646                    }
647                    
648
649                    if ($('> ul.mega-sub-menu > li.mega-toggle-on', menu_item).length == 0 ) {
650                        $('> ul.mega-sub-menu > li.mega-menu-item-has-children:visible', menu_item).first().addClass('mega-toggle-on');
651                    }
652                }
653
654                $('li.mega-menu-tabbed', menu).on('close_panel', function() {
655                    $('li.mega-menu-tabbed .mega-toggle-on', menu).removeClass('mega-toggle-on');
656                });
657            }
658
659            $('li.mega-menu-tabbed li.mega-collapse-children').on('close_panel', function() {
660                var menu_item = $(this).closest('.mega-menu-tabbed');
661
662                $("> ul.mega-sub-menu", $(this)).promise().done(function(){ // wait until slide animation has completed
663                    calculate_tabbed_sub_menu_heights( menu_item );
664                });
665            });
666        });
667    });
668})(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.