PageSourceSearch

https://franklincovey.gr/wp-content/plugins/megamenu-pro/assets/public.js?ver=2.2.8

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