PageSourceSearch

https://pequenoprincipe.org.br/wp-content/plugins/megamenu-pro/assets/public.js?ver=2.1.3

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