PageSourceSearch

https://jcls.org/wp-content/plugins/megamenu-pro/assets/public.js?ver=1.6.5

js jcls.org collected 2026-10-01 14:09:08 UTC 15,376 bytes, 443 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(menu, options) {
26
27        var plugin = this;
28        var $menu = $(menu);
29        var $wrap = $menu.parent();
30        var breakpoint = $menu.attr('data-breakpoint');
31
32        plugin.isDesktopView = function() {
33            return Math.max(window.outerWidth, $(window).width()) >= breakpoint; // account for scrollbars
34        };
35
36        plugin.isMobileView = function() {
37            return !plugin.isDesktopView();
38        };
39
40        plugin.monitorView = function() {
41            if (plugin.isDesktopView()) {
42                $menu.data("proview", "desktop");
43            } else {
44                $menu.data("proview", "mobile");
45            }
46
47            plugin.checkWidth();
48
49            $(window).resize(function() {
50                plugin.checkWidth();
51            });
52        };
53
54        plugin.checkWidth = function() {
55            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);
56
57            if ( plugin.isMobileView() ) {
58                var placeholder = expanding_search.attr('data-placeholder');
59                expanding_search.attr('placeholder', placeholder);
60            }
61
62            if ( plugin.isMobileView() && $menu.data("proview") === "desktop" ) {
63                $menu.data("proview", "mobile");
64                var placeholder = expanding_search.attr('data-placeholder');
65                expanding_search.attr('placeholder', placeholder);
66            }
67
68            if ( plugin.isDesktopView() && $menu.data("proview") === "mobile" ) {
69                $menu.data("proview", "desktop");
70                expanding_search.attr('placeholder', '');
71            }
72        };
73
74        plugin.init_replacements_search = function() {
75
76            $(".mega-search", $menu).children('input[type=text]').val("");
77
78            if ( plugin.isMobileView() ) {
79                $(".mega-search.expand-to-left .search-icon", $menu).on('click', function(e) {
80                    $(this).parents(".mega-search").submit();
81                });
82            } else {
83                $(".mega-search input[type=text]", $menu).on('focus', function(e) {
84                    var form = $(this).parents('.mega-search');
85
86                    if (! form.parent().hasClass('mega-static') && form.hasClass('mega-search-closed') && $menu.hasClass('mega-keyboard-navigation') ) {
87                        $(this).attr('placeholder', $(this).attr('data-placeholder'));
88                        form.removeClass('mega-search-closed');
89                        form.addClass('mega-search-open');
90                    }
91                });
92
93                $(".mega-search input[type=text]", $menu).on('blur', function(e) {
94                    var form = $(this).parents('.mega-search');
95
96                    if ( ! form.parent().hasClass('mega-static') && form.hasClass('mega-search-open') && $menu.hasClass('mega-keyboard-navigation') ) {
97                        $(this).attr('placeholder', '');
98                        form.removeClass('mega-search-open');
99                        form.addClass('mega-search-closed');
100                    }
101                });
102
103                $(".mega-search .search-icon", $menu).on('click', function(e) {
104
105                    var input = $(this).parents('.mega-search').children('input[type=text]');
106                    var form = $(this).parents('.mega-search');
107
108                    if (form.parent().hasClass('mega-static') ) {
109                        if (input.val() != '') {
110                            form.submit();
111                        }
112                    } else if (form.hasClass('mega-search-closed')) {
113                        input.focus();
114                        input.attr('placeholder', input.attr('data-placeholder'));
115                        form.removeClass('mega-search-closed');
116                        form.addClass('mega-search-open');
117                    } else if ( input.val() == '' ) {
118                        form.addClass('mega-search-closed');
119                        form.removeClass('mega-search-open');
120                        input.attr('placeholder', '');
121                    } else {
122                        form.submit();
123                    }
124                });
125            }
126
127        };
128
129
130        plugin.init_toggle_search = function() {
131
132            $(".mega-menu-toggle .mega-search", $wrap).children('input[type=text]').val("");
133
134            $(".mega-menu-toggle .mega-search .search-icon", $wrap).on('click', function(e) {
135
136                var input = $(this).parents('.mega-search').children('input[type=text]');
137                var form = $(this).parents('.mega-search');
138
139                if (form.hasClass('static') ) {
140                    form.submit();
141                } else if (form.hasClass('mega-search-closed')) {
142                    input.focus();
143                    input.attr('placeholder', input.attr('data-placeholder'));
144                    form.removeClass('mega-search-closed');
145                    form.addClass('mega-search-open');
146                } else if ( input.val() == '' ) {
147                    form.addClass('mega-search-closed');
148                    form.removeClass('mega-search-open');
149                    input.attr('placeholder', '');
150                } else {
151                    form.submit();
152                }
153            });
154
155        };
156
157        plugin.monitorView();
158        plugin.init_replacements_search();
159        plugin.init_toggle_search();
160
161    };
162
163    $.fn.maxmegamenu_searchbox = function(options) {
164
165        return this.each(function() {
166            if (undefined === $(this).data('maxmegamenu_searchbox')) {
167                var plugin = new $.maxmegamenu_searchbox(this, options);
168                $(this).data('maxmegamenu_searchbox', plugin);
169            }
170        });
171
172    };
173
174    $(function() {
175        $(".mega-menu").maxmegamenu_searchbox();
176    });
177})(jQuery);
178
179/**
180 * Sticky jQuery Plugin
181 */
182(function($) {
183
184    "use strict";
185
186    $.maxmegamenu_sticky = function(menu, options) {
187        var plugin = this;
188        var $menu = $(menu);
189        var $wrap = $menu.parent();
190        var breakpoint = $menu.attr('data-breakpoint');
191        var sticky_on_mobile = $menu.attr('data-sticky-mobile');
192        var sticky_expand = $menu.attr('data-sticky-expand');
193        var sticky_offset = parseInt($menu.attr('data-sticky-offset'));
194        var sticky_hide_until_scroll_up = $menu.attr('data-sticky-hide');
195        var sticky_hide_until_scroll_up_tolerance = parseInt($menu.attr('data-sticky-hide-tolerance'));
196        var sticky_hide_until_scroll_up_offset = parseInt($menu.attr('data-sticky-hide-offset'));
197        var sticky_menu_offset_top;
198        var sticky_menu_offset_left;
199        var sticky_menu_width;
200        var sticky_menu_width_round_up;
201        var sticky_menu_height;
202        var is_stuck = false;
203        var admin_bar_height = 0;
204        var last_scroll_top = 0;
205        var saved_scroll_top = 0;
206        var is_vertical = $menu.hasClass('mega-menu-vertical') || $menu.hasClass('mega-menu-accordion');
207
208        var sticky_hide_until_scroll_up_enabled = function() {
209            return $menu.hasClass('mega-menu-horizontal') && sticky_hide_until_scroll_up == "true";
210        }
211
212        var sticky_enabled = function() {
213            return $(window).width() > breakpoint || sticky_on_mobile === 'true';
214        };
215
216        var calculate_menu_position = function() {
217            sticky_menu_offset_top = $wrap.offset().top;
218            
219            if ($('body').hasClass('admin-bar') && $("#wpadminbar").is(":visible") && $("#wpadminbar").css('top') == '0px') {
220                admin_bar_height = $('#wpadminbar').height();
221                sticky_menu_offset_top = sticky_menu_offset_top - admin_bar_height;
222            }
223
224            if (sticky_offset < 0) {
225                sticky_menu_offset_top = sticky_menu_offset_top + sticky_offset;
226            } else {
227                sticky_menu_offset_top = sticky_menu_offset_top - sticky_offset;
228            }
229
230            sticky_menu_offset_left = $menu.offset().left;
231            sticky_menu_width = window.getComputedStyle($wrap[0]).width;
232            sticky_menu_width_round_up = Math.ceil(parseFloat(sticky_menu_width));
233            sticky_menu_height = $wrap.height();
234        };
235
236        plugin.stick_menu = function() {
237            is_stuck = true;
238
239            var total_offset = parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10);
240
241            if (sticky_offset < 0) {
242                total_offset = parseInt(admin_bar_height, 10);
243            }
244
245            var placeholder = $("<div />").addClass("mega-sticky-wrapper").css({
246                'height' : sticky_menu_height + 'px',
247                'position' :'static'
248            });
249
250            $wrap.addClass('mega-sticky').wrap(placeholder).css({
251                'margin-top' : total_offset + 'px'
252            });
253
254            if ($(window).width() > breakpoint) {
255                $menu.css({
256                    'margin-left' : sticky_menu_offset_left + 'px',
257                    'max-width' : sticky_menu_width_round_up + 'px'
258                });
259            } else {
260                $menu.css({
261                    'margin-left' : '0',
262                    'max-width' : 'auto'
263                });
264            }
265
266            if (is_vertical || sticky_expand === 'false') {
267                $wrap.css({
268                    'margin-left' : '0',
269                    'margin-right' : '0',
270                    'width' : sticky_menu_width_round_up + 'px',
271                    'left' : sticky_menu_offset_left + 'px'
272                });
273
274                $menu.css({
275                    'margin-left' : '0'
276                });
277            }
278
279            $wrap.delay(0).queue(function(next){
280                $(this).addClass('mega-stuck');
281                next();
282            });
283        };
284
285        plugin.unstick_menu = function() {
286            is_stuck = false;
287
288            $wrap.removeClass('mega-sticky').removeClass('mega-stuck').removeClass('mega-hide').removeClass('mega-reveal').unwrap().css({
289                'margin' : '',
290                'width' : '',
291                'left': ''
292            });
293
294            $menu.css({
295                'margin-left' : '',
296                'max-width' : ''
297            });
298        };
299
300        var mega_sticky_on_scroll = function(){
301            if ( ! sticky_enabled() ) {
302                return;
303            }
304
305            var scroll_top = $(window).scrollTop();
306
307            if (scroll_top > sticky_menu_offset_top) {
308                if (!is_stuck) {
309                    plugin.stick_menu();
310                }
311            } else {
312                if (is_stuck) {
313                    plugin.unstick_menu();
314                }
315            }
316        };
317
318        var mega_hide_on_scroll_up = function() {
319            if (sticky_hide_until_scroll_up_enabled() && $(window).width() > breakpoint) {
320                var scroll_top = $(window).scrollTop();
321
322                if ( last_scroll_top > 0 ) {
323                    // Only hide once scrolling. Show menu when refreshing page.
324                    $wrap.addClass('mega-hide');
325                }
326                
327                if ( scroll_top < sticky_hide_until_scroll_up_offset ) {
328                    $wrap.addClass('mega-reveal');
329                }
330                
331                saved_scroll_top = last_scroll_top;
332
333                if (scroll_top < last_scroll_top) {
334                    // scroll up
335                    if (saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance) {
336                        $wrap.addClass('mega-reveal');
337                    }
338                } else {
339                    // scroll down
340                    if (scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance) {
341                        $wrap.removeClass('mega-reveal');
342                    }
343                }
344
345                last_scroll_top = scroll_top;
346            }
347        }
348
349        var mega_sticky_on_resize = function() {
350            if ($('input', $wrap).is(':focus')) {
351                return;
352            }
353
354            if ( sticky_enabled() ) {
355                if (is_stuck) {
356                    plugin.unstick_menu();
357                    calculate_menu_position();
358                    plugin.stick_menu();
359                } else {
360                    calculate_menu_position();
361                    mega_sticky_on_scroll();
362                }
363            } else {
364                if (is_stuck) {
365                    plugin.unstick_menu();
366                }
367            }
368        };
369
370        plugin.init = function() {
371            calculate_menu_position();
372            mega_sticky_on_scroll();
373
374            var $window = $(window);
375
376            $window.scroll(function() {
377                 mega_sticky_on_scroll();
378                 mega_hide_on_scroll_up();
379            });
380
381            var windowWidth = $window.width();
382
383            $window.resize(function() {
384                if ($window.width() != windowWidth) {
385                    windowWidth = $window.width();
386                    mega_sticky_on_resize();
387                }
388            });
389        };
390
391        plugin.init();
392    };
393
394    $.fn.maxmegamenu_sticky = function(options) {
395
396        return this.each(function() {
397            if (undefined === $(this).data('maxmegamenu_sticky')) {
398                var plugin = new $.maxmegamenu_sticky(this, options);
399                $(this).data('maxmegamenu_sticky', plugin);
400            }
401        });
402
403    };
404
405    $(function() {
406        $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky();
407    });
408})(jQuery);
409
410/**
411 * Handle tabbed functionality
412 */
413(function($) {
414    $(function() {
415        $('li.mega-menu-tabbed').on('open_panel', function() {
416            var menu = $(this).parents('.mega-menu');
417            var menu_item = $(this);
418
419            if ( menu.data('view') == 'desktop' ) {
420                var max_height = 0;
421
422                if ($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length == 0 ) {
423                    $('> ul.mega-sub-menu > li.mega-menu-item-has-children', menu_item).first().addClass('mega-toggle-on');
424                }
425
426                $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function() {
427                    var tab_content = $(this);
428                    var this_height = parseInt(tab_content.css('height'));
429
430                    if (this_height > max_height) {
431                        max_height = this_height;
432                    }
433                });
434
435                $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height);
436            }
437
438            $('li.mega-menu-tabbed').on('close_panel', function() {
439                $(".mega-toggle-on", menu).removeClass("mega-toggle-on");
440            });
441        });
442    });
443})(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.