PageSourceSearch

https://tercerparlante.com/wp-content/themes/fox/js56/main.js?ver=6.9.7.1

js tercerparlante.com collected 2026-10-02 14:07:24 UTC 38,934 bytes, 1,173 lines download raw bytes

1!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function i(){var b,c,d={height:f.innerHeight,width:f.innerWidth};return d.height||(b=e.compatMode,(b||!a.support.boxModel)&&(c="CSS1Compat"===b?g:e.body,d={height:c.clientHeight,width:c.clientWidth})),d}function j(){return{top:f.pageYOffset||g.scrollTop||e.body.scrollTop,left:f.pageXOffset||g.scrollLeft||e.body.scrollLeft}}function k(){if(b.length){var e=0,f=a.map(b,function(a){var b=a.data.selector,c=a.$element;return b?c.find(b):c});for(c=c||i(),d=d||j();e<b.length;e++)if(a.contains(g,f[e][0])){var h=a(f[e]),k={height:h[0].offsetHeight,width:h[0].offsetWidth},l=h.offset(),m=h.data("inview");if(!d||!c)return;l.top+k.height>d.top&&l.top<d.top+c.height&&l.left+k.width>d.left&&l.left<d.left+c.width?m||h.data("inview",!0).trigger("inview",[!0]):m&&h.data("inview",!1).trigger("inview",[!1])}}}var c,d,h,b=[],e=document,f=window,g=e.documentElement;a.event.special.inview={add:function(c){b.push({data:c,$element:a(this),element:this}),!h&&b.length&&(h=setInterval(k,250))},remove:function(a){for(var c=0;c<b.length;c++){var d=b[c];if(d.element===this&&d.data.guid===a.guid){b.splice(c,1);break}}b.length||(clearInterval(h),h=null)}},a(f).on("scroll resize scrollstop",function(){c=d=null}),!g.addEventListener&&g.attachEvent&&g.attachEvent("onfocusin",function(){d=null})});
2
3/**
4 * since 5.6
5 */
6var $ = jQuery
7
8// Disable tooltip (microtip) - Use fox56-tooltip
9$(function() {
10    let $fox56_tooltip = $('#fox56-tooltip');
11    if( 0 == $fox56_tooltip.length ) {
12        $fox56_tooltip = $('<div id="fox56-tooltip"></div>').appendTo('body');
13    }
14
15    $('[role="tooltip"]').on('mouseenter', function(e) {
16        let pos = $(this).data('microtip-position');
17        // pos = 'bottom';
18        $fox56_tooltip.html( $(this).attr('aria-label') )
19                .attr('class', 'fox56_tooltip fox56_tooltip__'+pos);
20        
21        // switch
22        let top = $(this).offset().top - $(window).scrollTop(), left = $(this).offset().left;
23        switch ( pos ) {
24            case 'top':
25                top = top - $fox56_tooltip.outerHeight();
26                left = left - ($fox56_tooltip.outerWidth()/2) + ($(this).outerWidth()/2);
27                break;
28            case 'bottom':
29                top = top + $(this).outerHeight();
30                left = left - ($fox56_tooltip.outerWidth()/2) + ($(this).outerWidth()/2);
31                break;
32            case 'left':
33                top = top - ($fox56_tooltip.outerHeight()/2) + ($(this).outerHeight()/2);
34                left = left - $fox56_tooltip.outerWidth();
35                break;
36            case 'right':
37                top = top - ($fox56_tooltip.outerHeight()/2) + ($(this).outerHeight()/2);
38                left = left + $(this).outerWidth();
39                break;
40            default:
41                break;
42        }
43        $fox56_tooltip.attr('style', 'top:'+top+'px;'+ 'left:'+left+'px');
44    });
45    // Remove tooltip on Mouse leave
46    $('[role="tooltip"]').on('mouseleave', function(e) {
47        $fox56_tooltip.attr('style', 'display:none');
48    });
49});
50
51/* Debounce
52--------------------------------------------------------------------------------------------- */
53window.debounce = function(func, wait, immediate) {
54    var timeout;
55    return function() {
56        var context = this, args = arguments;
57        var later = function() {
58            timeout = null;
59            if (!immediate) func.apply(context, args);
60        };
61        var callNow = immediate && !timeout;
62        clearTimeout(timeout);
63        timeout = setTimeout(later, wait);
64        if (callNow) func.apply(context, args);
65    };
66};
67
68/**
69 * WooCommerce Quantity Buttons
70 * @since 2.4
71 */
72$( document ).ready( function(){
73    
74    var insert_quan = function() {
75
76        // Quantity buttons
77        $( 'div.quantity:not(.buttons-added), td.quantity:not(.buttons-added)' )
78        .addClass( 'buttons-added' )
79        .append( '<input type="button" value="+" class="plus" />' )
80        .prepend( '<input type="button" value="-" class="minus" />' );
81
82        // Set min value
83        $( 'input.qty:not(.product-quantity input.qty)' ).each ( function() {
84            var qty = $( this ),
85                min = parseFloat( qty.attr( 'min' ) );
86            if ( min && min > 0 && parseFloat( qty.val() ) < min ) {
87                qty.val( min );
88            }
89        });
90        
91    }
92    
93    insert_quan();
94    
95    $( document.body ).on( 'updated_cart_totals', function(){
96        insert_quan()
97    })
98
99    // Handle click event
100    $( '.quantity' ).on( 'click', '.plus, .minus', function() {
101
102            // Get values
103        var qty = $( this ).closest( '.quantity' ).find( '.qty' ),
104            currentQty = parseFloat( qty.val() ),
105            max = parseFloat( qty.attr( 'max' ) ),
106            min = parseFloat( qty.attr( 'min' ) ),
107            step = qty.attr( 'step' );
108
109        // Format values
110        if ( !currentQty || currentQty === '' || currentQty === 'NaN' ) currentQty = 0;
111        if ( max === '' || max === 'NaN' ) max = '';
112        if ( min === '' || min === 'NaN' ) min = 0;
113        if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;
114
115        // Change the value
116        if ( $( this ).is( '.plus' ) ) {
117
118            if ( max && ( max == currentQty || currentQty > max ) ) {
119                qty.val( max );
120            } else {
121                qty.val( currentQty + parseFloat( step ) );
122            }
123
124        } else {
125
126            if ( min && ( min == currentQty || currentQty < min ) ) {
127                qty.val( min );
128            } else if ( currentQty > 0 ) {
129                qty.val( currentQty - parseFloat( step ) );
130            }
131
132        }
133
134        // Trigger change event
135        qty.trigger( 'change' );
136
137    });
138
139})
140
141/* LIGHTBOX
142==========================================================================================  */
143var gallery_args = {
144    type: 'image',
145    delegate: 'a',
146    gallery: {
147        enabled: true,
148        tCounter: '%curr% / <span class="total">%total%</span>',
149        arrowMarkup : '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"><i class="ic56-chevron-thin-%dir%"></i></button>',
150    },
151    removalDelay : 400,
152    tLoading : WITHEMES56.l10n.loading ? WITHEMES56.l10n.loading : 'Loading...',
153    image: {
154        // options for image content type
155        titleSrc: function(item) {
156            var text = item.el.closest( 'figure' ).find( 'figcaption' );
157            if ( ! text.length ) return '';
158
159            text = text.html();
160
161            if ( text.split( ' ' ).length > 12 ) {
162                return '<p class="lightbox-caption-long">' + text + '</p>';
163            } else {
164                return '<p class="lightbox-caption-short">
164' + text + '</p>';
165            }
166        }
167    },
168    closeBtnInside : true,
169    closeMarkup : '<button title="%title%" type="button" class="mfp-close"><i class="ic56-clear"></i></button>',
170    callbacks: {
171
172        beforeOpen: function() {
173            $( 'html' ).addClass( 'lightbox-open' )
174        },
175        afterClose: function() {
176            $( 'html' ).removeClass( 'lightbox-open' )
177        },
178        imageLoadComplete: function() {	
179            var self = this;
180            setTimeout(function() { self.wrap.addClass('mfp-image-loaded'); }, 16);
181        }
182
183    }
184}
185var run_lightbox = function( selector = null ) {
186
187    if ( ! selector ) {
188        selector = $( 'body' )
189    }
190    
191    if ( ! WITHEMES56.enable_lightbox ) {
192        return
193    }
194    
195    if ( ! $().magnificPopup ) {
196        return;
197    }
198    
199    /* ------------------------------ video type */
200    selector.find( '.open-video-lightbox' ).magnificPopup({
201        type: 'iframe',
202    });
203
204    /* ------------------------------ grid gallery */
205    selector.find( '.gallery56--lightbox' ).each(function() {
206        var wrapper = $( this )
207        wrapper.magnificPopup( gallery_args )
208    });
209
210    /* ------------------------------ single post gallery */
211    selector.find( '.single56__content .wp-block-gallery, .gallery' ).each(function(){
212        var wrapper = $( this )
213        var as = wrapper.find( 'a' ).filter(function(index){
214            var href = $( this ).attr('href');
215            if (href) {
216                href = href.toLowerCase()
217            }
218            var extension = href.split('.').pop(),
219                img_extensions = [ 'jpg', 'gif', 'jpeg', 'png', 'bmp', 'svg', 'webp', 'avif', 'tiff' ]
220            return img_extensions.includes( extension )
221        })
222        var new_args = gallery_args
223        new_args.delegate = null
224        if ( ! as.length ) {
225            return;
226        }
227        as.magnificPopup( new_args )
228    });
229
230    /* ------------------------------ single images */
231    selector.find( '.wp-block-image a, .align-left a, .align-right a, .align-center a, .align-stretch a, .align-wide a, .align-none a' ).each(function(){
232
233        // hmm, is this an efficient method?
234        if ( $( this ).closest( '.wp-block-gallery' ).length ) {
235            return
236        }
237        
238        var href = $( this ).attr('href');
239        if ( ! href ) {
240            return;
241        }
242        href = href.toLowerCase()
243        var extension = href.split('.').pop()
244        var img_extensions = [ 'jpg', 'gif', 'jpeg', 'png', 'bmp', 'svg', 'webp', 'tiff' ]
245        if ( ! img_extensions.includes( extension ) ) {
246            return;
247        }
248        var new_args = gallery_args
249        new_args.gallery = { enabled: false }
250        new_args.removalDelay = 0
251        new_args.delegate = null
252        $( this ).magnificPopup( new_args )
253    })
254
255}
256
257/* DARK MODE
258==================================================================================== */
259function createCookie(name, value, days) {
260    var expires;
261
262    if (days) {
263        var date = new Date();
264        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
265        expires = "; expires=" + date.toGMTString();
266    } else {
267        expires = "";
268    }
269    document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
270}
271
272function eraseCookie(name) {
273    createCookie(name, "", -1);
274}
275
276var cookie_prefix2 = 'fox_' + WITHEMES56.site_id + '_'
277$( document ).ready(function() {
278    $( '.lamp56' ).on( 'click', function(e) {
279        $( 'body' ).toggleClass( 'darkmode' );
280        if ( $( 'body' ).hasClass( 'darkmode' ) ) {
281            createCookie( cookie_prefix2 + 'user_darkmode', 'dark' );
282        } else {
283            createCookie( cookie_prefix2 + 'user_darkmode', 'light' );
284        }
285    });
286});
287
288/* MOBILE SHARE
289since v6.8
290==========================================================================================  */
291$( document ).ready(function() {
292    $( '.li-share a' ).on( 'click', function( e ) {
293        e.preventDefault()
294        let li = $( this ).parent(),
295            ul = li.closest( '.share56 ul' ),
296            dropdown = li.find( '.li-share-dropdown' )
297        if ( ! dropdown.length ) {
298            return
299        }
300        dropdown.addClass( 'shown' )
301        if ( dropdown.hasClass( 'icons-added' ) ) {
302            return
303        }
304        ul.find( 'li:not(.li-share)' ).clone().appendTo( dropdown.find( 'ul' ) )
305        dropdown.addClass( 'icons-added' )
306    })
307    $( '#wi-all' ).on( 'click', function(e) {
308        if ( ! $( e.target ).closest( '.share56' ).length ) {
309            $( '.li-share-dropdown' ).removeClass('shown')
310        }
311    })
312})
313
314/* THUMBNAIL SHOWING EFFECT
315 * since 6.0.9
316==================================================================================== */
317$( document ).ready(function() {
318    $( '.thumbnail56--hasshowing' ).each(function() {
319        var thumbnail = $( this )
320        thumbnail.on('inview', function(e, isInView) {
321            if (isInView) {
322                thumbnail.addClass( 'inview' )
323            }
324          });
325    })
326});
327
328/* SCROLL DOWN
329==================================================================================== */
330$( document ).ready(function() {
331    
332    $( '.scroll-down-btn' ).on( 'click', function( e ) {
333        e.preventDefault();
334        var hero = $( this ).closest( '.hero56' );
335        if ( ! hero.length ) {
336            return;
337        }
338        
339        var scrollTop = hero.offset().top + $( window ).outerHeight();
340        if ( $( '#wpadminbar' ).length ) {
341            scrollTop = scrollTop - $( '#wpadminbar' ).outerHeight();
342        }
343        
344        $( "html, body").animate({ scrollTop: scrollTop + 'px' }, 300 , 'linear' );
345        
346    });
347    
348});
349
350/* SIDE DOCK
351==================================================================================== */
352$( document ).ready(function() {
353
354    var doc = $( '.sidedock56' );
355    if ( ! doc.length ) {
356        return;
357    }
358    if ( ! $( '#wi-footer,.footer-elementor' ).length ) {
359        return;
360    }
361    var close = doc.find( '.close' );
362    $( '#wi-footer,.footer-elementor' ).each(function(){
363        var footer = $( this )
364        footer.on( 'inview', function(e,isInvew){
365            if ( isInvew ) {
366                if ( ! doc.data('never-show')) {
367                    doc.addClass( 'shown' )
368                }
369            }
370        })
371    })
372    
373    // Setup Animation
374    doc.find( '.sidedock56__post' ).each(function( i ) {
375        $( this ).css({
376            '-webkit-transition-delay': ( 400 + 80 * i + 'ms' ),
377            'transition-delay': ( 400 + 80 * i + 'ms' ),
378        });
379    });
380
381    // close
382    $( '.sidedock56 .close' ).on( 'click', function(e){
383        e.preventDefault()
384        doc
385        .removeClass( 'shown' )
386        .addClass( 'dont-show-me-again' )
387        .data( 'never-show', true )
388    })
389});
390
391/* PROGRESS
392==================================================================================== */
393$( document ).ready(function() {
394    
395    var progress = $( '.progress56' ),
396        postContent = $( '.single56__post_content' );
397    if ( ! progress.length ) return;
398    if ( ! postContent.length ) return;
399
400    // move it to header
401    if ( progress.hasClass( 'progress56--header' ) ) {
402        var sticky_header = $( '.masthead--sticky' );
403        if ( sticky_header.length ) {
404            progress.appendTo( sticky_header.find( '.masthead__wrapper' ) )
405
406        // otherwise, move it to top
407        } else {
408            progress.removeClass( 'progress56--header' )
409            progress.addClass( 'progress56--top' )
410        }
411    }
412
413    var offsetBottom = postContent.offset().top + postContent.outerHeight();
414    
415    var getMax = function() {
416        return offsetBottom;
417    }
418
419    var getValue = function(){
420        var top = $( window ).scrollTop();
421        if ( top > getMax() ) return getMax();
422        else return top;
423    }
424
425    progress.attr( 'max', getMax() );
426
427    $(document).on('scroll', function(){
428        // On scroll only Value attr needs to be calculated
429        progress.attr({ value: getValue() });
430    });
431    
432    var run = function() {
433        // too short
434        /*
435        if ( postContent.outerHeight() < $( window ).height() ) {
436            progress.hide();
437            return;
438        } else {
439            progress.show();
440        }
441        */
442        
443        offsetBottom = postContent.offset().top + postContent.outerHeight();
444        progress.attr( 'max', offsetBottom );
445    }
446    run()
447    
448    // re-calculate offsetBottom on resize
449    $( window ).resize( debounce( function() {
450        run();
451    }, 100 ) );
452    
453})
454
455/* CAROUSEL
456since 5.6
457==================================================================================== */
458function run_carousel( selector = null ) {
459
460    if ( ! $().flickity ) {
461        return
462    }
463
464    if ( selector ) {
465        if ( ! selector.hasClass( 'carousel56' ) ) {
466            selector = selector.find( '.carousel56' )
467        }
468    } else {
469        selector = jQuery( '.carousel56' )
470    }
471    selector.each(function() {
472        var wrapper = $( this ),
473            main_carousel = wrapper.find( '.main-carousel' ),
474            options = wrapper.data( 'options')
475
476        main_carousel.on( 'ready.flickity', function() {
477            
478            main_carousel.addClass( 'carousel-ready' )
479
480            if ( ! WITHEMES56.enable_lightbox ) {
481                return
482            }
483            if ( ! $().magnificPopup ) {
484                return;
485            }
486
487            var as = main_carousel.find( 'a' ).filter(function(index){
488                var href = $( this ).attr('href');
489                if (href) {
490                    href = href.toLowerCase()
491                }
492                var extension = href.split('.').pop(),
493                    img_extensions = [ 'jpg', 'gif', 'jpeg', 'png', 'bmp', 'svg', 'webp', 'tiff' ]
494                return img_extensions.includes( extension )
495            })
496            var new_args = gallery_args
497            new_args.delegate = null
498            if ( ! as.length ) {
499                return;
500            }
501            as.magnificPopup( new_args )
502
503        });
504
505        main_carousel.flickity( options );
506    });
507
508}
509
510/* MASONRY
511since 5.6
512==================================================================================== */
513function run_masonry( selector = null ) {
514    if ( selector ) {
515        if ( ! selector.hasClass( 'masonry56' ) ) {
516            selector = selector.find( '.masonry56' )
517        }
518    } else {
519        selector = jQuery( '.masonry56' )
520    }
521    selector.each(function() {
522
523        var wrapper = jQuery( this ),
524            std = {
525                columnWidth: '.grid-sizer',
526                percentPosition: true,
527                initLayout: false,
528            },
529            options = wrapper.data( 'options' )
530            options = jQuery.extend( std, options );
531
532        wrapper.imagesLoaded( function() {
533        
534            var grid = wrapper.find( '.main-masonry' ).masonry( options );
535            grid.masonry( 'on', 'layoutComplete', function() {
536                wrapper.addClass( 'loaded' );
537
538                wrapper.find( '.masonry-cell' ).each(function() {
539                    var item = $( this )
540                    item.on( 'inview', function( e, isInview ){
541                        if ( isInview ) {
542                            item.addClass( 'inview' )
543                        }
544                    })
545                }); // each
546
547            });
548        
549            grid.masonry();
550
551        });
552
553    });
554}
555
556/* STICKY SIDEBAR
557since 5.6
558==================================================================================== */
559function run_sticky_sidebar( selector = null ) {
560    if ( ! $().theiaStickySidebar ) return;
561    if ( selector ) {
562        if ( ! selector.hasClass( 'hassidebar--sticky' ) ) {
563            selector = selector.find( '.hassidebar--sticky' )
564        }
565    } else {
566        selector = $( '.hassidebar--sticky' )
567    }
568    selector.each(function() {
569        var wrapper = $( this )
570        wrapper.find( '.primary56, .secondary56' ).theiaStickySidebar({
571            minWidth: 1024,
572        })
573    });
574}
575
576/* toggle search
577==================================================================================== */
578$( document ).ready(function() {
579    
580    let search_wrapper = $( '.search-wrapper-toggle' )
581    if ( ! search_wrapper.length ) {
582        return
583    }
584
585    // close
586    $( document ).on( 'click', function( e ) {
587        var currentTarget = $( e.target );
588        if ( currentTarget.closest( '.header56__search' ).length ) {
589        } else {
590            if( search_wrapper.hasClass( 'shown' ) ) {
591                search_wrapper.removeClass( 'shown' )
592                $( '.search-btn-toggle' ).find( 'i' ).removeClass( 'ic56-clear' )
593            }
594        }
595    })
596
597    // open
598    $( document ).on( 'click', '.search-btn-toggle', function( e ) {
599        e.preventDefault();
600        search_wrapper.toggleClass( 'shown' );
601        $(this).find("i").toggleClass('ic56-clear');
602        if( search_wrapper.hasClass( 'shown' ) ) {
603            search_wrapper.find('.search-field').focus();
604        }
605    });
606})
607
608/* classic search
609==================================================================================== */
610const classic_search_close = function() {
611    $( '.search-wrapper-classic' ).slideUp('fast','linear');
612}
613$( document ).ready(function($) {
614
615    /* -------------------  click search button */
616    $( '.search-btn-classic' ).on( 'click', function( e ) {
617        e.preventDefault()
618        var btn = $( this ),
619            header_row = $( '.main_header56' ); // we always append it to the main section
620        
621        // Check if mobile devices
622        if ( ! header_row.is(':visible') ) {
623            header_row = $( '.header_mobile56' );
624        }
625        
626        if ( ! header_row.length ) {
627            return;
628        }
629        if ( ! $( '.search-wrapper-classic' ).length ) {
630            return;
631        }
632
633        var container = header_row.find( '.container' )
634        if ( ! container.length ) {
635            return;
636        }
637        container = container.first();
638        if ( ! container.find( '>.search-wrapper-classic' ).length ) {
639            container.prepend( $( '.search-wrapper-classic' ).first() )
640        }
641        var wrapper = container.find( '>.search-wrapper-classic' );
642        $("html, body").animate({ scrollTop: 0 }, 400 , 'linear');
643        wrapper.slideDown( 200 ,function() {
644            wrapper.find( '.s' ).focus();
645        })
646    });
647
648    
649
650    /* -------------------  click outside to close it */
651    if ( $( '.search-wrapper-classic' ).length ) {
652        $( document ).on( 'click', function( e ) {
653        
654            var currentTarget = $( e.target );
655            if ( currentTarget.is( '.search-wrapper-classic, .search-btn-classic' ) || currentTarget.closest( '.search-wrapper-classic, .search-btn-classic' ).length ) {
656            } else {
657                classic_search_close()
658            }
659            
660        })
661    }
662
663});
664
665/* toggle search
666==================================================================================== */
667
668/* flying search
669==================================================================================== */
670let modal_search_close = function() {
671    $( 'html' ).removeClass( 'in-modal-search56' );
672}
673$( document ).ready(function() {
674        
675    var modal_search_open = function() {
676        $( 'html' ).addClass( 'in-modal-search56' );
677    }
678    
679    /* open by click 
680    ------------------------------------ */
681    $( '.search-btn-modal' ).on( 'click', function( e ) {
682        
683        /**
684         * set up
685         */
686        if ( ! $( '.search-wrapper-modal' ).length ) {
687            return;
688        }
689        var wrapper = $( 'body > .search-wrapper-modal' )
690        if ( ! wrapper.length ) {
691            $( 'body' ).append( $( '.search-wrapper-modal' ).first() )
692            wrapper = $( 'body > .search-wrapper-modal' )
693        }
694        wrapper = wrapper.first()
695    
696        setTimeout(function() {
697            modal_search_open();
698        }, 100 );
699        setTimeout(function() {
700            wrapper.find( '.s' ).focus();
701        }, 150 );
702
703    });
704    
705    /* close by click the close button
706    ------------------------------------ */
707    $( '.search-modal-close-btn' ).on( 'click', function( e ) {
708        
709        e.preventDefault()
710        modal_search_close()
711        
712    });
713    
714});
715
716/* off canvas open
717==========================================================================================  */
718$( document ).ready(function() {
719    
720    // hamburger is a toggle class
721    $( '.hamburger' ).on( 'click', function() {
722        $( 'html' ).toggleClass( 'on-offcanvas' )
723    });
724
725    $( '.close-offcanvas, .offcanvas56__overlay' ).on( 'click', function() {
726        $( 'html' ).removeClass( 'on-offcanvas' )
727    });
728    
729    /* animation
730    ------------------------------------ */
731    $( '.offcanvas56--hasanimation' ).find( '.offcanvasnav56 ul.menu > li, .offcanvas56__social, .offcanvas56__search, .widget, .offcanvas56__html1, .offcanvas56__html2, .offcanvas56__html3, .offcanvas56__button1, .offcanvas56__button2' ).each(function(index) {
732        $( this ).css({
733            transitionDelay : -400 + 400 * Math.pow(index + 1, 1/3) + 'ms',
734        })
735    })
736
737});
738
739/* off canvas menu
740==========================================================================================  */
741$( document ).ready(function() {
742    
743    $( '.offcanvasnav56 .mk' ).on( 'click', function( e ) {
744        e.preventDefault()
745        var li = $( this ).closest( 'li' ),
746            ul = li.find( '> ul' )
747        if ( ! ul.length ) {
748            return;
749        }
750        if ( li.hasClass( 'active') ) {
751            ul.slideUp('fast','linear')
752            li.removeClass( 'active' )
753        } else {
754            ul.slideDown('fast','linear')
755            li.addClass( 'active' )
756        }
757    });
758    
759});
760
761/* STICKY HEADER
762==========================================================================================  */
763$( document ).ready(function() {
764    var masthead = $( '.masthead--sticky' )
765    if ( ! masthead.length ) {
766        return;
767    }
768    var wrapper = masthead.find( '.masthead__wrapper' ),
769        header_top = masthead.offset().top,
770        header_h = wrapper.outerHeight(),
771        delay_distance = 220,
772        sticky_point = header_top + header_h + delay_distance,
773        hide_point = header_top + header_h
774
775    // masthead.css( 'height', header_h )
776    window.addEventListener('resize', debounce( function() {
777        wrapper.removeClass('is-sticky before-sticky') // to recalculate the height
778        // masthead.css( 'height',masthead.outerHeight() )
779        readAndUpdatePage()
780    }, 50) );
781
782    var scheduledAnimationFrame;
783    function readAndUpdatePage() {
784        var windowTop = window.scrollY;
785        if ( windowTop > sticky_point ) {
786            wrapper.addClass('before-sticky is-sticky');
787            masthead.css( 'height', header_h )
788        } else if ( windowTop > hide_point ) {
789            wrapper.removeClass('is-sticky');
790            wrapper.addClass('before-sticky');
791            masthead.css( 'height',header_h )
792        } else {
793            wrapper.removeClass('is-sticky before-sticky');
794            masthead.css( 'height', '' )
795            // update the header height
796            // header_h = wrapper.outerHeight()
797        }
798        scheduledAnimationFrame = false;
799    }    
800
801    var onscroll = function() {
802
803        // Store the scroll value for laterz.
804        var windowTop = window.scrollY;
805
806        // Prevent multiple rAF callbacks.
807        if (scheduledAnimationFrame){
808            return;
809        }
810
811        scheduledAnimationFrame = true;
812        requestAnimationFrame(readAndUpdatePage);
813    }
814    //  readAndUpdatePage()
815    window.addEventListener('scroll', onscroll);
816});
817
818/* SCROLL TOP
819==========================================================================================  */
820$( document ).ready(function() {
821    $( '.scrollup56, a[href="#top"]' ).on( 'click', function( e ) {
822        e.preventDefault()
823        $("html, body").animate({ scrollTop: 0 }, 400 , 'linear');
824		return false;     
825    })
826
827    var scheduledAnimationFrame = false
828    var readAndUpdatePage = function() {
829        if ( window.scrollY > 200) {
830            $('.scrollup56').addClass('shown');
831        } else {
832            $('.scrollup56').removeClass('shown');
833        }
834        scheduledAnimationFrame = false;
835    }
836
837    var onscroll = function() {
838
839        // Prevent multiple rAF callbacks.
840        if (scheduledAnimationFrame){
841            return;
842        }
843
844        scheduledAnimationFrame = true;
845        requestAnimationFrame(readAndUpdatePage);
846    }
847    readAndUpdatePage()
848    window.addEventListener('scroll', onscroll);
849
850});
851
852/* HEADER MIN STICKY
853==========================================================================================  */
854var run_minimal_header_sticky = function( selector = null ) {
855
856    if ( ! $( '.minimal-header' ).length ) {
857        return;
858    }
859
860    var scheduledAnimationFrame = false,
861        vh = $( window ).outerHeight();
862    var readAndUpdatePage = function() {
863        if ( window.scrollY > vh ) {
864            $( '.minimal-header' ).removeClass( 'top-mode' );
865        } else {
866            $( '.minimal-header' ).addClass( 'top-mode' );
867        }
868        scheduledAnimationFrame = false;
869    }
870
871    var onscroll = function() {
872
873        // Prevent multiple rAF callbacks.
874        if (scheduledAnimationFrame){
875            return;
876        }
877
878        scheduledAnimationFrame = true;
879        requestAnimationFrame(readAndUpdatePage);
880    }
881    readAndUpdatePage()
882    window.addEventListener('scroll', onscroll);
883    
884}
885
886/* HEADER MEGA
887==========================================================================================  */
888var run_header_mega = function( selector = null ) {
889
890    /* --------------------------------     set up mega menu */
891    var setup_mega = function( container ) {
892
893        var outerContainer = container.closest( '.container' )
894        if ( ! outerContainer.length ) {
895            return;
896        }
897            
898        var setup_position = debounce( function() {
899            var outerContainerLeft = outerContainer.offset().left,
900                outerContainerWidth = outerContainer.outerWidth()
901
902            container.find( 'ul.menu > li.mega' ).each(function() {
903
904                var li = $( this ),
905                    ul = li.find( '>ul' )
906                    
907                if ( ! ul.length ) {
908                    return;
909                }
910                li.removeClass( 'mega-loaded' )
911
912                /* ------------------- column */
913                var col = ul.find( ' > li' ).length;
914                if ( li.hasClass( 'menu-item-object-category' ) ) col = 3;
915                if ( ! col ) {
916                    return;
917                }
918
919                if ( col > 0 ) {
920                    li.addClass( 'column-' + col );
921                }
922                if ( col >= 4 ) {
923
924                    li.addClass( 'mega-full' );
925                    ul.css('width', outerContainerWidth)
926                    var translateX = li.offset().left - outerContainerLeft
927
928                } else {
929                
930                    /* ------------------- adjust the position of menu correctly */
931                    var dropdown_width = ul.outerWidth(),
932                        translateX = dropdown_width/2 - li.outerWidth()/2 - 30, // the ideal one, 60 is a small factor
933                        li_away_left = li.offset().left - outerContainerLeft,
934                        li_away_right = outerContainerWidth - ( li_away_left + li.outerWidth() )
935
936                    // this means it's way too left, so don't translate left too much
937                    if ( li_away_left < translateX ) {
938                        translateX = li_away_left - 40
939                    
940                    // this means it's way too right, so we translate left as much as we can
941                    } else if ( li_away_right < translateX ) {
942                        translateX = dropdown_width - ( outerContainerWidth - li_away_left ) + 40
943                    }
944
945                }
946
947                ul.css({
948                    transform: 'translate(-' + translateX + 'px,0)',
949                })
950
951                // only show up after loading
952                li.addClass( 'mega-loaded' )
953
954            })
955        }, 200 );
956        setup_position()
957        $( window ).on( 'resize', setup_position )
958    }
959
960    $( '.mainnav, .header-builder .widget_nav_menu, .el-nav.hnav > .nav-inner' ).each(function(){
961        setup_mega( $( this ) )
962    })
963    
964}
965
966/* SHARE
967==========================================================================================  */
968var run_share = function( selector = null ) {
969    var Config = {
970        Width: 800,
971        Height: 600
972    };
973
974    $( '.share56 a' ).on( 'click', function( e ) {
975        if ( $( this ).parent().hasClass( 'li-share' ) ) {
976            return
977        }
978        // popup position
979        var a = $( this ),
980            px = Math.floor(((screen.availWidth || 1024) - Config.Width) / 2),
981            py = Math.floor(((screen.availHeight || 700) - Config.Height) / 2);
982        
983        if ( ! a.attr( 'href')) {
984            return;
985        }
986        // open popup
987        var popup = null;
988        if(a.parent().attr('class') == "li-email") {
989            window.location.href = a.attr('href');
990        } 
991        else { 
992            popup = window.open(a.attr('href'), "social", 
993                "width="+Config.Width+",height="+Config.Height+
994                ",left="+px+",top="+py+
995                ",location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1");
996            if (popup) {
997                popup.focus();
998                e.preventDefault()
999                e.returnValue = false;
1000            }
1001        }
1002    
1003        return !!popup;
1004    });
1005}
1006
1007/* AUTHOR BOX
1008==========================================================================================  */
1009var run_authorbox = function( selector = null ) {
1010    
1011    $( '.authorbox56__tabs a' ).on( 'click', function( e ) {
1012        e.preventDefault();
1013        
1014        var btn = $( this ),
1015            tabs = btn.parent(),
1016            tab = btn.data('tab'),
1017            box = btn.closest( '.authorbox56' )
1018        
1019        if ( ! tabs.length || ! box.length ) {
1020            return;
1021        }
1022        tabs.find( 'a' ).removeClass( 'active' )
1023        btn.addClass( 'active' )
1024        
1025        // content active
1026        box.find( '.authorbox56__content' ).removeClass( 'active' );
1027        box.find( '.authorbox56__content[data-tab="' + tab + '"]' ).addClass( 'active' );
1028    });
1029}
1030
1031/* FITVIDS
1032==========================================================================================  */
1033jQuery( document ).ready(function( $ ) {
1034    if ( ! $().fitVids ) {
1035        return;
1036    }
1037
1038    // $( document, '.media-container' ).fitVids();
1039});
1040
1041/* FINAL INIT
1042==========================================================================================  */
1043$( document ).ready(function($) {
1044    run_lightbox();
1045    run_masonry();
1046    run_carousel();
1047    run_sticky_sidebar();
1048    run_header_mega();
1049    run_minimal_header_sticky();
1050    run_share();
1051    run_authorbox();
1052});
1053$( document ).on( 'partial-refresh', function( e, partial_id, selector_str ) {
1054    var selector = $( selector_str )
1055    if ( selector.length ) {
1056        run_masonry( selector )
1057        run_carousel( selector );
1058        run_sticky_sidebar( selector )
1059        run_header_mega( selector )
1060        run_minimal_header_sticky( selector )
1061        run_share( selector )
1062        run_authorbox( selector );
1063        run_lightbox( selector );
1064    }
1065});
1066
1067$( document ).on( 'fox_section_update', function( e, selector ) {
1068    if ( ! selector.length ) {
1069        return
1070    }
1071    console.log( selector.attr( 'class' ) )
1072    run_masonry( selector )
1073    run_carousel( selector );
1074    run_sticky_sidebar( selector )
1075});
1076
1077jQuery( window ).on( 'elementor/frontend/init', function() {
1078    elementorFrontend.hooks.addAction( 'frontend/element_ready/fox_nav.default', function( $scope, $ ) {
1079        run_header_mega()
1080    })
1081})
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096jQuery.event.special.touchstart = {
1097    setup: function( _, ns, handle ) {
1098        this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") });
1099    }
1100};
1101jQuery.event.special.touchmove = {
1102    setup: function( _, ns, handle ) {
1103        this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") });
1104    }
1105};
1106jQuery.event.special.wheel = {
1107    setup: function( _, ns, handle ){
1108        this.addEventListener("wheel", handle, { passive: true });
1109    }
1110};
1111jQuery.event.special.mousewheel = {
1112    setup: function( _, ns, handle ){
1113        this.addEventListener("mousewheel", handle, { passive: true });
1114    }
1115};
1116
1117$( document ).ready(function(){
1118    /* -------------------  close by esc key */
1119    $( document ).on( 'keydown', function( e ) {
1120        // ESCAPE key pressed
1121        if (e.keyCode !== 27) {
1122            return
1123        }
1124        if ( $( '.search-wrapper-classic' ).length ) {
1125            classic_search_close()
1126        }
1127        modal_search_close()
1128
1129        // close off canvas
1130        $( 'html' ).removeClass( 'on-offcanvas' )
1131    });
1132
1133    // Make sure the Inline-CSS elements are in the correct order. They are at the TOP.
1134    $('link[rel="profile"]').after( $('#classic-theme-styles-inline-css'), $('#global-styles-inline-css'), $("#fox-above-inline-css") );
1135})
1136
1137
1138$( document ).ready( function() {
1139    $( '.post56.format-video .thumbnail56.youtube-thumbnail' ).each(function() {
1140        let $figure = $( this ),
1141            youtube_id = $figure.data( 'youtube_id' ),
1142            trigger_method = $figure.data( 'video_trigger' )
1143
1144        let run = function() {
1145            if ( $figure.hasClass( 'iframe-inserted' ) ) {
1146                return
1147            }
1148            let iframe = document.createElement( "iframe" );
1149            iframe.setAttribute("src", `https://www.youtube.com/embed/${youtube_id}?autoplay=1&mute=1`);
1150            iframe.setAttribute("frameborder", "0");
1151            iframe.setAttribute("allow", "autoplay; encrypted-media");
1152            iframe.setAttribute("allowfullscreen", "");
1153            iframe.style.width = "100%";
1154            iframe.style.height = "100%";
1155
1156            if ( ! $figure.find( 'iframe' ).length ) {
1157                $figure.append( iframe )
1158                $figure.addClass( 'iframe-inserted' )
1159            }
1160        }
1161            
1162        if ( 'click' == trigger_method ) {
1163            $figure.on( 'click', function( e ) {
1164                e.preventDefault()
1165                run()
1166            })
1167        } else {
1168            $figure.on( 'mouseenter', function( e ) {
1169                run()
1170            })
1171        }
1172    })
1173})

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.