PageSourceSearch

https://www.gbsweb.it/wp-content/themes/betheme/js/scripts.js

js gbsweb.it collected 2026-10-04 11:07:08 UTC 133,985 bytes, 4,902 lines download raw bytes

1/* globals jQuery, mfn */
2/* jshint esversion: 6 */
3
4/**
5 * query loop masonry - prevents error with init in iframe
6 */
7
8function queryLoopMasonry() {
9  jQuery('.mfn-query-loop-masonry').each(function() {
10
11    let $masonry = jQuery(this);
12
13    $masonry.imagesLoaded(function() {
14
15      $masonry.isotope({
16        itemSelector: '.mfn-queryloop-item-wrapper',
17        layoutMode: 'masonry',
18        isOriginLeft: jQuery('body').hasClass('rtl') ? false : true
19      });
20
21      $masonry.addClass('mfn-initialized');
22
23    });
24
25  });
26}
27
28(function($) {
29
30  "use strict";
31
32  var scrollTicker, lightboxAttr, sidebar,
33    rtl = $('body').hasClass('rtl'),
34    simple = $('body').hasClass('style-simple'),
35    isBlocks = $('body').hasClass('builder-blocks'),
36    topBarTop = '0',
37    headerH = 0,
38    currWidth = $(window).width(),
39    newWidth = $(window).width(),
40    screen = 'desktop',
41    mobileInitW = mfn.mobileInit ? mfn.mobileInit : 1240;
42
43  /**
44   * Lightbox | Magnific Popup
45   */
46
47  if ( ! mfn.lightbox.disable ) {
48    if ( ! ( mfn.lightbox.disableMobile && ( window.innerWidth < 768 ) ) ) {
49      lightboxAttr = {
50        title: mfn.lightbox.title ? mfn.lightbox.title : false,
51      };
52    }
53  }
54
55  /**
56   * Admin Bar & WooCommerce Store Notice
57   */
58
59  function adminBarH() {
60
61    var height = 0;
62
63    // WP adminbar
64
65    if ($('body').hasClass('admin-bar')) {
66      var actionBarH = $('#wpadminbar').innerHeight() || 0;
67      height += actionBarH;
68    }
69
70    // WC demo store
71
72    if ($('body').hasClass('woocommerce-demo-store')) {
73      var demoStoreH = $('body > p.demo_store').innerHeight() || 0;
74      height += demoStoreH;
75    }
76
77    return height;
78  }
79
80  /**
81   * Header | Sticky
82   */
83
84  function mfnSticky() {
85
86    if( ! $('body').hasClass('sticky-header') ){
87      return false;
88    }
89
90    if( $('body').hasClass('header-creative') && window.innerWidth >= 768 ){
91      return false;
92    }
93
94    var startY = headerH;
95    var windowY = $(window).scrollTop();
96    var topBarH = $('#Top_bar').height() || 0;
97
98    if ( windowY > startY ) {
99
100      if ( ! ( $('#Top_bar').hasClass('is-sticky') ) ) {
101
102        $('.header_placeholder').css('height', topBarH);
103
104        $('#Top_bar')
105          .addClass('is-sticky')
106          .css('top', -60)
107          .animate({
108            'top': adminBarH() + 'px'
109          }, 300);
110
111        headerWidth();
112
113        $(document).trigger('mfn:header:sticky:on');
114      }
115
116    } else {
117
118      if ($('#Top_bar').hasClass('is-sticky')) {
119
120        $('.header_placeholder').css('height', 0);
121        $('#Top_bar')
122          .removeClass('is-sticky')
123          .css('top', topBarTop);
124
125        stickyLogo();
126        headerWidth();
127
128        $(document).trigger('mfn:header:sticky:off');
129
130      }
131
132    }
133
134  }
135
136  /**
137   * Header | Sticky | Retina Logo - max height
138   */
139
140  function stickyLogo() {
141
142    // ! retina display
143
144    if( window.devicePixelRatio <= 1 ){
145      return false;
146    }
147
148    var parent = $('#Top_bar #logo'),
149      el = $('img.logo-main', parent),
150      height = el.data('height');
151
152    // ! retina logo set
153    if ( ! parent.hasClass('retina')) {
154      return false;
155    }
156
157    if ( $('body').hasClass('logo-overflow') ) {
158      // do nothing
159    } else if ( height > parent.data('height') ) {
160      height = parent.data('height');
161    }
162
163    el.css('max-height', height + 'px');
164
165  }
166
167  /**
168   * Header | Sticky | Height
169   */
170
171  function mfnStickyH() {
172
173    var topBarH = $('#Top_bar').innerHeight() || 0;
174
175    if ( $('body').hasClass('header-below') ) {
176
177      // header below slider
178
179      var sliderH = $('.mfn-main-slider').innerHeight() || 0;
180
181      headerH = topBarH + sliderH;
182
183    } else {
184
185      // default
186
187      var actionBarH = $('#Action_bar').innerHeight() || 0;
188
189      headerH = topBarH + actionBarH;
190
191    }
192
193  }
194
195  /**
196   * Header | Sticky | Mobile
197   */
198
199  function mfnMobileSticky() {
200
201    if( ! $('body').hasClass('.mobile-sticky') ){
202      return false;
203    }
204
205    if( $(window).width() >= 768 ){
206      return false;
207    }
208
209    var menuH,
210      windowH = $(window).height() || 0,
211      logoH = $('#Top_bar .logo').height() || 0,
212      offset = adminBarH() + logoH;
213
214    if ( ( ! $('#Top_bar').hasClass('is-sticky')) && $('#Action_bar').is(':visible') ) {
215      offset += $('#Action_bar').height() || 0;
216    }
217
218    menuH = windowH - offset;
219
220    if (menuH < 176) {
221      menuH = 176;
222    }
223
224    $('#Top_bar #menu').css('max-height', menuH + 'px');
225
226  }
227
228  /**
229   * Header | Top bar left | Width
230   */
231
232  function headerWidth() {
233
234    var rightW = $('.top_bar_right').outerWidth() || 0;
235
236    rightW = Math.ceil( rightW );
237
238    if( $('body').hasClass('header-modern') ){
239      rightW += 10;
240    }
241
242    var parentW = $('#Top_bar .one').width() || 0;
243    var leftW = parentW - rightW;
244
245  }
246
247  /**
248   * FIX | Header | Sticky | Height
249   */
250
251  function fixStickyHeaderH() {
252
253    var stickyH = 0;
254
255    // FIX | sticky top bar height
256
257    var topBar = $('.sticky-header #Top_bar');
258
259    if( topBar.length ){
260
261      // default headers
262
263      if (topBar.hasClass('is-sticky')) {
264        stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
265      } else {
266        topBar.addClass('is-sticky');
267        stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
268        topBar.removeClass('is-sticky');
269      }
270
271    } else if( $('.mfn-header-tmpl-builder').length ) {
272
273      var height = 15;
274      var shift = 0;
275
276      if( $('#mfn-header-template').hasClass('mfn-hasSticky') ){
277        height = $('#mfn-header-template').outerHeight();
278        shift = parseFloat($('#mfn-header-template').css('top'));
279      }else if( $('#mfn-header-template').hasClass('mfn-header-tmpl-fixed') ){
280        height = $('#mfn-header-template').outerHeight();
281        shift = parseFloat($('#mfn-header-template').css('top'));
282      }
283
284      stickyH = height + shift;
285
286    }
287
288    // FIX | responsive
289
290    if ( $(window).width() < mobileInitW ) {
291
292      if ( $(window).width() < 768 ) {
293
294        // mobile
295        if (!$('body').hasClass('mobile-sticky')) {
296          stickyH = 0;
297        }
298
299      } else {
300
301        // tablet
302        if (!$('body').hasClass('tablet-sticky')) {
303          stickyH = 0;
304        }
305
306      }
307
308    } else {
309
310      // desktop
311
312      // FIX | header creative
313      if ($('body').hasClass('header-creative')) {
314        stickyH = 0;
315      }
316
317    }
318
319    return stickyH;
320  }
321
322  /**
323   * Sidebar | Height
324   */
325
326  function mfnSidebar() {
327    if ($('.mcb-sidebar').length) {
328
329      var maxH = $('#Content .sections_group').outerHeight();
330
331      $('.mcb-sidebar').each(function() {
332        $(this).css('min-height', 0);
333        if ($(this).height() > maxH) {
334          maxH = $(this).height();
335        }
336      });
337
338      $('.mcb-sidebar').css('min-height', maxH + 'px');
339
340      if( sidebar ){
341        sidebar.stickySidebar('updateSticky');
342      }
343
344    }
345  }
346
347
348  /**
349   * Into | Full Screen
350   */
351
352  function mfnIntroH() {
353
354    var windowH = $(window).height() || 0;
355    var headerWrapperH = $('#Header_wrapper').height() || 0;
356
357    windowH = windowH - headerWrapperH - adminBarH();
358
359    $('#Intro.full-screen').each(function() {
360
361      var el = $(this),
362        inner = $('.intro-inner', el),
363        innerH = inner.height() || 0;
364
365      el.css('padding', 0).css('min-height', windowH);
366
367      var padding = ( windowH - innerH ) / 2;
368      inner.css('padding-top', padding).css('padding-bottom', padding);
369
370    });
371  }
372
373  /**
374   * Footer | Sliding | Height
375   */
376
377  function mfnFooter() {
378
379    var footerH = $('#Footer').height() || 0;
380
381    // Fixed, Sliding
382
383    if ($('.footer-fixed #Footer, .footer-sliding #Footer').length) {
384
385      footerH = footerH - 1;
386      $('#Content').css('margin-bottom', footerH + 'px');
387
388    }
389
390    // Stick to bottom
391
392    if ($('.footer-stick #Footer').length) {
393
394      var headerWrapperH = $('#Header_wrapper').height() || 0;
395
396      var headerFooterH = headerWrapperH + footerH;
397
398      var documentH = $(document).height() - adminBarH();
399
400      if ( ( documentH <= $(window).height() ) && ( headerFooterH <= $(window).height() ) ) {
401        $('#Footer').addClass('is-sticky');
402      } else {
403        $('#Footer').removeClass('is-sticky');
404      }
405
406    }
407
408  }
409
410  /**
411   * Back To Top | Sticky / Show on scroll
412   */
413
414  function backToTopSticky() {
415
416    if ($('#back_to_top.sticky.scroll').length) {
417      var el = $('#back_to_top.sticky.scroll');
418
419      // Clear Timeout if one is pending
420      if (scrollTicker) {
421        window.clearTimeout(scrollTicker);
422        scrollTicker = null;
423      }
424
425      el.addClass('focus');
426
427      // Set Timeout
428      scrollTicker = window.setTimeout(function() {
429        el.removeClass('focus');
430      }, 1500); // Timeout in msec
431
432    }
433
434  }
435
436  /**
437   * # Hash smooth navigation
438   */
439
440  function hashNav() {
441
442    var hash = window.location.hash;
443
444    if (hash) {
445
446      // FIX | Master Slider
447
448      if (hash.indexOf("&") > -1 || hash.indexOf("/") > -1 || hash.indexOf("?") > -1) {
449        return false;
450      }
451
452      // Contact Form 7 in popup
453
454      if (hash.indexOf("wpcf7") > -1) {
455        cf7popup(hash);
456      }
457
458      if ($(hash).length) {
459
460        $(window).scrollTop(0, 0);
461
462        setTimeout(function() {
463
464          var offset = 0,
465            headerH = fixStickyHeaderH(),
466            tabH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
467
468          // header builder
469
470          if( $('body').hasClass('mhb') ){
471
472            var currentView = $('.mhb-view').filter(':visible');
473            headerH = currentView.height() || 0;
474
475          }
476
477          offset = headerH + adminBarH() + tabH;
478
479          $('html, body').animate({
480            scrollTop: $(hash).offset().top - offset
481          }, 500);
482
483        }, 500);
484
485      }
486
487
488    }
489
490  }
491
492  /**
493   * One Page | Scroll Active
494   */
495
496  function onePageActive() {
497    if ($('body').hasClass('one-page')) {
498
499      var stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
500      if( $('#mfn-header-template').length ) stickyH = $('#mfn-header-template').innerHeight() || 0;
501      var windowT = $(window).scrollTop();
502      var start = windowT + stickyH + adminBarH() + 1;
503      var first = false;
504
505      $('[data-id]:not(.elementor-element), section[data-id]').each(function() {
506
507        // FIX | elementor adds own data-id for each section
508
509        if( $(this).attr('data-id') && ( -1 == $(this).attr('data-id').indexOf('#') ) ){
510          return true;
511        }
512
513        if ($(this).visible(true)) {
514
515          if (!first) {
516            first = $(this);
517          } else if (($(this).offset().top < start) && ($(this).offset().top > first.offset().top)) {
518            first = $(this);
519          }
520        }
521
522        if (first) {
523
524          var newActive = first.attr('data-id');
525          var active = '[data-hash="' + newActive + '"]';
526
527          if (newActive) {
528            var menu = $('#menu, .mhb-menu');
529            if( $('#mfn-header-template').length ) menu = $('#mfn-header-template .mfn-header-menu');
530            menu.find('li').removeClass('current-menu-item current-menu-parent current-menu-ancestor current_page_item current_page_parent current_page_ancestor');
531            $(active, menu)
532              .closest('li').addClass('current-menu-item')
533              .closest('.menu > li').addClass('current-menu-item');
534          }
535
536        }
537
538      });
539
540    }
541  }
542
543  /**
544   * Contact Form 7 | Popup
545   */
546
547  function cf7popup(hash) {
548    if (hash && $(hash).length) {
549      var id = $(hash).closest('.popup-content').attr('id');
550
551      $('a.popup-link[href="#' + id + '"]:not(.once)')
552        .addClass('once')
553        .trigger('click');
554
555    }
556  }
557
558  /**
559   * Sticky | Wrap
560   */
561
562  var stickyWrap = {
563
564    headerH: 0,
565
566    // stickyWrap.init()
567
568    init: function(){
569
570      if( isBlocks ){
571        return;
572      }
573
574      // calculate
575
576      stickyWrap.headerH = fixStickyHeaderH() + adminBarH();
577
578      // prepare dom
579
580      $('.mcb-wrap.sticky.sticky-'+screen+':not(.stickied)').each(function(){
581
582        var $wrap = $(this);
583
584        if( screen == 'desktop' && $wrap.hasClass('one') ) return;
585        if( screen == 'tablet' && $wrap.hasClass('tablet-one') ) return;
586        if( screen == 'mobile' && $wrap.hasClass('mobile-one') ) return;
587
588        if( screen == 'desktop' && typeof $wrap.attr('data-stickyoffset') !== 'undefined' ) stickyWrap.headerH = parseInt( $wrap.attr('data-stickyoffset') );
589        if( screen == 'tablet' && typeof $wrap.attr('data-stickyoffsettablet') !== 'undefined' ) stickyWrap.headerH = parseInt( $wrap.attr('data-stickyoffsettablet') );
590        if( screen == 'mobile' && typeof $wrap.attr('data-stickyoffsetmobile') !== 'undefined' ) stickyWrap.headerH = parseInt( $wrap.attr('data-stickyoffsetmobile') );
591
592        var size = $wrap.attr('data-'+screen+'-col'),
593          padding = {
594            top : $wrap.css('padding-top'),
595            right : $wrap.css('padding-right'),
596            bottom : $wrap.css('padding-bottom'),
597            left : $wrap.css('padding-left'),
598          };
599
600        padding = Object.values(padding).join(' ');
601
602        $wrap.css('padding', padding);
603
604        $wrap.addClass('stickied').removeClass(size).addClass('one')
605        .wrap(function() {
606          return '<div class="mcb-wrap wrap-sticky-spacer ' + size + '"><div class="mcb-wrap wrap-sticky-rails"></div></div>';
607        });
608
609      });
610
611      // initial scroll
612
613      stickyWrap.scroll();
614
615    },
616
617    // stickyWrap.scroll()
618
619    scroll: function(){
620
621      if( ! $('.mcb-wrap.sticky.sticky-'+screen).length ){
622        return;
623      }
624
625      var windowY = $(window).scrollTop();
626
627      $('.mcb-wrap.sticky.sticky-'+screen+'.stickied').each(function(){
628
629        var $wrap = $(this),
630          $rails = $wrap.closest('.wrap-sticky-rails'),
631          $section = $wrap.closest('.mcb-section-inner');
632
633        var width = $rails.width() || 0,
634          sectionT = $section.offset().top,
635          sectionH = $section.innerHeight(),
636          wrapH = $wrap.outerHeight();
637
638        var start = windowY + stickyWrap.headerH - sectionT,
639          limit = start + wrapH - sectionH;
640
641        $wrap.css( 'width', width )
642          .closest('.wrap-sticky-rails').css('min-height', sectionH + 'px');
643
644        if( limit > 0 ){
645
646          $wrap.removeClass('fixed').addClass('stick-bottom').css({
647            'top' : ''
648          });
649
650        } else {
651
652          $wrap.removeClass( 'stick-bottom' );
653
654          if( start > 0 ){
655            $wrap.addClass('fixed').css({
656              'top' : stickyWrap.headerH + 'px'
657            });
658          } else {
659            $wrap.removeClass('fixed').css({
660              'top' : ''
661            });
662          }
663
664        }
665
666      });
667
668    },
669
670    reset: function() {
671      // stickyWrap.reset()
672
673      if( $('.wrap-sticky-spacer').length ){
674        $('.wrap-sticky-spacer').each(function() {
675          $(this).find('.mcb-wrap.sticky').removeClass('stickied one fixed').addClass( $(this).find('.mcb-wrap.sticky').attr('data-'+screen+'-col') ).css({'top': '0', 'width': ''});
676          $(this).replaceWith( $(this).find('.mcb-wrap.sticky') );
677        });
678      }
679
680      if( $('.mcb-wrap.sticky.sticky-'+screen+':not(.stickied)').length ){
681        stickyWrap.init();
682      }
683
684    }
685
686  };
687
688  /**
689   * $(document).mfnPopupInit
690   * init js plugins on popup open
691   */
692
693  $(document).on('mfnPopupInit', function() {
694
695    // chart
696
697    if( $('.mfn-popup-tmpl.mfn-popup-active .chart:not(.mfn-initialized)').length ){
698      $('.mfn-popup-tmpl.mfn-popup-active .chart:not(.mfn-initialized)').each(function() {
699          var lineW = simple ? 4 : 8;
700          $(this).addClass('mfn-initialized');
701          $(this).easyPieChart({
702            animate: 1000,
703            lineCap: 'circle',
704            lineWidth: lineW,
705            size: 140,
706            scaleColor: false
707          });
708
709      });
710    }
711
712    // before after
713
714    if( $('.mfn-popup-tmpl.mfn-popup-active .before_after.twentytwenty-container:not(.mfn-initialized)').length ){
715
716      $('.mfn-popup-tmpl.mfn-popup-active .before_after.twentytwenty-container:not(.mfn-initialized)').each(function(){
717
718        var el = $(this);
719        el.addClass('mfn-initialized');
720        el.imagesLoaded().done(function(instance, image){
721          queueMicrotask(() => el.twentytwenty());
722        });
723
724      });
725    }
726
727    // countdown
728
729    if( $('.mfn-popup-tmpl.mfn-popup-active .downcount:not(.mfn-initialized)').length ){
730      $('.mfn-popup-tmpl.mfn-popup-active .downcount:not(.mfn-initialized)').each(function() {
731        var el = $(this);
732        el.addClass('mfn-initialized');
733        el.downCount({
734          date: el.attr('data-date'),
735          offset: el.attr('data-offset')
736        });
737      });
738    }
739
740    // counter
741
742    if( $('.mfn-popup-tmpl.mfn-popup-active .animate-math .number:not(.mfn-initialized)').length ){
743      $('.mfn-popup-tmpl.mfn-popup-active .animate-math .number:not(.mfn-initialized)').each(function() {
744
745        var el = $(this);
746        var duration = Math.floor((Math.random() * 1000) + 1000);
747        var to = el.attr('data-to');
748
749        el.addClass('mfn-initialized');
750
751        $({
752          property: 0
753        }).animate({
754          property: to
755        }, {
756          duration: duration,
757          easing: 'linear',
758          step: function() {
759            el.text(Math.floor(this.property));
760          },
761          complete: function() {
762            el.text(this.property);
763          }
764        });
765
766      });
767    }
768
769  });
770
771  /**
772   * $(document).ready
773   * Specify a function to execute when the DOM is fully loaded.
774   */
775
776  $(document).ready(function() {
777
778    /**
779     *
780     * WPML language switcher
781     *
782     * */
783
784    if( $('.mfn-language-switcher-dropdown:not(.mfn-initialized)').length ) {
785      $('.mfn-language-switcher-dropdown:not(.mfn-initialized)').each(function() {
786        let that = $(this);
787        that.addClass('mfn-initialized');
788
789        let $ul = that.find('ul');
790        let $current = $ul.find('li.wpml-ls-current-language');
791
792        $current.append($ul.clone());
793
794        $ul.children('li:not(.wpml-ls-current-language)').remove();
795
796        $current.find('ul li.wpml-ls-current-language').remove();
797
798        if( that.hasClass('mfn-language-switcher-dropdown-icon') ){
799          let icon_html = '';
800          if( that.attr('data-icon') == 'image' ){
801            icon_html = '<span class="mfn-arrow-icon"><img src="'+that.attr('data-path')+'" alt=""></span>';
802          }else if( that.attr('data-icon') == 'icon' ){
803            icon_html = '<span class="mfn-arrow-icon"><i class="'+that.attr('data-path')+'"></i></span>';
804          }
805
806          $current.children('a').append(icon_html);
807        }
808
809      });
810    }
811
812    /**
813     * Isotope
814    */
815
816    class Isotope {
817      constructor(){
818        this.runIsotopes = this.runIsotopes.bind(this);
819        this.itemToModify = {};
820        this.ajaxObjects = [];
821      }
822
823      get getList() {
824        return [
825          {
826            name: 'Portfolio - Isotope',
827            location: '.blog_wrapper .isotope:not( .masonry ), .portfolio_wrapper .isotope:not( .masonry-flat, .masonry-hover, .masonry-minimal )',
828            beforeActive: () => null,
829            afterActive: () => null,
830            settings: {
831              itemSelector: '.isotope-item',
832              layoutMode: 'fitRows',
833              isOriginLeft: rtl ? false : true
834            }
835          },
836          {
837            name: 'Portfolio - Masonry Flat',
838            location: '.portfolio_wrapper .masonry-flat',
839            beforeActive: () => null,
840            afterActive: () => null,
841            settings: {
842              itemSelector: '.isotope-item',
843              percentPosition: true,
844              masonry: { columnWidth: 1 },
845              isOriginLeft: rtl ? false : true
846            }
847          },
848          {
849            name: 'Blog & Portfolio & Shop - Masonry',
850            location: '.isotope.masonry, .isotope.masonry-hover, .isotope.masonry-minimal',
851            beforeActive: () => null,
852            afterActive: () => null,
853            settings: {
854              itemSelector: '.isotope-item',
855              layoutMode: 'masonry',
856              isOriginLeft: rtl ? false : true
857            }
858          },
859          /*{
860            name: 'General - Masonry Isotope',
861            location: '.masonry.isotope, .masonry.gallery',
862            beforeActive: () => null,
863            afterActive: () => null,
864            settings: {}
865          },
866          {
867            name: 'General - Isotope',
868            location: '.isotope',
869            beforeActive: () => null,
870            afterActive: () => null,
871            settings: {},
872          },*/
873          {
874            name: 'Filters - Isotope Event on Click',
875            location: '.isotope-filters .filters_wrapper',
876            beforeActive: () => null,
877            afterActive: ({location}) => {
878              const filterButtons = $(location).find('li:not(.close) a');
879              filterButtons.on('click', (e) => {
880                e.preventDefault();
881                const buttonClicked = $(e.target);
882
883                let isoWrapper = $('.isotope'),
884                    filters = buttonClicked.closest('.isotope-filters'),
885                    parent = filters.attr('data-parent');
886
887                if (parent) {
888                  parent = filters.closest('.' + parent);
889                  isoWrapper = parent.find('.isotope').first();
890                }
891
892                filters.find('li').removeClass('current-cat');
893                buttonClicked.closest('li').addClass('current-cat');
894
895                // $('.isotope-filters .filters_wrapper').find('li').removeClass('current-cat');
896                this.isotopeFilter(buttonClicked, isoWrapper);
897              })
898            },
899            settings: 'do-not-run'
900          },
901          ...this.ajaxObjects //dynamical loaded content, like load more.
902        ]
903      }
904
905      // One liners, queries to isotope API
906      addEventListener(onEvent, doWhat) {
907        return $(document).on( `isotope:${onEvent}`, doWhat)
908      }
909      queryIsotopeAPI(location, apiAction, actionToPass) {
910        return $(location).isotope(apiAction, actionToPass);
911      };
912      triggerIsotopeEvent(doWhat) {
913        return $(document).trigger(`isotope:${doWhat}`)
914      }
915
916      // Add elements which require isotope and are loaded on the fly
917      addIsotopeLocation( payload ) {
918        if ( !payload.location ) return console.error('MfnIsotope Error: No Location Provided!');
919
920        // Push it to object
921        this.ajaxObjects.push(
922          {
923            name: payload.name ? payload.name : 'No name applied - Dynamic Isotope Function',
924            location: payload.location,
925            beforeActive: payload.beforeActive ? payload.beforeActive : () => null,
926            afterActive: payload.afterActive ? payload.afterActive : () => null,
927            settings: payload.settings ? payload.settings : {}
928          }
929        );
930
931        // Reload it anyway while using that option
932        $( payload.location ).isotope( payload.settings )
933      }
934
935      isotopeFilter( domEl, isoWrapper ) {
936        if( !domEl || !isoWrapper ) return console.error('MfnIsotope Error: isotopeFilter, missing one of the values!');
937        const filter = domEl.attr('data-rel');
938
939        isoWrapper.isotope({ filter });
940
941        queueMicrotask(() => $(window).trigger('resize'));
942
943        setTimeout(function() {
944          mfnIsotope.triggerIsotopeEvent('arrange');
945        }, 500);
946      }
947
948      // Usually for init, turn on all of the isotopes!
949      runIsotopes( resize = true ) {
950        const isotopeList = this.getList;
951
952        //console.log(isotopeList);
953
954        isotopeList.map(item => {
955          //console.log(jQuery(item.location));
956          if( $(item.location).length ) {
957            // HOOK, before isotope binding
958            item.beforeActive(item)
959
960            // Trigger resize to recalculate some plugins stuff
961            if( resize ){
962                $(window).trigger('resize');
963            }
964
965            // Isotope init
966            if( 'do-not-run' !== item.settings ){
967              queueMicrotask(() => $( item.location ).isotope( item.settings ));
968            }
969
970            // HOOK, after isotope binding
971            item.afterActive(item);
972          }
973        });
974      }
975    }
976
977    const mfnIsotope = new Isotope;
978    mfnIsotope.runIsotopes();
979
980    /**
981     * Waypoints
982    */
983
984    class Waypoints {
985      constructor(){
986        this.runWaypoints = this.runWaypoints.bind(this);
987      }
988
989      get getList() {
990        return [
991          {
992            name: 'Chart',
993            location: '.sections_group .chart, .elementor-section .chart',
994            beforeActive: () => {},
995            afterActive: () => {},
996            settings: () => {
997              return {
998                offset: '100%',
999                triggerOnce: true,
1000                handler: function(){
1001                  var el = $(this.element).length ? $(this.element) : $(this);
1002                  var lineW = simple ? 4 : 8;
1003
1004                  el.easyPieChart({
1005                    animate: 1000,
1006                    lineCap: 'circle',
1007                    lineWidth: lineW,
1008                    size: 140,
1009                    scaleColor: false
1010                  });
1011
1012                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1013                    this.destroy();
1014                  }
1015                }
1016              }
1017            }
1018          },
1019          {
1020            name: 'Progress Icons',
1021            location: '.progress_icons',
1022            beforeActive: () => {},
1023            afterActive: () => {},
1024            settings: () => {
1025              return {
1026                offset: '100%',
1027                triggerOnce: true,
1028                handler: function() {
1029                  var el = $(this.element).length ? $(this.element) : $(this);
1030                  var active = el.attr('data-active');
1031                  var color = el.attr('data-color');
1032                  var transparent = el.hasClass('transparent');
1033                  var icon = el.find('.progress_icon');
1034                  var timeout = 200; // timeout in milliseconds
1035
1036                  icon.each(function(i) {
1037                    if (i < active) {
1038                      var time = (i + 1) * timeout;
1039                      setTimeout(function() {
1040
1041                        $(icon[i]).addClass('themebg');
1042
1043                        if( transparent ){
1044                          $(icon[i]).css('color', color);
1045                        } else {
1046                          $(icon[i]).css('background-color', color);
1047                        }
1048
1049                      }, time);
1050                    }
1051                  });
1052
1053                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1054                    this.destroy();
1055                  }
1056                }
1057              }
1058            }
1059          },
1060          {
1061            name: 'Animate Math | Counter, Quick Fact, etc.',
1062            location: '#Wrapper .animate-math .number',
1063            beforeActive: () => {},
1064            afterActive: () => {},
1065            settings: () => {
1066              return {
1067                offset: '100%',
1068                triggerOnce: true,
1069                handler: function() {
1070                  var el = $(this.element).length ? $(this.element) : $(this);
1071                  var duration = Math.floor((Math.random() * 1000) + 1000);
1072                  var to = el.attr('data-to');
1073
1074                  $({
1075                    property: 0
1076                  }).animate({
1077                    property: to
1078                  }, {
1079                    duration: duration,
1080                    easing: 'linear',
1081                    step: function() {
1082                      el.text(Math.floor(this.property));
1083                    },
1084                    complete: function() {
1085                      el.text(this.property);
1086                    }
1087                  });
1088
1089                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1090                    this.destroy();
1091                  }
1092                }
1093              }
1094            }
1095          },
1096          {
1097            name: 'Infinite Scroll | Blog & Portfolio',
1098            location: '.mfn-infinite-load-button',
1099            infiniteLoadButton: $('.mfn-infinite-load-button a'),
1100            beforeActive: () => {},
1101            afterActive: ({infiniteLoadButton}) => {
1102              // Leave it, probably will be necessary soon.
1103              // const itemProvided = $('.column_portfolio').length ? '.column_portfolio' : '.column_blog';
1104
1105              // $(`html, ${itemProvided}`).waypoint({
1106              //   handler: function(direction) {
1107              //     infiniteScrollFunction($(location), infiniteLoadButton, direction);
1108              //   },
1109              //   offset: 'bottom-in-view'
1110              // });
1111            },
1112            settings: ({infiniteLoadButton, location}) => {
1113              return {
1114                handler: function(direction) {
1115                  infiniteScrollFunction($(location), infiniteLoadButton, direction);
1116                },
1117                offset: function(){
1118                  //after each load, calc the offset of element to know when posts should be loaded
1119                  var offsetPosition = - ( ($(this)[0].element.scrollHeight) - (window.innerHeight / 1.2) );
1120                  return offsetPosition;
1121                }
1122              }
1123            }
1124          },
1125          {
1126            name: 'Bars List',
1127            location: '.bars_list',
1128            beforeActive: () => {},
1129            afterActive: ({infiniteLoadButton}) => {},
1130            settings: () => {
1131              return {
1132                offset: '100%',
1133                triggerOnce: true,
1134                handler: function() {
1135
1136                  var el = $(this.element).length ? $(this.element) : $(this);
1137
1138                  el.addClass('hover');
1139
1140                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1141                    this.destroy();
1142                  }
1143                }
1144              }
1145            }
1146          }
1147        ]
1148      }
1149
1150
1151      runWaypoints(){
1152        const waypoints = this.getList;
1153
1154        waypoints.map(item => {
1155          if( $(item.location).length ) {
1156            // HOOK, before waypoints binding
1157            item.beforeActive(item)
1158
1159            // waypoints init
1160            queueMicrotask(() => $(item.location).waypoint(item.settings( item )) );
1161
1162            // HOOK, after waypoints binding
1163            item.afterActive(item);
1164          }
1165        })
1166      }
1167    }
1168
1169    const mfnWaypoints = new Waypoints;
1170          mfnWaypoints.runWaypoints();
1171
1172    /**
1173     * Header template
1174     */
1175
1176    if( $('.promo_bar_slider').length ){
1177      promoBarSlider();
1178    }
1179
1180    if( $('.mfn-looped-items-slider').length ){
1181      queryLoopSlider();
1182    }
1183
1184    headerTemplate.init();
1185    footerTemplate.init();
1186    mfnPopup.init();
1187
1188    if( $('.mfn-menu-item-megamenu').length ){
1189      headerMegamenu.init();
1190    }
1191
1192    $('#Top_bar').removeClass('loading');
1193
1194    // topBarTop = parseInt($('#Top_bar').css('top'), 10);
1195    // if (topBarTop < 0) topBarTop = 61;
1196    // topBarTop = topBarTop + 'px';
1197
1198    /**
1199     * Sticky | Sidebar
1200     */
1201
1202    function sidebarSticky(){
1203
1204      var spacing = fixStickyHeaderH();
1205
1206      if( ! mfn.sidebarSticky ){
1207        return false;
1208      }
1209
1210      if( $('.woocommerce-store-notice').length ){
1211        spacing += $('.woocommerce-store-notice').outerHeight() || 0;
1212      }
1213
1214      sidebar = $('.mcb-sidebar .widget-area').stickySidebar({
1215        topSpacing: spacing
1216      });
1217
1218    }
1219
1220    sidebarSticky();
1221
1222    if( $('.mfn-off-canvas-sidebar').length ){
1223      offCanvasSidebar.init();
1224    }
1225
1226
1227    if( $(window).width() < 767 && !$('.mfn-off-canvas-sidebar').length ){
1228      offCanvasSidebar.mobile();
1229      screen = 'mobile';
1230    }else if($(window).width() < 959){
1231      screen = 'tablet';
1232    }
1233
1234    $(window).on('debouncedresize', function() {
1235
1236      if( $(window).width() < 767 ){
1237        screen = 'mobile';
1238      }else if($(window).width() < 959){
1239        screen = 'tablet';
1240      }else if($(window).width() > 960){
1241        screen = 'desktop';
1242      }
1243
1244      newWidth = $(window).width();
1245
1246      if( newWidth != currWidth ){
1247        currWidth = $(window).width();
1248        headerTemplate.init();
1249        footerTemplate.init();
1250      }
1251
1252      // stickyWrap.reset();
1253
1254      if( $(window).width() < 767 && !$('.mfn-off-canvas-sidebar').length ){
1255        offCanvasSidebar.mobile();
1256      }else{
1257        $('html').removeClass('mfn-ofcs-opened');
1258      }
1259
1260    });
1261
1262    /**
1263     * Menu | Overlay
1264     */
1265
1266    $('.overlay-menu-toggle').on('click',function(e) {
1267      e.preventDefault();
1268
1269      $(this).toggleClass('focus');
1270      $('#Overlay').stop(true, true).fadeToggle(500);
1271
1272      var menuH = $('#Overlay nav').height() || 0;
1273      menuH = menuH / 2;
1274
1275      $('#Overlay nav').css('margin-top', '-' + menuH + 'px');
1276    });
1277
1278    $('#Overlay').on('click', '.menu-item > a', function() {
1279      $('.overlay-menu-toggle').trigger('click');
1280    });
1281
1282    $( '.header-overlay' ).on( 'keydown', function(event) {
1283      if ( 27 == event.keyCode ) {
1284        $('.overlay-menu-toggle.focus').trigger('click');
1285      }
1286    });
1287
1288    /**
1289     * Menu | Responsive | button
1290     */
1291
1292    $('.responsive-menu-toggle').on('click', function(e) {
1293      e.preventDefault();
1294
1295      var el = $(this);
1296      var menu = $('#Top_bar #menu');
1297      var menuWrap = menu.closest('.top_bar_left');
1298
1299      el.toggleClass('active');
1300
1301      // sticky menu button
1302      if (el.hasClass('is-sticky') && el.hasClass('active') && (window.innerWidth < 768)) {
1303
1304        var top = 0;
1305        if (menuWrap.length) {
1306          top = menuWrap.offset().top - adminBarH();
1307        }
1308        $('body,html').animate({
1309          scrollTop: top
1310        }, 200);
1311
1312      }
1313
1314      menu.stop(true, true).slideToggle(200);
1315    });
1316
1317    // close menu after link click
1318
1319    $('#Top_bar #menu').on('click', 'a:not(.menu-toggle)', function(){
1320      var $menuButton = $('.responsive-menu-toggle.active');
1321
1322      if( $menuButton.length ){
1323        setTimeout(function(){
1324          $menuButton.trigger('click');
1325        },300);
1326      }
1327
1328    });
1329
1330
1331    /**
1332     * Menu | Responsive | Side Slide
1333     */
1334
1335    function sideSlide() {
1336
1337      //if( $('body').hasClass('mfn-header-template') ) return;
1338
1339      var slide = $('#Side_slide');
1340      var overlay = $('#body_overlay');
1341      var ssMobileInitW = mobileInitW;
1342      var pos = 'right';
1343
1344      var shiftSlide = -slide.data('width');
1345      var shiftBody = shiftSlide / 2;
1346
1347      // constructor
1348
1349      var constructor = function() {
1350        if (!slide.hasClass('enabled')) {
1351
1352          $('nav#menu').detach().appendTo('#Side_slide .menu_wrapper');
1353          slide.addClass('enabled');
1354
1355        }
1356      };
1357
1358      // destructor
1359
1360      var destructor = function() {
1361        if (slide.hasClass('enabled')) {
1362
1363          close();
1364          $('nav#menu').detach().prependTo('#Top_bar .menu_wrapper');
1365          slide.removeClass('enabled');
1366
1367        }
1368      };
1369
1370      // reload
1371
1372      var reload = function() {
1373
1374        if ( window.innerWidth < ssMobileInitW ) {
1375          constructor();
1376        } else if( $('body').hasClass('header-shop') ) {
1377          if ($('#Top_bar').hasClass('is-sticky')) {
1378            $(document).trigger('mfn:header:sticky:on');
1379          } else {
1380            $(document).trigger('mfn:header:sticky:off');
1381          }
1382        } else {
1383          destructor();
1384        }
1385
1386      };
1387
1388      // init
1389
1390      var init = function() {
1391
1392        if (slide.hasClass('left')) {
1393          pos = 'left';
1394        }
1395
1396        // responsive off
1397        if ($('body').hasClass('responsive-off')) {
1398          ssMobileInitW = 0;
1399        }
1400
1401        // header simple
1402        if ($('body').hasClass('header-simple')) {
1403          ssMobileInitW = 9999;
1404        }
1405
1406        //  header style: shop | top bar is sticky
1407        if ($('#Top_bar').hasClass('is-sticky')) {
1408          $(document).trigger('mfn:header:sticky:on');
1409        }
1410
1411        reload();
1412      };
1413
1414      // reset to default
1415
1416      var reset = function(time) {
1417
1418        $('.lang-active.active', slide).removeClass('active').children('i').attr('class', 'icon-down-open-mini');
1419        $('.lang-wrapper', slide).fadeOut(0);
1420
1421        $('.icon.search.active', slide).removeClass('active');
1422        $('.search-wrapper', slide).fadeOut(0);
1423
1424        $('.menu_wrapper, .social', slide).fadeIn(time);
1425
1426      };
1427
1428      // menu button
1429
1430      var button = function() {
1431
1432        // show
1433
1434        if (pos == 'left') {
1435          slide.animate({
1436            'left': 0
1437          }, 300);
1438          $('body').animate({
1439            'right': shiftBody
1440          }, 300);
1441        } else {
1442          slide.animate({
1443            'right': 0
1444          }, 300);
1445          $('body').animate({
1446            'left': shiftBody
1447          }, 300);
1448        }
1449
1450        overlay.fadeIn(300);
1451
1452        $('body').addClass('side-slide-is-open');
1453
1454        // reset
1455
1456        reset(0);
1457
1458      };
1459
1460      // close
1461
1462      var close = function() {
1463
1464        if (pos == 'left') {
1465          slide.animate({
1466            'left': shiftSlide
1467          }, 300);
1468          $('body').animate({
1469            'right': 0
1470          }, 300);
1471        } else {
1472          slide.animate({
1473            'right': shiftSlide
1474          }, 300);
1475          $('body').animate({
1476            'left': 0
1477          }, 300);
1478        }
1479
1480        overlay.fadeOut(300);
1481
1482        $('body').removeClass('side-slide-is-open');
1483
1484        /* Just to be sure, change aria. */
1485        if ( $('body').hasClass('keyboard-support') ) {
1486          $('#Side_slide').attr('aria-expanded', 'false');
1487        }
1488
1489        // if page contains revolution slider, trigger resize
1490
1491        if ($('.rev_slider').length) {
1492          setTimeout(function() {
1493            $(window).trigger('resize');
1494          }, 300);
1495        }
1496
1497      };
1498
1499      // search
1500
1501      $('.icon.search', slide).on('click', function(e) {
1502
1503        e.preventDefault();
1504
1505        var el = $(this);
1506
1507        if (el.hasClass('active')) {
1508
1509          $('.search-wrapper', slide).fadeOut(0);
1510          $('.menu_wrapper, .social', slide).fadeIn(300);
1511
1512        } else {
1513
1514          $('.search-wrapper', slide).fadeIn(300);
1515          $('.menu_wrapper, .social', slide).fadeOut(0);
1516
1517          $('.lang-active.active', slide).removeClass('active').children('i').attr('class', 'icon-down-open-mini');
1518          $('.lang-wrapper', slide).fadeOut(0);
1519
1520        }
1521
1522        el.toggleClass('active');
1523      });
1524
1525      // search form submit
1526
1527      $('a.submit', slide).on('click', function(e) {
1528        e.preventDefault();
1529        $('#side-form').submit();
1530      });
1531
1532      // lang menu
1533
1534      $('.lang-active', slide).on('click', function(e) {
1535        e.preventDefault();
1536
1537        var el = $(this);
1538
1539        if (el.hasClass('active')) {
1540
1541          $('.lang-wrapper', slide).fadeOut(0);
1542          $('.menu_wrapper, .social', slide).fadeIn(300);
1543          el.children('i').attr('class', 'icon-down-open-mini');
1544
1545        } else {
1546
1547          $('.lang-wrapper', slide).fadeIn(300);
1548          $('.menu_wrapper, .social', slide).fadeOut(0);
1549          el.children('i').attr('class', 'icon-up-open-mini');
1550
1551          $('.icon.search.active', slide).removeClass('active');
1552          $('.search-wrapper', slide).fadeOut(0);
1553
1554        }
1555
1556        el.toggleClass('active');
1557      });
1558
1559      // bind ---
1560
1561      // click | menu button
1562
1563      $('.responsive-menu-toggle').off('click');
1564
1565      $('.responsive-menu-toggle').on('click', function(e) {
1566        e.preventDefault();
1567        button();
1568      });
1569
1570      // click | close
1571
1572      overlay.on('click', function(e) {
1573        close();
1574      });
1575
1576      $('.close', slide).on('click', function(e) {
1577        e.preventDefault();
1578        close();
1579      });
1580
1581      $(slide).on('click', '.menu_wrapper a:not(.menu-toggle), .action_button', function(e) {
1582
1583        if( $(this).hasClass('mega-menu-link') ){
1584          return; // FIX: plugin maxmegamenu
1585        }
1586
1587        if( '#' == $(this).attr('href') ){
1588          e.preventDefault();
1589          return;
1590        }
1591
1592        setTimeout(function(){
1593          close();
1594        },500);
1595
1596      });
1597
1598      // click | below search or languages menu
1599
1600      $(slide).on('click', function(e) {
1601        if ($(e.target).is(slide)) {
1602          reset(300);
1603        }
1604      });
1605
1606      // debouncedresize
1607
1608      $(window).on('debouncedresize', reload);
1609
1610      // header style: shop | sticky
1611
1612      if( $('body').hasClass('header-shop') ){
1613
1614        $(document).on('mfn:header:sticky:on', function(){
1615          if( window.innerWidth >= ssMobileInitW ){
1616            $('#Top_bar .menu_wrapper').css('min-height', '70px');
1617            constructor();
1618          }
1619        });
1620
1621        $(document).on('mfn:header:sticky:off', function(){
1622          if( window.innerWidth >= ssMobileInitW ){
1623            destructor();
1624          }
1625        });
1626
1627      }
1628
1629      // init
1630
1631      init();
1632
1633    }
1634
1635    if ($('body').hasClass('mobile-side-slide')) {
1636      sideSlide();
1637    }
1638
1639    /**
1640     * Gallery | WordPress Gallery
1641     */
1642
1643    // WordPress <= 4.9 | content
1644
1645    $('.sections_group .gallery, .mcb-section .gallery, .elementor-section .gallery').each(function() {
1646
1647      var el = $(this);
1648      var id = el.attr('id');
1649
1650      $('> br', el).remove();
1651
1652      $('.gallery-icon > a', el)
1653        .wrap('<div class="image_frame scale-with-grid"><div class="image_wrapper"></div></div>')
1654        .prepend('<div class="mask"></div>')
1655        .children('img')
1656        .css('height', 'auto')
1657        .css('width', '100%');
1658
1659      // lightbox | link to media file
1660
1661      if (el.hasClass('file')) {
1662        $('.gallery-icon a', el)
1663          .attr('rel', 'prettyphoto[' + id + ']')
1664          .attr('data-elementor-lightbox-slideshow', id); // FIX: elementor lightbox gallery
1665      }
1666
1667      $( '.gallery-item', el ).each(function(){
1668        var title = $(this).data('title');
1669        var description = $(this).data('description');
1670        $('.gallery-icon a', $(this))
1671          .attr('data-elementor-lightbox-title', title)
1672          .attr('data-elementor-lightbox-description', description);
1673      });
1674
1675      // isotope for masonry layout
1676
1677      if (el.hasClass('masonry')) {
1678
1679        mfnIsotope.addIsotopeLocation({
1680          name: 'Wordpress && Elementor - Masonry gallery',
1681          location: el,
1682          settings: {
1683            itemSelector: '.gallery-item',
1684            layoutMode: 'masonry',
1685            isOriginLeft: rtl ? false : true
1686          }
1687        })
1688
1689        mfnIsotope.runIsotopes();
1690      }
1691
1692    });
1693
1694    // WordPress >
1694= 5.0 | content
1695
1696    $('.sections_group .wp-block-gallery').each(function(index) {
1697
1698      var el = $(this);
1699      var link = $('.blocks-gallery-item a, .wp-block-image a', el);
1700
1701      // lightbox | link to media file
1702
1703      if ((/\.(gif|jpg|jpeg|png)$/i).test(link.attr('href'))) {
1704        link.attr('rel', 'prettyphoto[wp5-gallery-' + index + ']');
1705      }
1706
1707    });
1708
1709    // widgets
1710
1711    $('.widget_media_gallery .gallery').each(function() {
1712
1713      var el = $(this);
1714      var id = el.attr('id');
1715
1716      // lightbox | link to media file
1717
1718      $('.gallery-icon a', el).attr('rel', 'prettyphoto[widget-' + id + ']');
1719
1720    });
1721
1722    /**
1723     * Lightbox | PrettyPhoto
1724     */
1725
1726    $('a[rel^="prettyphoto[portfolio]"]').each(function() {
1727
1728      var el = $(this);
1729      var parent = el.closest('.column');
1730      var index = $('.column').index(parent);
1731
1732      el.attr('rel', 'prettyphoto[portfolio-' + index + ']');
1733
1734    });
1735
1736    /**
1737     * Lightbox | Magnific Popup
1738     * with prettyPhoto backward compatibility
1739     */
1740
1741    function lightbox() {
1742
1743      var galleries = [];
1744
1745      // init
1746
1747      var init = function() {
1748
1749        if (lightboxAttr) {
1750          compatibility();
1751          setType();
1752          constructor();
1753        }
1754
1755      };
1756
1757      // backward compatibility for prettyPhoto
1758
1759      var compatibility = function() {
1760
1761        $('a[rel^="prettyphoto"], a.prettyphoto, a[rel^="prettyphoto"]').each(function() {
1762
1763          var el = $(this);
1764          var rel = el.attr('rel');
1765
1766          if (rel) {
1767            rel = rel.replace('prettyphoto', 'lightbox');
1768          } else {
1769            rel = 'lightbox';
1770          }
1771
1772          el.removeClass('prettyphoto').attr('rel', rel);
1773
1774        });
1775
1776      };
1777
1778      // check if item is a part of gallery
1779
1780      var isGallery = function(rel) {
1781
1782        if (!rel) {
1783          return false;
1784        }
1785
1786        var regExp = /\[(?:.*)\]/;
1787        var gallery = regExp.exec(rel);
1788
1789        if (gallery) {
1790          gallery = gallery[0];
1791          gallery = gallery.replace('[', '').replace(']', '');
1792          return gallery;
1793        }
1794
1795        return false;
1796      };
1797
1798      // set array of names of galleries
1799
1800      var setGallery = function(gallery) {
1801
1802        if (galleries.indexOf(gallery) == -1) {
1803          galleries.push(gallery);
1804          return true;
1805        }
1806
1807        return false;
1808      };
1809
1810      // get file type by link
1811
1812      var getType = function(src) {
1813
1814        if (src.match(/youtube\.com\/watch/i) || src.match(/youtube\.com\/embed/i) || src.match(/youtu\.be/i)) {
1815          return 'iframe';
1816
1817        } else if (src.match(/youtube-nocookie\.com/i)) {
1818          return 'iframe';
1819
1820        } else if (src.match(/vimeo\.com/i)) {
1821          return 'iframe';
1822
1823        } else if (src.match(/\biframe=true\b/i)) {
1824          return 'ajax';
1825
1826        } else if (src.match(/\bajax=true\b/i)) {
1827          return 'ajax';
1828
1829        } else if (src.match(/\.mp4/i)) {
1830          return 'mp4';
1831
1832        } else if (src.substr(0, 1) == '#') {
1833          return 'inline';
1834
1835        } else {
1836          return 'image';
1837
1838        }
1839      };
1840
1841      // set file type
1842
1843      var setType = function() {
1844
1845        $('a[rel^="lightbox"]').each(function() {
1846
1847          var el = $(this);
1848          var href = el.attr('href');
1849          var rel = el.attr('rel');
1850
1851          // FIX: WPBakery Page Builder duplicated lightbox
1852          if ( el.closest('.wpb_column').length ){
1853            // return true;
1854          }
1855
1856          if (href) {
1857
1858            // gallery
1859
1860            var gallery = isGallery(rel);
1861
1862            if (gallery) {
1863              el.attr('data-lightbox-type', 'gallery');
1864              setGallery(gallery);
1865              return true;
1866            }
1867
1868            el.attr('data-lightbox-type', getType(href));
1869
1870            // iframe paremeters
1871
1872            if (getType(href) == 'iframe') {
1873              el.attr('href', href.replace('&rel=0', ''));
1874            }
1875          }
1876
1877        });
1878
1879      };
1880
1881      // constructor
1882
1883      var constructor = function() {
1884
1885        // Dividing plugins into separate files fix
1886        if( !galleries.length
1887          && !$('a[rel^="lightbox"][data-lightbox-type="image"]').length
1888          && !$('a[rel^="lightbox"][data-lightbox-type="iframe"]').length
1889          && !$('a[rel^="lightbox"][data-lightbox-type="inline"]').length
1890          && !$('a[rel^="lightbox"][data-lightbox-type="mp4"]').length
1891          && !$('a[rel^="pdf-lightbox"]').length
1892        ) return;
1893
1894        var attr = {
1895          autoFocusLast: false,
1896          removalDelay: 160,
1897          image: {
1898            titleSrc: function(item) {
1899              var img = item.el.closest('.image_wrapper, li').find('img').first();
1900              if (lightboxAttr.title && img.length) {
1901                return img.attr('alt');
1902              } else {
1903                return false;
1904              }
1905            }
1906          }
1907        };
1908
1909        // image
1910
1911        $('a[rel^="lightbox"][data-lightbox-type="image"]').magnificPopup({
1912          autoFocusLast: attr.autoFocusLast,
1913          removalDelay: attr.removalDelay,
1914          type: 'image',
1915          image: attr.image
1916        });
1917
1918        // iframe | video
1919
1920        $('a[rel^="lightbox"][data-lightbox-type="iframe"]').magnificPopup({
1921          autoFocusLast: attr.autoFocusLast,
1922          removalDelay: attr.removalDelay,
1923          type: 'iframe',
1924          iframe: {
1925            patterns: {
1926              youtube: {
1927                index: 'youtube.com/',
1928                id: 'v=',
1929                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
1930              },
1931              youtu_be: {
1932                index: 'youtu.be/',
1933                id: '/',
1934                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
1935              },
1936              nocookie: {
1937                index: 'youtube-nocookie.com/embed/',
1938                id: '/',
1939                src: '//www.youtube-nocookie.com/embed/%id%?autoplay=1&rel=0'
1940              }
1941            }
1942          }
1943        });
1944
1945        // iframe | mp4
1946
1947        $('a[rel^="lightbox"][data-lightbox-type="mp4"]').magnificPopup({
1948          autoFocusLast: attr.autoFocusLast,
1949          removalDelay: attr.removalDelay,
1950          type: 'iframe',
1951          iframe: {
1952            markup: '<div class="mfp-mp4 popup-content">'+
1953              '<video controls mute autoplay>'+
1954                '<source class="mfp-source" type="video/mp4">'+
1955              '</video>'+
1956              '<div class="mfp-close"></div>'+
1957            '</div>',
1958            patterns: {
1959              mp4: {
1960                src: '%id%',
1961              }
1962            },
1963            srcAction: 'source_src',
1964          }
1965        });
1966
1967        // pdf
1968
1969        $('a[rel^="pdf-lightbox"]').magnificPopup({
1970          autoFocusLast: attr.autoFocusLast,
1971          removalDelay: attr.removalDelay,
1972          type: 'iframe'
1973        });
1974
1975        // inline
1976
1977        $('a[rel^="lightbox"][data-lightbox-type="inline"]').magnificPopup({
1978          autoFocusLast: attr.autoFocusLast,
1979          type: 'inline',
1980          midClick: true,
1981          callbacks: {
1982            open: function() {
1983              $('.mfp-content').children().addClass('mfp-inline');
1984            },
1985            beforeClose: function() {
1986              $('.mfp-content').children().removeClass('mfp-inline');
1987            }
1988          }
1989        });
1990
1991        // gallery
1992
1993        for (var i = 0, len = galleries.length; i < len; i++) {
1994
1995          var gallery = '[' + galleries[i] + ']';
1996          gallery = 'a[rel^="lightbox' + gallery + '"]:visible';
1997
1998          $(gallery).magnificPopup({
1999            autoFocusLast: attr.autoFocusLast,
2000            removalDelay: attr.removalDelay,
2001            type: 'image',
2002            image: attr.image,
2003            gallery: {
2004              enabled: true,
2005              tCounter: '<span class="mfp-counter">%curr% / %total%</span>' // markup of counter
2006            }
2007          });
2008        }
2009
2010        // FIX: elementor | disable in Elementor wrapper
2011
2012        $('.elementor-page a[rel^="lightbox"]:not([data-lightbox-type="gallery"]):not(.popup-link):not(.rs-layer)').off('click');
2013
2014        // FIX: WPBakery | disable if WPBakery lighbox is active
2015
2016        setTimeout(function(){
2017
2018          var $doc = $('body');
2019          var $events = $._data($doc[0],"events");
2020
2021          if($events && $events.click){
2022            for(var i=$events.click.length-1; i>=0; i--){
2023              var handler = $events.click[i];
2024              if( handler && handler.selector && handler.selector.indexOf('lightbox') !== -1 ){
2025                $('.wpb_column a[rel^="lightbox"]:not(.popup-link)').off('click');
2026              }
2027            }
2028          }
2029
2030        },0);
2031
2032      };
2033
2034      // reload
2035
2036      var reload = function() {
2037
2038        $('a[rel^="lightbox"]').off('click');
2039        constructor();
2040
2041      };
2042
2043      // init
2044
2045      init();
2046
2047      // isotope:arrange
2048
2049      mfnIsotope.addEventListener('arrange', reload);
2050
2051      // ajaxComplete
2052
2053      $(document).ajaxComplete(function() {
2054        reload();
2055      });
2056
2057    }
2058
2059    lightbox();
2060
2061    /**
2062     * Menu | mfnMenu
2063     */
2064
2065    function mainMenu() {
2066
2067      var mmMobileInitW = mobileInitW;
2068
2069      if ($('body').hasClass('header-simple') || $('#Header_creative.dropdown').length) {
2070        mmMobileInitW = 9999;
2071      }
2072
2073      $('#menu > ul.menu').mfnMenu({
2074        addLast: true,
2075        arrows: true,
2076        mobileInit: mmMobileInitW,
2077        responsive: mfn.responsive
2078      });
2079
2080      $('#secondary-menu > ul.secondary-menu').mfnMenu({
2081        mobileInit: mmMobileInitW,
2082        responsive: mfn.responsive
2083      });
2084
2085    }
2086
2087    mainMenu();
2088
2089    /**
2090     * Menu | NOT One Page | .scroll item
2091     * Works with .scroll class
2092     * Since 4.8 replaced with: Page Options > One Page | function: onePageMenu()
2093     */
2094
2095    function onePageScroll() {
2096      if (!$('body').hasClass('one-page')) {
2097        var menu = $('#menu');
2098
2099        if (menu.find('li.scroll').length > 1) {
2100          menu.find('li.current-menu-item:not(:first)').removeClass('current-menu-item currenet-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor');
2101
2102          // menu item click
2103          menu.on('click','a',function() {
2104            $(this).closest('li').siblings('li').removeClass('current-menu-item currenet-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor');
2105            $(this).closest('li').addClass('current-menu-item');
2106          });
2107        }
2108      }
2109    }
2110    onePageScroll();
2111
2112    /**
2113     * Menu | One Page | Active on Scroll & Click
2114     */
2115
2116    function onePageMenu() {
2117      if ($('body').hasClass('one-page')) {
2118
2119        var menu = $('#menu');
2120        if( $('#mfn-header-template').length ) menu = $('#mfn-header-template .mfn-header-menu');
2121
2122        // add attr [data-hash] & [data-id]
2123
2124        $('a[href]', menu).each(function() {
2125
2126          var url = $(this).attr('href');
2127          if (url && url.split('#')[1]) {
2128
2129            // data-hash
2130            var hash = '#' + url.split('#')[1];
2131            if (hash && $(hash).length) {
2132              // check if element with specified ID exists
2133              $(this).attr('data-hash', hash);
2134              $(hash).attr('data-id', hash);
2135            }
2136
2137            // Visual Composer
2138            var vcHash = '#' + url.split('#')[1];
2139            var vcClass = '.vc_row.' + url.split('#')[1];
2140            if (vcClass && $(vcClass).length) {
2141              // check if element with specified Class exists
2142              $(this).attr('data-hash', vcHash);
2143              $(vcClass).attr('data-id', vcHash);
2144            }
2145
2146          }
2147
2148        });
2149
2150        // active
2151
2152        var hash;
2153        var activeSelector = 'li.current-menu-item, li.current-menu-parent, li.current-menu-ancestor, li.current-page-ancestor, li.current_page_item, li.current_page_parent, li.current_page_ancestor';
2154        var activeClasses = 'current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor';
2155
2156        if ($(activeSelector, menu).length) {
2157
2158          // remove duplicated
2159          $(activeSelector, menu)
2160            .not(':first').removeClass(activeClasses);
2161
2162          // remove if 1st link to section & section is not visible
2163          hash = $(activeSelector, menu).find('a[data-hash]').attr('data-hash');
2164
2165          if (hash) {
2166            hash = '[data-id="' + hash + '"]';
2167
2168            if ($(hash).length && $(hash).visible(true)) {
2169              // do nothing
2170            } else {
2171              $(activeSelector, menu).removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor')
2172                .closest('li').removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor');
2173            }
2174          } else {
2175            // do nothing
2176          }
2177
2178        } else {
2179
2180          // add to first if none is active
2181          var first = $('li:first-child', menu);
2182          var firstA = first.children('a');
2183
2184          if (firstA.attr('data-hash')) {
2185            hash = firstA.attr('data-hash');
2186            hash = '[data-id="' + hash + '"]';
2187
2188            if ($(hash).length && ($(hash).offset().top == adminBarH())) {
2189              first.addClass('current-menu-item');
2190            }
2191          }
2192
2193        }
2194
2195        // click
2196
2197        var menu_item = $('#menu a[data-hash]');
2198        if( $('#mfn-header-template').length ) menu_item = $('#mfn-header-template .mfn-header-menu a[data-hash]');
2199
2200        menu_item.on('click', function(e) {
2201          e.preventDefault(); // only with: body.one-page
2202
2203          if( $('html').hasClass('mfn-header-tmpl-burger-sidebar-opened') ){
2204            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2205          }
2206
2207          // active
2208
2209          menu.find('li').removeClass('current-menu-item');
2210          $(this)
2211            .closest('li').addClass('current-menu-item')
2212            .closest('.menu > li').addClass('current-menu-item');
2213
2214          var hash = $(this).attr('data-hash');
2215          hash = '[data-id="' + hash + '"]';
2216
2217          // mobile - sticky header - close menu
2218
2219          if ( window.innerWidth < 768 ) {
2220            $('.responsive-menu-toggle').removeClass('active');
2221            $('#Top_bar #menu').hide();
2222          }
2223
2224          // offset
2225
2226          var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
2227          var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
2228
2229          var offset = headerFixedAbH + tabsHeaderH + adminBarH();
2230
2231          // sticky height
2232
2233          var stickyH = fixStickyHeaderH();
2234
2235          // FIX | Header below | 1st section
2236          if ($('body').hasClass('header-below') && $('#Content').length) {
2237            if ($(hash).offset().top < ($('#Content').offset().top + 60)) {
2238              stickyH = -1;
2239            }
2240          }
2241
2242          // animate scroll
2243
2244          $('html, body').animate({
2245            scrollTop: $(hash).offset().top - offset - stickyH
2246          }, 500);
2247
2248        });
2249
2250      }
2251    }
2252    onePageMenu();
2253
2254    /**
2255     * Header | Creative
2256     */
2257
2258    var cHeader = 'body:not( .header-open ) #Header_creative',
2259      cHeaderEl = $(cHeader),
2260      cHeaderCurrnet;
2261
2262    function creativeHeader() {
2263
2264      $('.creative-menu-toggle').on('click', function(e) {
2265        e.preventDefault();
2266
2267        cHeaderEl.addClass('active');
2268        $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeOut(500);
2269        $('#Action_bar', cHeaderEl).fadeIn(500);
2270
2271      });
2272
2273    }
2274    creativeHeader();
2275
2276    $(document).on('mouseenter', cHeader, function() {
2277      cHeaderCurrnet = 1;
2278    });
2279
2280    $(document).on('mouseleave', cHeader, function() {
2281      cHeaderCurrnet = null;
2282      setTimeout(function() {
2283        if (!cHeaderCurrnet) {
2284
2285          cHeaderEl.removeClass('active');
2286          $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeIn(500);
2287          $('#Action_bar', cHeaderEl).fadeOut(500);
2288
2289        }
2290      }, 1000);
2291    });
2292
2293    // Fix: Header Creative & Mobile Sticky | On Resize > 768 px
2294    function creativeHeaderFix() {
2295      if ( $('body').hasClass('header-creative') && window.innerWidth >= 768 ) {
2296        if ($('#Top_bar').hasClass('is-sticky')) {
2297          $('#Top_bar').removeClass('is-sticky');
2298        }
2299      }
2300    }
2301
2302    /**
2303     * Header | Menu Burger
2304     */
2305
2306    $(document).on("click", ".mfn-header-tmpl .mfn-header-menu-toggle", function(e) {
2307      e.preventDefault();
2308
2309      if( $(this).closest('.mcb-column').hasClass('mfn-header-tmpl-menu-active') ){
2310        $(document).unbind('click', hideSidebarTmplBurger);
2311        $(this).closest('.mcb-column').removeClass('mfn-header-tmpl-menu-active');
2312        removeBringToFront();
2313        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', false);
2314
2315        $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2316      }else{
2317        $(document).bind('click', hideSidebarTmplBurger);
2318        $(this).closest('.mcb-column').addClass('mfn-header-tmpl-menu-active');
2319        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2320        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2321        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2322        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', true);
2323
2324        var htmlW = $('html').width();
2325
2326        $('html').addClass('mfn-header-tmpl-burger-sidebar-opened');
2327
2328        if( $('html').width() != htmlW ){
2329          $('html').addClass('scrollbar-hidden');
2330        }
2331      }
2332
2333    });
2334
2335    $(document).on("click", ".one-page .mfn-header-tmpl-menu-sidebar .mfn-header-menu .mfn-menu-li a", function(e) {
2336      let href = $(this).attr('href');
2337
2338      if( href.includes('/') ){
2339        let href_ex = href.split('#');
2340        href = '#'+href_ex[1].replace('/', '');
2341      }
2342
2343      if( $('body').hasClass('one-page') && href.includes('#') && $(href).length ) {
2344        e.preventDefault();
2345        let header_h = 0;
2346        if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-tmpl-fixed') || $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-hasSticky') ){
2347          header_h = $('.mfn-header-tmpl.mfn-header-main').outerHeight();
2348        }
2349        $(this).closest('ul').find('li.current-menu-item').removeClass('current-menu-item');
2350        $(this).closest('li').addClass('current-menu-item');
2351
2352        let scroll_offset = $(href).offset().top - header_h;
2353        $('body, html').animate({ scrollTop: scroll_offset }, 500);
2354        $(document).unbind('click', hideSidebarTmplBurger);
2355        $(this).closest('.mcb-column').removeClass('mfn-header-tmpl-menu-active');
2356        removeBringToFront();
2357        if( $('html').hasClass('mfn-header-tmpl-burger-sidebar-opened') ){
2358          $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2359        }
2360      }
2361    });
2362
2363    function hideSidebarTmplBurger(e){
2364        var div = $('.mfn-header-tmpl-menu-sidebar');
2365
2366        if (!div.is(e.target) && div.has(e.target).length === 0){
2367            $('.mfn-header-tmpl-menu-active').removeClass('mfn-header-tmpl-menu-active');
2368            $(document).unbind('click', hideSidebarTmplBurger);
2369            removeBringToFront();
2370            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2371        }
2372    }
2373
2374    function removeBringToFront(){
2375      if( $('.mfn-bring-to-front').length ) {
2376        $('.mfn-bring-to-front').removeClass('mfn-bring-to-front');
2377      }
2378    }
2379
2380    /**
2381     * Header | Search
2382     */
2383
2384    $(document).on("click", ".mfn-header-tmpl .mfn-searchbar-toggle, .mfn-header-tmpl .search_wrapper .mfn-close-icon", function(e) {
2385      e.preventDefault();
2386
2387      if( $(this).closest('.mcb-column-inner').hasClass('mfn-searchbar-active') ){
2388        $(this).closest('.mcb-column-inner').removeClass('mfn-searchbar-active');
2389        removeBringToFront();
2390      }else{
2391        $(this).closest('.mcb-column-inner').addClass('mfn-searchbar-active');
2392        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2393        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2394        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2395
2396        if( $(this).closest('.mcb-column-inner').find('input.field').length ){
2397          $(this).closest('.mcb-column-inner').find('input.field').focus();
2398        }
2399      }
2400
2401
2402
2403    });
2404
2405    $(".search_button:not(.has-input), #Top_bar .icon_close").on('click', function(e) {
2406      e.preventDefault();
2407
2408      if( $(this).closest('.mfn-header-tmpl').length ){
2409        // header template
2410        $(this).closest('.mcb-column').toggleClass('mfn-searchbar-active');
2411
2412      }else{
2413        const search = $('.search_wrapper')
2414        if( search.css('display') === 'none' ){
2415          search.fadeIn().find('.field').focus();
2416
2417          setTimeout(function(){ search.addClass('mfn-loaded') }, 300);
2418        } else{
2419          search.fadeOut().removeClass('mfn-loaded');
2420        }
2421      }
2422
2423    });
2424
2425    /**
2426     * WPML | Language switcher in the WP Menu
2427     */
2428
2429    function mfnWPML() {
2430      $('#menu .menu-item-language:not(.menu-item-language-current)').each(function() {
2431        var el = $(this).children('a');
2432
2433        if (!el.children('span:not(.icl_lang_sel_bracket)').length) {
2434          el.wrapInner('<span></span>');
2435        }
2436
2437      });
2438
2439      $('#menu span.icl_lang_sel_bracket').each(function() {
2440        var el = $(this);
2441        el.replaceWith(el.html());
2442      });
2443
2444    }
2445    mfnWPML();
2446
2447    /**
2448     * Breadcrumbs | Remove last item link
2449     */
2450
2451    function breadcrumbsRemoveLastLink() {
2452      var el = $('.breadcrumbs.no-link').find('li').last();
2453      var text = el.text();
2454      el.html(text);
2455    }
2456    breadcrumbsRemoveLastLink();
2457
2458    /**
2459     * Downcount
2460     */
2461
2462    $('#Wrapper .downcount:not(.mfn-initialized), .content-under-construction .downcount:not(.mfn-initialized)').each(function() {
2463      var el = $(this);
2464      el.addClass('mfn-initialized');
2465      el.downCount({
2466        date: el.attr('data-date'),
2467        offset: el.attr('data-offset')
2468      });
2469    });
2470
2471    /**
2472     * Hover | on Touch | .tooltip, .hover_box
2473     */
2474
2475    $('.tooltip, .hover_box')
2476      .on('touchstart', function() {
2477        $(this).toggleClass('hover');
2478      })
2479      .on('touchend', function() {
2480        $(this).removeClass('hover');
2481      });
2482
2483    /**
2484     * Popup | Contact Form | Button
2485     */
2486
2487    $("#popup_contact .footer_button").on('click', function(e) {
2488      e.preventDefault();
2489      $(this).parent().toggleClass('focus');
2490    });
2491
2492    /**
2493     * Scroll | niceScroll for Header Creative
2494     */
2495
2496    if ( $('#Header_creative.scroll').length && window.innerWidth >= 1240 ) {
2497      $('#Header_creative.scroll').niceScroll({
2498        autohidemode: false,
2499        cursorborder: 0,
2500        cursorborderradius: 5,
2501        cursorcolor: '#222222',
2502        cursorwidth: 0,
2503        horizrailenabled: false,
2504        mousescrollstep: 40,
2505        scrollspeed: 60
2506      });
2507    }
2508
2509    /**
2510     * Sliding Top
2511     */
2512
2513    $('.sliding-top-control').on('click', function(e) {
2514      e.preventDefault();
2515      $('#Sliding-top .widgets_wrapper').slideToggle();
2516      $('#Sliding-top').toggleClass('active');
2517    });
2518
2519    /**
2520     * Alert
2521     */
2522
2523    $('body').on('click', '.alert .close', function(e) {
2524      e.preventDefault();
2525      $(this).closest('.alert').hide(300);
2526    });
2527
2528    /**
2529     * Navigation Arrows | Sticky
2530     */
2531
2532    $('.fixed-nav').appendTo('body');
2533
2534    /**
2535     * Feature List
2536     */
2537
2538    $('.feature_list').each(function() {
2539      var col = $(this).attr('data-col') ? $(this).attr('data-col') : 4;
2540      $(this).find('li:nth-child(' + col + 'n):not(:last-child)').after('<hr />');
2541    });
2542
2543    /**
2544     * IE Fixes
2545     */
2546
2547    function checkIE() {
2548      // IE 9
2549      var ua = window.navigator.userAgent;
2550      var msie = ua.indexOf("MSIE ");
2551      if (msie > 0 && parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) == 9) {
2552        $("body").addClass("ie");
2553      }
2554    }
2555    checkIE();
2556
2557    /**
2558     * Parallax
2559     */
2560
2561    var ua = navigator.userAgent,
2562      isMobileWebkit = /WebKit/.test(ua) && /Mobile/.test(ua);
2563
2564    if ( ! isMobileWebkit && window.innerWidth >= 768 ) {
2565
2566      if (mfn.parallax == 'stellar') {
2567
2568        // Stellar
2569        $.stellar({
2570          horizontalScrolling: false,
2571          responsive: true
2572        });
2573
2574      } else {
2575
2576        $(window).enllax();
2577
2578      }
2579
2580    } else {
2581
2582      $('div[data-enllax-ratio], div[data-stellar-ratio]').css('background-attachment', 'scroll');
2583
2584    }
2585
2586    /**
2587     * Load More | Ajax
2588     */
2589
2590    $('.pager_load_more').on('click', function(e) {
2591      e.preventDefault();
2592
2593      var el = $(this);
2594      var pager = el.closest('.pager_lm');
2595      var href = el.attr('href');
2596
2597      // index | for many items on the page
2598      //var index = $('.lm_wrapper').index(el.closest('.isotope_wrapper').find('.lm_wrapper'));
2599      var index = $('.lm_wrapper').index( el.closest('.mcb-column-inner').find('.lm_wrapper') );
2600
2601      el.fadeOut(50);
2602      pager.addClass('loading');
2603
2604      $.get( href, function( data ) {
2605
2606        // content
2607
2608        var content = $('.lm_wrapper:eq(' + index + ')', data).wrapInner('').html();
2609        var $content = $(content);
2610
2611        href = $('.lm_wrapper:eq(' + index + ')', data).next().find('.pager_load_more').attr('href');
2612
2613        if ($('.lm_wrapper:eq(' + index + ')').hasClass('isotope')) {
2614          // isotope
2615          const location = '.lm_wrapper:eq(' + index + ')';
2616          $(location).append( $content );
2617
2618          mfnIsotope.queryIsotopeAPI(location, 'appended', $content);
2619          mfnIsotope.addIsotopeLocation({ name: 'Load More - Ajax', location })
2620
2621        } else if ($('.lm_wrapper:eq(' + index + ')').hasClass('mfn-woo-products')) {
2622
2623          $('.lm_wrapper:eq(' + index + ') ul.products').append( $content.html() );
2624          href = $('.lm_wrapper:eq(' + index + ')', data).find('.pager_load_more').attr('href');
2625
2626          var $listing = $('.lm_wrapper ul.products.isotope');
2627
2628          if( $listing.length ){
2629            $listing.imagesLoaded().progress(function() {
2630              $listing.isotope('reloadItems');
2631            });
2632          }
2633
2634        } else {
2635          // default
2636          $content.hide().appendTo('.lm_wrapper:eq(' + index + ')').fadeIn(1000);
2637        }
2638
2639        // next page link
2640
2641        pager.removeClass('loading');
2642        if (href) {
2643          el.fadeIn();
2644          el.attr('href', href);
2645        }
2646
2647        // refresh some staff
2648
2649        mfnJPlayer();
2650        lightbox();
2651
2652        // isotope fix: second resize
2653
2654        if( $('.lm_wrapper.isotope').length ){
2655          $('.lm_wrapper.isotope').imagesLoaded().progress(function() {
2656            mfnIsotope.queryIsotopeAPI( '.lm_wrapper.isotope' );
2657          });
2658        }
2659
2660      });
2661
2662    });
2663
2664    /**
2665     * Filters | Blog & Portfolio
2666     */
2667
2668    $('.filters_buttons .open').on('click', function(e) {
2669      e.preventDefault();
2670      var type = $(this).closest('li').attr('class');
2671
2672      $('.filters_wrapper').show(200);
2673      $('.filters_wrapper ul.' + type).show(200);
2674      $('.filters_wrapper ul:not(.' + type + ')').hide();
2675    });
2676
2677    $('.filters_wrapper .close a').on('click', function(e) {
2678      e.preventDefault();
2679      $('.filters_wrapper').hide(200);
2680    });
2681
2682    /**
2683     * Portfolio List | Next v / Prev ^ buttons
2684     */
2685
2686    $('.portfolio_next_js').on('click', function(e) {
2687      e.preventDefault();
2688
2689      var item = $(this).closest('.portfolio-item').next();
2690
2691      if (item.length) {
2692        $('html, body').animate({
2693          scrollTop: item.offset().top - fixStickyHeaderH()
2694        }, 500);
2695      }
2696    });
2697
2698    $('.portfolio_prev_js').on('click', function(e) {
2699      e.preventDefault();
2700
2701      var item = $(this).closest('.portfolio-item').prev();
2702
2703      if (item.length) {
2704        $('html, body').animate({
2705          scrollTop: item.offset().top - fixStickyHeaderH()
2706        }, 500);
2707      }
2708    });
2709
2710    /**
2711     * Link | Smooth Scroll | .scroll
2712     */
2713
2714    $('body').on('click', '.scroll > a, a.scroll, .mcb-column.scroll a', function(e) {
2715
2716      // prevent default if link directs to the current page
2717
2718      // var urlL = location.href.replace(/\/#.*|#.*/, '');
2719      // var urlT = this.href.replace(/\/#.*|#.*/, ''); // remove also trailing slash
2720
2721      var urlL = location.href.replace(/#.*/, '');
2722      var urlT = this.href.replace(/#.*/, '');
2723
2724      if (urlL == urlT) {
2725        e.preventDefault();
2726      }
2727
2728      var hash = this.hash;
2729
2730      // offset
2731
2732      var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
2733      var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
2734
2735      var offset = headerFixedAbH + tabsHeaderH + adminBarH();
2736
2737      // table of contents
2738
2739      if( $(this).parents('.table_of_content').length ){
2740        offset += 30;
2741      }
2742
2743      // animate scroll
2744
2745      if (hash && $(hash).length) {
2746
2747        // do scroll
2748
2749        $('html, body').animate({
2750          scrollTop: $(hash).offset().top - offset - fixStickyHeaderH()
2751        }, 500);
2752      }
2753    });
2754
2755    /**
2756     * Tabs
2757     */
2758
2759    $('.jq-tabs').tabs();
2760
2761    /**
2762     * Fake tabs
2763     */
2764
2765    $('.fake-tabs > ul').on('click', 'a', function(e) {
2766      e.preventDefault();
2767
2768      var $li = $(this).closest('li');
2769
2770      var tab = $li.data('tab');
2771
2772      if( $li.hasClass('active') ){
2773        return;
2774      }
2775
2776      $li.addClass('active')
2777        .siblings().removeClass('active');
2778
2779      $('.tab-'+ tab ).addClass('active').attr('tabindex', 0)
2780        .siblings('.tab').removeClass('active').attr('tabindex', -1);
2781
2782      $(window).trigger('resize');
2783    });
2784
2785    /**
2786     * Toggle
2787     */
2788
2789    $('body').on('click', '.mfn-toggle .toggle-bar', function() {
2790
2791      var $parent = $(this).parent(),
2792        $toggle = $(this).closest('.mfn-toggle');
2793      var speed = 100;
2794
2795      if ( $parent.hasClass('active') ) {
2796
2797        if( $toggle.is('.mfn-toggle-open-all') ){
2798          return;
2799        }
2800
2801        $parent.removeClass('active')
2802          .children('.toggle-content').slideUp(speed);
2803
2804      } else {
2805
2806        $parent.addClass('active')
2807          .children('.toggle-content').slideDown(speed);
2808
2809        if( ! $toggle.is('.mfn-toggle-open-more') ){
2810          $parent.siblings().removeClass('active')
2811            .children('.toggle-content').slideUp(speed);
2812        }
2813
2814      }
2815
2816      setTimeout(function() {
2817        $(window).trigger('resize');
2818      }, speed);
2819
2820    });
2821
2822    /**
2823     * Accordion & FAQ
2824     */
2825
2826    $('.mfn-acc').each(function() {
2827      var el = $(this);
2828
2829      if (el.hasClass('openAll')) {
2830
2831        // show all
2832        el.find('.question')
2833          .addClass('active')
2834          .children(".answer")
2835          .show();
2836
2837      } else {
2838
2839        // show one
2840        var activeTab = el.attr('data-active-tab');
2841        if (el.hasClass('open1st')) activeTab = 1;
2842
2843        if (activeTab) {
2844          el.find('.question').eq(activeTab - 1)
2845            .addClass('active')
2846            .children(".answer")
2847            .show();
2848        }
2849
2850      }
2851    });
2852
2853    $('.mfn-acc .question > .title').on('click', function() {
2854
2855      if ($(this).parent().hasClass('active')) {
2856
2857        $(this).parent().removeClass('active').children(".answer").slideToggle(100);
2858
2859      } else {
2860
2861        if (!$(this).closest('.mfn-acc').hasClass('toggle')) {
2862          $(this).parents(".mfn-acc").children().each(function() {
2863            if ($(this).hasClass('active')) {
2864              $(this).removeClass('active').children(".answer").slideToggle(100);
2865            }
2866          });
2867        }
2868        $(this).parent().addClass('active');
2869        $(this).next(".answer").slideToggle(100);
2870
2871      }
2872
2873      setTimeout(function() {
2874        $(window).trigger('resize');
2875      }, 50);
2876
2877    });
2878
2879    // Visual Composer | Accordion | Sidebar height
2880    $('.wpb_wrapper .vc_tta-panel-title').on('click', 'a', function() {
2881
2882      setTimeout(function() {
2883        $(window).trigger('resize');
2884      }, 50);
2885
2886    });
2887
2888    /**
2889     * Helper
2890     */
2891
2892    $('.helper .link.toggle').on('click', function(e) {
2893
2894      e.preventDefault();
2895
2896      var el = $(this);
2897      var id = el.attr('data-rel');
2898      var parent = el.closest('.helper');
2899
2900      if (el.hasClass('active')) {
2901
2902        el.removeClass('active');
2903        parent.find('.helper_content > .item-' + id).slideUp(200);
2904
2905        setTimeout(function() {
2906          parent.find('.helper_content > .item-' + id).removeClass('active');
2907        }, 200);
2908
2909      } else {
2910
2911        parent.find('.links > .link.active').removeClass('active');
2912        parent.find('.helper_content > .item.active').slideUp(200);
2913
2914        el.addClass('active');
2915        parent.find('.helper_content > .item-' + id).addClass('active').hide().slideDown(200);
2916
2917      }
2918
2919      setTimeout(function() {
2920        $(window).trigger('resize');
2921      }, 50);
2922
2923    });
2924
2925    /**
2926     * HTML5 Video | jPlayer
2927     */
2928
2929    function mfnJPlayer() {
2930      $('.mfn-jplayer').each(function() {
2931
2932        var m4v = $(this).attr('data-m4v'),
2933          poster = $(this).attr('data-img'),
2934          swfPath = $(this).attr('data-swf'),
2935          cssSelectorAncestor = '#' + $(this).closest('.mfn-jcontainer').attr('id');
2936
2937        $(this).jPlayer({
2938          ready: function() {
2939            $(this).jPlayer('setMedia', {
2940              m4v: m4v,
2941              poster: poster
2942            });
2943          },
2944          play: function() {
2945            // To avoid both jPlayers playing together.
2946            $(this).jPlayer('pauseOthers');
2947          },
2948          size: {
2949            cssClass: 'jp-video-360p',
2950            width: '100%',
2951            height: '360px'
2952          },
2953          swfPath: swfPath,
2954          supplied: 'm4v',
2955          cssSelectorAncestor: cssSelectorAncestor,
2956          wmode: 'opaque'
2957        });
2958      });
2959    }
2960    mfnJPlayer();
2961
2962    /**
2963     * Love
2964     */
2965
2966    $('body').on('click', '.mfn-love', function() {
2967      var el = $(this);
2968
2969      if (el.hasClass('loved')) {
2970        return false;
2971      }
2972      el.addClass('loved');
2973
2974      var post = {
2975        action: 'mfn_love',
2976        post_id: el.attr('data-id')
2977      };
2978
2979      $.post(mfn.ajax, post, function(data) {
2980        el.find('.label').html(data);
2981      });
2982
2983      return false;
2984    });
2985
2986    /**
2987     * Go to top
2988     */
2989
2990    $('#back_to_top').on('click', function() {
2991      $('body,html').animate({
2992        scrollTop: 0
2993      }, 500);
2994      return false;
2995    });
2996
2997    /**
2998     * Section | Next v / Prev ^ navigation arrows
2999     */
3000
3001    $('.section .section-nav').on('click', function() {
3002
3003      var el = $(this);
3004      var section = el.closest('.section');
3005
3006      var offset = fixStickyHeaderH() + adminBarH();
3007
3008      if (el.hasClass('prev')) {
3009
3010        // Previous Section
3011        if (section.prev().length) {
3012          $('html, body').animate({
3013            scrollTop: section.prev().offset().top - offset
3014          }, 500);
3015        }
3016
3017      } else {
3018
3019        // Next Section
3020        if (section.next().length) {
3021          $('html, body').animate({
3022            scrollTop: section.next().offset().top - offset
3023          }, 500);
3024        }
3025
3026      }
3027    });
3028
3029    /**
3030     * Intro | Scroll v arrow
3031     */
3032
3033    $('#Intro .intro-next').on('click', function() {
3034      var intro = $(this).closest('#Intro');
3035
3036      if (intro.next().length) {
3037        $('html, body').animate({
3038          scrollTop: intro.next().offset().top - fixStickyHeaderH() - adminBarH()
3039        }, 500);
3040      }
3041    });
3042
3043    /**
3044     * Widget | Muffin Menu | Hover on click
3045     */
3046
3047    $('.widget_mfn_menu ul.submenus-click, .widget_mfn_menu ul.submenus-click-mobile').each(function() {
3048
3049      var el = $(this);
3050
3051      if( el.is('.submenus-click-mobile') && $(window).width() > 767 ){
3052        return;
3053      }
3054
3055      $('a', el).on('click', function(e) {
3056        var li = $(this).closest('li');
3057
3058        if (li.hasClass('hover') || !li.hasClass('menu-item-has-children')) {
3059          // link click
3060        } else {
3061          e.preventDefault();
3062          li.siblings('li').removeClass('hover')
3063            .find('li').removeClass('hover');
3064          $(this).closest('li').addClass('hover');
3065        }
3066
3067      });
3068
3069    });
3070
3071    /**
3072     * WooCommerce | Add to cart
3073     */
3074
3075    function addToCart() {
3076
3077      $('body').on('click', '.add_to_cart_button', function() {
3078        $(this)
3079          .closest('.product')
3080          .addClass('adding-to-cart')
3081          .removeClass('added-to-cart');
3082      });
3083
3084      $('body').on('added_to_cart', function() {
3085        $('.adding-to-cart')
3086          .removeClass('adding-to-cart')
3087          .addClass('added-to-cart');
3088      });
3089    }
3090    addToCart();
3091
3092    /**
3093     * WooCommerce | Rating click
3094     */
3095
3096    $('.woocommerce-product-rating').on('click', function(){
3097
3098      var el;
3099
3100      if( $('.product_tabs_wrapper.fake-tabs').length ){
3101
3102        el = $('.product_tabs_wrapper.fake-tabs');
3103        $('li[data-tab="reviews"] a', el).trigger('click');
3104
3105      } else if( $('.woocommerce-content .jq-tabs').length ){
3106
3107        el = $('.woocommerce-content .jq-tabs');
3108        $('.ui-tabs-nav a[href="#tab-reviews"]', el).trigger('click');
3109
3110      } else {
3111
3112        el = $('.woocommerce-content .accordion');
3113        $('#reviews').closest('.question:not(.active)').children('.title').trigger('click');
3114
3115      }
3116
3117      // offset
3118
3119      var actionBarH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
3120      var offset = actionBarH + adminBarH();
3121
3122      // animate scroll
3123
3124      $('html, body').animate({
3125        scrollTop: el.offset().top - offset - fixStickyHeaderH()
3126      }, 500);
3127
3128    });
3129
3130    /**
3131     * WooCommerce | Quantity change
3132     */
3133
3134    $('body').on('click', '.quantity-change', function(e){
3135
3136      e.preventDefault();
3137
3138      var $el = $(this),
3139        $input = $(this).siblings('input');
3140
3141      var step = parseFloat($input.attr('step')) || 1,
3142        minAttr = $input.attr('min'),
3143        min = typeof minAttr !== typeof undefined && minAttr !== false ? parseFloat(minAttr) : 1,
3144        max = parseFloat($input.attr('max')) || 9999,
3145        current = $input.val() ? parseFloat($input.val()) : min,
3146        val = 0;
3147
3148      if( $el.hasClass('plus') ){
3149        val = current + step;
3150        if( val > max ){
3151          val = current;
3152        }
3153      } else {
3154        val = current - step;
3155        if( val < min ){
3156          val = current;
3157        }
3158      }
3159
3160      val = Math.round(val * 10) / 10;
3161
3162      $input.val(val).trigger('change');
3163
3164    });
3165
3166    /**
3167     * Ajax | Complete
3168     */
3169
3170    $(document).ajaxComplete(function() {
3171
3172      setTimeout(function() {
3173        $(window).trigger('resize');
3174        mfnSidebar();
3175      }, 100);
3176
3177    });
3178
3179    /**
3180     * $(window).on('debouncedresize')
3181     * Specify a function to execute on window resize
3182     */
3183
3184    $(window).on('debouncedresize', function() {
3185
3186      // isotope
3187      mfnIsotope.runIsotopes( false );
3188
3189      // sliding footer height
3190
3191      mfnFooter();
3192
3193      // header width
3194
3195      headerWidth();
3196
3197      // sidebar height
3198
3199      mfnSidebar();
3200
3201      // intro header
3202
3203      mfnIntroH();
3204
3205      // mobile sticky for header creative
3206
3207      creativeHeaderFix();
3208
3209    });
3210
3211    /**
3212     * document.ready
3213     * Initialize document ready functions
3214     */
3215
3216    mfnSliderBlog();
3217    mfnSliderClients();
3218    mfnSliderOffer();
3219    mfnSliderOfferThumb();
3220    mfnSliderShop();
3221
3222    sliderPortfolio();
3223    sliderTestimonials();
3224
3225    // sliding footer height
3226
3227    mfnFooter();
3228
3229    // header width
3230
3231    headerWidth();
3232
3233    // sidebar height
3234
3235    mfnSidebar();
3236
3237    // intro header
3238
3239    mfnIntroH();
3240
3241    // hash navigation
3242
3243    hashNav();
3244
3245    // GDPR container display
3246
3247    gdpr();
3248
3249    // table of contents
3250    tableContentAttachId();
3251
3252  });
3253
3254  /**
3255   * $(window).on('scroll')
3256   * The scroll event is sent to an element when the user scrolls to a different place in the element.
3257   */
3258
3259  $(window).on('scroll', function() {
3260
3261    // sticky header
3262
3263    mfnSticky();
3264    mfnMobileSticky();
3265
3266    // sticky back to top
3267
3268    backToTopSticky();
3269
3270    // one page scroll active
3271
3272    onePageActive();
3273
3274    // sticky wrap
3275
3276    stickyWrap.scroll();
3277
3278  });
3279
3280  /**
3281   * $(window).on('load')
3282   * window.load
3283   */
3284
3285  $(window).on('load', function() {
3286
3287    //setTimeout(queryLoopMasonry, 100);
3288    queryLoopMasonry();
3289
3290    // top bar top position
3291
3292    setTimeout(function(){
3293
3294      topBarTop = parseInt($('#Top_bar').css('top'), 10);
3295
3296      // page has already been scrolled and is refreshed or is opened with #hash
3297
3298      var scrollPos = $(window).scrollTop();
3299
3300      if( scrollPos > 0 ){
3301        window.scrollTo(0, 0);
3302        $(window).scrollTop(0);
3303        topBarTop = parseInt($('#Top_bar').css('top'), 10);
3304        window.scrollTo(0, scrollPos);
3305      }
3306
3307      // negative top bar top value
3308
3309      if (topBarTop < 0){
3310        topBarTop = 0;
3311      }
3312
3313      topBarTop = topBarTop + 'px';
3314
3315    },1000);
3316
3317    // align divs heights
3318
3319    alignHeights();
3320
3321    /**
3322     * Elementor plugin
3323     * Disable built-in one page
3324     */
3325
3326    function elementorDisableOnePage(){
3327
3328      if( ! $('body').hasClass('one-page') ){
3329        return false;
3330      }
3331
3332      setTimeout(function(){
3333        var doc=$(document),
3334          $events=$("a[href*='#']").length ? $._data(doc[0],"events") : null;
3335        if($events && $events.click){
3336          for(var i=$events.click.length-1; i>=0; i--){
3337            var handler=$events.click[i];
3338            if(handler && handler.namespace != "mPS2id" && handler.selector === 'a[href*="#"]' ) doc.off("click",handler.handler);
3339          }
3340        }
3341      }, 300);
3342
3343    }
3344
3345    elementorDisableOnePage();
3346
3347    /**
3348     * Live search item
3349     * z-index for live search item parents
3350     */
3351
3352    function liveSearchItemZindex(){
3353
3354      $('.column_livesearch').each(function(){
3355        $(this).closest('.mcb-wrap').addClass('has-live-search-element')
3356          .closest('.mcb-section').addClass('has-live-search-element');
3357      });
3358
3359    }
3360
3361    liveSearchItemZindex();
3362
3363    /**
3364     * Retina Logo
3365     */
3366
3367    function retinaLogo() {
3368
3369      // ! retina display
3370
3371      if( window.devicePixelRatio <= 1 ){
3372        return false;
3373      }
3374
3375      var el, src, height,
3376        parent = $('#Top_bar #logo'),
3377        parentH = parent.data('height');
3378
3379      var maxH = {
3380        sticky: {
3381          init: 35,
3382          noPadding: 60,
3383          overflow: 110
3384        },
3385        mobile: {
3386          mini: 50,
3387          miniNoPadding: 60
3388        },
3389        mobileSticky: {
3390          init: 50,
3391          noPadding: 60,
3392          overflow: 80
3393        }
3394      };
3395
3396      $('#Top_bar #logo img').each(function(index) {
3397
3398        el = $(this);
3399        src = el.data('retina');
3400        height = el.height() || 0;
3401
3402        // main
3403
3404        if (el.hasClass('logo-main')) {
3405
3406          if ($('body').hasClass('logo-overflow')) {
3407
3408            // do nothing
3409
3410          } else if (height > parentH) {
3411
3412            height = parentH;
3413
3414          }
3415
3416        }
3417
3418        // sticky
3419
3420        if (el.hasClass('logo-sticky')) {
3421
3422          if ($('body').hasClass('logo-overflow')) {
3423
3424            if (height > maxH.sticky.overflow) {
3425              height = maxH.sticky.overflow;
3426            }
3427
3428          } else if ($('body').hasClass('logo-no-sticky-padding')) {
3429
3430            if (height > maxH.sticky.noPadding) {
3431              height = maxH.sticky.noPadding;
3432            }
3433
3434          } else if (height > maxH.sticky.init) {
3435
3436            height = maxH.sticky.init;
3437
3438          }
3439
3440        }
3441
3442        // mobile
3443
3444        if (el.hasClass('logo-mobile')) {
3445
3446          if ($('body').hasClass('mobile-header-mini')) {
3447
3448            if (parent.data('padding') > 0) {
3449
3450              if (height > maxH.mobile.mini) {
3451                height = maxH.mobile.mini;
3452              }
3453
3454            } else {
3455
3456              if (height > maxH.mobile.miniNoPadding) {
3457                height = maxH.mobile.miniNoPadding;
3458              }
3459
3460            }
3461
3462          }
3463
3464        }
3465
3466        // mobile-sticky
3467
3468        if (el.hasClass('logo-mobile-sticky')) {
3469
3470          if ($('body').hasClass('logo-no-sticky-padding')) {
3471
3472            if (height > maxH.mobileSticky.noPadding) {
3473              height = maxH.mobileSticky.noPadding;
3474            }
3475
3476          } else if (height > maxH.mobileSticky.init) {
3477            height = maxH.mobileSticky.init;
3478          }
3479
3480        }
3481
3482        // SET
3483
3484        if (src) {
3485          el.parent().addClass('retina');
3486          el.attr('src', src).css('max-height', height + 'px');
3487        }
3488
3489      });
3490
3491    }
3492
3493    setTimeout(function() {
3494      retinaLogo();
3495    }, 0); // jQuery 3.5 window.load
3496
3497    /**
3498     * Before After | TwentyTwenty
3499     */
3500
3501    $('#Wrapper .before_after.twentytwenty-container:not(.mfn-initialized)').each(function(){
3502
3503      var el = $(this);
3504
3505      el.addClass('mfn-initialized');
3506      el.imagesLoaded().done(function(instance, image){
3507
3508        queueMicrotask(() => el.twentytwenty());
3509
3510      });
3511
3512    });
3513
3514    // Visual Composer prettyPhoto | off
3515
3516    if ( lightboxAttr ) {
3517      $('a[data-rel^="prettyPhoto"]:not(.popup-link), a[rel^="lightbox"]:not(.popup-link)').each(function() {
3518        $(this).off('click.prettyphoto');
3519      });
3520    }
3521
3522    /**
3523     * Reload some functions on window.load
3524     */
3525
3526    // sticky header
3527
3528    mfnStickyH();
3529    mfnSticky();
3530    mfnMobileSticky();
3531
3532    // intro header
3533
3534    mfnIntroH();
3535
3536    // FIX | jQuery 3.5 window.load
3537
3538    setTimeout(function() {
3539
3540      // triger resize to recalculate some plugins stuff
3541      $(window).trigger('resize');
3542
3543      // sidebar height
3544
3545      mfnSidebar();
3546
3547      // sliders
3548
3549      sliderSlider();
3550
3551      // sticky wrap
3552      stickyWrap.init();
3553
3554    }, 0);
3555
3556  });
3557
3558  /**
3559   * $(document).on('mouseup')
3560   * Specify a function to execute when the DOM is fully loaded.
3561   * Close some modals when click outside
3562   */
3563
3564  $(document).on('mouseup',function(e) {
3565
3566    // Widget | Muffin menu | Hover on click
3567
3568    if ($('.widget_mfn_menu ul.submenus-click').length && ($('.widget_mfn_menu ul.submenus-click').has(e.target).length === 0) ) {
3569      $('.widget_mfn_menu ul.submenus-click li').removeClass('hover');
3570    }
3571
3572    // Mobile menu | Classic
3573
3574    if ($('.menu_wrapper').length && ( $('.menu_wrapper').has(e.target).length === 0 )) {
3575      if( $('.responsive-menu-toggle').hasClass('active') ){
3576        $('.responsive-menu-toggle').trigger('click');
3577      }
3578    }
3579
3580    // Popup contact form
3581
3582    if ($('#popup_contact').length && ( $('#popup_contact').has(e.target).length === 0 )) {
3583      if( $('#popup_contact').hasClass('focus') ){
3584        $('#popup_contact .footer_button').trigger('click');
3585      }
3586    }
3587
3588    // Off canvas sidebar
3589
3590    if($('html').hasClass('mfn-ofcs-opened') && !$('.mfn-off-canvas-sidebar').is(e.target) && $('.mfn-off-canvas-sidebar').has(e.target).length === 0){
3591      $('html').removeClass('mfn-ofcs-opened');
3592    }
3593
3594  });
3595
3596  /**
3597   * Sliders configuration
3598   */
3599
3600  // Slick Slider | Auto responsive
3601
3602  function slickAutoResponsive(slider, max, size, round = false) {
3603
3604    if (!max){
3605      max = 5;
3606    }
3607    if (!size){
3608      size = 380;
3609    }
3610
3611    var width = slider.width() || 0;
3612    var count;
3613
3614    if ( round ) {
3615      count = Math.floor(width / size);
3616    } else {
3617      count = Math.ceil(width / size);
3618    }
3619
3620    if (count < 1) count = 1;
3621    if (count > max) count = max;
3622
3623    return count;
3624  }
3625
3626  // Slider | Offer Thumb
3627
3628  function mfnSliderOfferThumb() {
3629
3630    var pager = function(el, i) {
3631      var img = $(el.$slides[i]).find('.thumbnail:first').html();
3632      return '<a>' + img + '</a>';
3633    };
3634
3635    $('.offer_thumb_ul').each(function() {
3636
3637      var slider = $(this);
3638
3639      slider.slick({
3640        cssEase: 'ease-out',
3641        arrows: false,
3642        dots: true,
3643        infinite: true,
3644        touchThreshold: 10,
3645        speed: 300,
3646
3647        adaptiveHeight: true,
3648        appendDots: slider.siblings('.slider_pagination'),
3649        customPaging: pager,
3650
3651        rtl: rtl ? true : false,
3652        autoplay: mfn.slider.offer ? true : false,
3653        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
3654
3655        slidesToShow: 1,
3656        slidesToScroll: 1
3657      });
3658
3659    });
3660  }
3661
3662  // Slider | Offer
3663
3664  function mfnSliderOffer() {
3665    $('.offer_ul').each(function() {
3666
3667      var slider = $(this);
3668
3669      slider.slick({
3670        cssEase: 'ease-out',
3671        dots: false,
3672        infinite: true,
3673        touchThreshold: 10,
3674        speed: 300,
3675
3676        prevArrow: '<a class="slider_prev" href="#"><span class="button_icon"><i class="icon-up-open-big" aria-label="previous slide"></i></span></a>',
3677        nextArrow: '<a class="slider_next" href="#"><span class="button_icon"><i class="icon-down-open-big" aria-label="next slide"></i></span></a>',
3678
3679        adaptiveHeight: true,
3680        //customPaging 	: pager,
3681
3682        rtl: rtl ? true : false,
3683        autoplay: mfn.slider.offer ? true : false,
3684        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
3685
3686        slidesToShow: 1,
3687        slidesToScroll: 1
3688      });
3689
3690      // Pagination | Show (css)
3691
3692      slider.siblings('.slider_pagination').addClass('show');
3693
3694      // Pager | Set slide number after change
3695
3696      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
3697        slider.siblings('.slider_pagination').find('.current').text(currentSlide + 1);
3698      });
3699
3700    });
3701  }
3702
3703  // Slider | Shop
3704
3705  function mfnSliderShop() {
3706
3707    var pager = function(el, i) {
3708      return '<a>' + i + '</a>';
3709    };
3710
3711    $('.shop_slider_ul').each(function() {
3712
3713      var slider = $(this);
3714      var slidesToShow = 4;
3715
3716      var count = slider.closest('.shop_slider').data('count');
3717      if (slidesToShow > count) {
3718        slidesToShow = count;
3719        if (slidesToShow < 1) {
3720          slidesToShow = 1;
3721        }
3722      }
3723
3724      slider.slick({
3725        cssEase: 'ease-out',
3726        dots: true,
3727        infinite: true,
3728        touchThreshold: 10,
3729        speed: 300,
3730
3731        prevArrow: '<a class="button the-icon slider_prev" href="#"><span class="button_icon"><i class="icon-left-open-big" aria-label="previous slide"></i></span></a>',
3732        nextArrow: '<a class="button the-icon slider_next" href="#"><span class="button_icon"><i class="icon-right-open-big" aria-label="next slide"></i></span></a>',
3733        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
3734
3735        appendDots: slider.siblings('.slider_pager'),
3736        customPaging: pager,
3737
3738        rtl: rtl ? true : false,
3739        autoplay: mfn.slider.shop ? true : false,
3740        autoplaySpeed: mfn.slider.shop ? mfn.slider.shop : 5000,
3741
3742        slidesToShow: slickAutoResponsive(slider, slidesToShow),
3743        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
3744      });
3745
3746      // ON | debouncedresize
3747
3748      $(window).on('debouncedresize', function() {
3749        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
3750        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
3751      });
3752
3753    });
3754  }
3755
3756  // Slider | Blog
3757
3758  function mfnSliderBlog() {
3759
3760    var pager = function(el, i) {
3761      return '<a>' + i + '</a>';
3762    };
3763
3764    $('.blog_slider_ul').each(function() {
3765
3766      var slider = $(this);
3767      var slidesToShow = 4;
3768
3769      var count = slider.closest('.blog_slider').data('count');
3770      var singlePostMode = slider.closest('.blog_slider').hasClass('single_post_mode');
3771
3772      if (slidesToShow > count) {
3773        slidesToShow = count;
3774        if (slidesToShow < 1) {
3775          slidesToShow = 1;
3776        }
3777      }
3778
3779      if (singlePostMode) {
3780        slidesToShow = 1;
3781      }
3782
3783      slider.slick({
3784        cssEase: 'ease-out',
3785        dots: true,
3786        infinite: true,
3787        touchThreshold: 10,
3788        speed: 300,
3789
3790        prevArrow: '<a class="button the-icon slider_prev" href="#"><span class="button_icon"><i class="icon-left-open-big" aria-label="previous slide"></i></span></a>',
3791        nextArrow: '<a class="button the-icon slider_next" href="#"><span class="button_icon"><i class="icon-right-open-big" aria-label="next slide"></i></span></a>',
3792        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
3793
3794        appendDots: slider.siblings('.slider_pager'),
3795        customPaging: pager,
3796
3797        rtl: rtl ? true : false,
3798        autoplay: mfn.slider.blog ? true : false,
3799        autoplaySpeed: mfn.slider.blog ? mfn.slider.blog : 5000,
3800
3801        slidesToShow: slickAutoResponsive(slider, slidesToShow),
3802        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
3803      });
3804
3805      // On | debouncedresize
3806
3807      $(window).on('debouncedresize', function() {
3808        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
3809        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
3810      });
3811
3812    });
3813  }
3814
3815  // Slider | Clients
3816
3817  function mfnSliderClients() {
3818    $('.clients_slider_ul').each(function() {
3819
3820      var slider = $(this);
3821
3822      var clientsPerSlide = slider.closest('.clients_slider').attr('data-client-per-slide') ? parseInt(slider.closest('.clients_slider').attr('data-client-per-slide')) : 4;
3823      var navigationPosition = slider.closest('.clients_slider').attr('data-navigation-position') || false;
3824      var appendArrows = ( navigationPosition == 'content' ) ? slider : slider.siblings('.blog_slider_header').children('.slider_navigation');
3825      var size = 400;
3826
3827      var calc = () => slickAutoResponsive(slider, clientsPerSlide, size - (clientsPerSlide * 40), true);
3828      var calcScroll = calc;
3829      var slidesToScroll = slider.closest('.clients_slider').attr('data-sli
3829des-to-scroll') ? parseInt(slider.closest('.clients_slider').attr('data-slides-to-scroll')) : calc();
3830
3831      if( 1 === slidesToScroll ){
3832        calcScroll = () => slickAutoResponsive(slider, 1, size - (clientsPerSlide * 40), true);
3833      }
3834
3835      slider.slick({
3836        cssEase: 'ease-out',
3837        dots: false,
3838        infinite: true,
3839        touchThreshold: 10,
3840        speed: 300,
3841
3842        prevArrow: '<a class="button the-icon slider_prev" href="#"><span class="button_icon"><i class="icon-left-open-big" aria-label="previous slide"></i></span></a>',
3843        nextArrow: '<a class="button the-icon slider_next" href="#"><span class="button_icon"><i class="icon-right-open-big" aria-label="next slide"></i></span></a>',
3844        appendArrows: appendArrows,
3845
3846        rtl: rtl ? true : false,
3847        autoplay: mfn.slider.clients ? true : false,
3848        autoplaySpeed: mfn.slider.clients ? mfn.slider.clients : 5000,
3849
3850        slidesToShow: calc(),
3851        slidesToScroll: calcScroll()
3852      });
3853
3854      // ON | debouncedresize
3855
3856      $(window).on('debouncedresize', function() {
3857        slider.slick('slickSetOption', 'slidesToShow', calc(), false);
3858        slider.slick('slickSetOption', 'slidesToScroll', calcScroll(), true);
3859      });
3860
3861    });
3862  }
3863
3864  // Slider | Portfolio
3865
3866  function sliderPortfolio() {
3867
3868    $('.portfolio_slider_ul').each(function() {
3869
3870      var slider = $(this);
3871      var size = 380;
3872      var scroll = 5;
3873
3874      if (slider.closest('.portfolio_slider').data('size')) {
3875        size = slider.closest('.portfolio_slider').data('size');
3876      }
3877
3878      if (slider.closest('.portfolio_slider').data('size')) {
3879        scroll = slider.closest('.portfolio_slider').data('scroll');
3880      }
3881
3882      slider.slick({
3883        cssEase: 'ease-out',
3884        dots: false,
3885        infinite: true,
3886        touchThreshold: 10,
3887        speed: 300,
3888
3889        prevArrow: '<a class="slider_nav slider_prev themebg" href="#"><i class="icon-left-open-big" aria-label="previous slide"></i></a>',
3890        nextArrow: '<a class="slider_nav slider_next themebg" href="#"><i class="icon-right-open-big" aria-label="next slide"></i></a>',
3891
3892        rtl: rtl ? true : false,
3893        autoplay: mfn.slider.portfolio ? true : false,
3894        autoplaySpeed: mfn.slider.portfolio ? mfn.slider.portfolio : 5000,
3895
3896        slidesToShow: slickAutoResponsive(slider, 5, size),
3897        slidesToScroll: slickAutoResponsive(slider, scroll, size)
3898      });
3899
3900      // ON | debouncedresize
3901      $(window).on('debouncedresize', function() {
3902        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, 5, size), false);
3903        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, scroll, size), true);
3904      });
3905
3906    });
3907  }
3908
3909  // header promo bar | Slider
3910
3911  function promoBarSlider() {
3912    $('.promo_bar_slider').each(function() {
3913      var speed = parseInt($(this).attr('data-speed')) * 1000;
3914
3915      var $slider = $(this);
3916      $slider.find( '.pbs_one' ).first().addClass('pbs-active');
3917      $slider.addClass('mfn-initialized');
3918
3919      function changeSlide() {
3920        var $current = $slider.find( '.pbs_one.pbs-active' );
3921        var $next = $slider.find( '.pbs_one.pbs-active' ).next();
3922        if( !$next.length ) $next = $slider.find( '.pbs_one' ).first();
3923
3924        $current.addClass('pbs-active-ends');
3925
3926        setTimeout(function() {
3927          $current.removeClass('pbs-active pbs-active-ends');
3928          $next.addClass('pbs-active');
3929        }, 300);
3930
3931      }
3932
3933      if( $slider.find( '.pbs_one' ).length > 1 ){
3934        setInterval(changeSlide, speed);
3935      }
3936
3937    });
3938  }
3939
3940  // section slider
3941
3942  function queryLoopSlider() {
3943    $('body:not(.mfn-ui) .mfn-looped-items-slider').each(function(i) {
3944
3945      const swipers = [];
3946
3947      var $slider = $(this);
3948
3949      let swiperClass = 'mfn-ql-slider-'+i;
3950
3951      $slider.addClass(swiperClass);
3952
3953      var swiperParams = {
3954        spaceBetween: parseInt($slider.attr('data-space_desktop')),
3955        slidesPerView: parseInt($slider.attr('data-columns-mobile')),
3956      };
3957
3958      if( typeof $slider.attr('data-dots') !== 'undefined' && $slider.attr('data-dots') == '1' ){
3959        $slider.parent().append('<div class="swiper-pagination mfn-swiper-pagination-'+i+'"></div>');
3960        swiperParams['pagination'] = {
3961          el: ".mfn-swiper-pagination-"+i,
3962          clickable: true,
3963        };
3964      }
3965
3966      /*if( $slider.attr('data-animation') == 'fade' ){
3967        swiperParams['effect'] = 'fade';
3968      }*/
3969
3970      if( $slider.attr('data-infinity') == '1' ){
3971        swiperParams['loop'] = true;
3972      }
3973
3974      if( $slider.attr('data-arrows') == '1' ){
3975        $slider.parent().append('<div class="swiper-button-next mfn-swiper-arrow mfn-swiper-button-next-'+i+'"><i class="'+$slider.attr('data-arrownext')+'"></i></div><div class="swiper-button-prev mfn-swiper-arrow mfn-swiper-button-prev-'+i+'"><i class="'+$slider.attr('data-arrowprev')+'"></i></div>');
3976        swiperParams['navigation'] = {
3977          nextEl: ".mfn-swiper-button-next-"+i,
3978          prevEl: ".mfn-swiper-button-prev-"+i,
3979        };
3980      }
3981
3982      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-autoplay') !== 'undefined' && parseFloat($slider.attr('data-autoplay')) > 0 ){
3983        swiperParams['autoplay'] = {
3984          delay: parseFloat($slider.attr('data-autoplay')),
3985          disableOnInteraction: true,
3986        };
3987      }
3988
3989      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-mousewheel') !== 'undefined' && $slider.attr('data-mousewheel') > 0 ){
3990        swiperParams['mousewheel'] = true;
3991      }
3992
3993      if( $('body').hasClass('mfn-ui') ){
3994        swiperParams['allowTouchMove'] = false;
3995      }
3996
3997      // popup fix
3998      if( $slider.closest('.mfn-popup-tmpl').length ){
3999        swiperParams['observer'] = true;
4000        swiperParams['observeParents'] = true;
4001      }
4002
4003      swiperParams['breakpoints'] = {
4004        768: {
4005          spaceBetween: parseInt($slider.attr('data-space_desktop')),
4006          slidesPerView: parseInt($slider.attr('data-columns-tablet'))
4007        },
4008        960: {
4009          spaceBetween: parseInt($slider.attr('data-space_desktop')),
4010          slidesPerView: parseInt($slider.attr('data-columns'))
4011        }
4012      };
4013
4014      swipers[i] = new Swiper('.'+swiperClass, swiperParams);
4015
4016      swipers[i].on('slideChange', function () {
4017        $(window).trigger('scroll');
4018      });
4019
4020      /*swipers[i].on('beforeSlideChangeStart', function(swiper) {
4021        $(swiper.el).find('.mcb-column.animate').each(function() {
4022          $(this).removeClass( $(this).attr('data-anim-type') );
4023        });
4024      })*/
4025
4026    });
4027  }
4028
4029  // Slider | Slider
4030
4031  function sliderSlider() {
4032
4033    var pager = function(el, i) {
4034      return '<a>' + i + '</a>';
4035    };
4036
4037    $('.content_slider_ul').each(function() {
4038
4039      var slider = $(this);
4040      var count = 1;
4041      var centerMode = false;
4042
4043      if (slider.closest('.content_slider').hasClass('carousel')) {
4044        count = slickAutoResponsive(slider);
4045
4046        $(window).on('debouncedresize', function() {
4047          slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider), false);
4048          slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider), true);
4049        });
4050      }
4051
4052      if (slider.closest('.content_slider').hasClass('center')) {
4053        centerMode = true;
4054      }
4055
4056      slider.slick({
4057        cssEase: 'cubic-bezier(.4,0,.2,1)',
4058        dots: true,
4059        infinite: true,
4060        touchThreshold: 10,
4061        speed: 300,
4062
4063        centerMode: centerMode,
4064        centerPadding: '20%',
4065
4066        prevArrow: '<a class="button the-icon slider_prev" href="#"><span class="button_icon"><i class="icon-left-open-big" aria-label="previous slide"></i></span></a>',
4067        nextArrow: '<a class="button the-icon slider_next" href="#"><span class="button_icon"><i class="icon-right-open-big" aria-label="next slide"></i></span></a>',
4068
4069        adaptiveHeight: true,
4070        appendDots: slider.siblings('.slider_pager'),
4071        customPaging: pager,
4072
4073        rtl: rtl ? true : false,
4074        autoplay: mfn.slider.slider ? true : false,
4075        autoplaySpeed: mfn.slider.slider ? mfn.slider.slider : 5000,
4076
4077        slidesToShow: count,
4078        slidesToScroll: count
4079      });
4080
4081      // Lightbox | disable on dragstart
4082
4083      var clickEvent = false;
4084
4085      slider.on('dragstart', '.slick-slide a[rel="lightbox"]', function(event) {
4086        if (lightboxAttr) {
4087          var events = $._data(this,'events');
4088          if( events && Object.prototype.hasOwnProperty.call(events, 'click') ){
4089            clickEvent = events.click[0];
4090            $(this).addClass('off-click').off('click');
4091          }
4092        }
4093      });
4094
4095      // Lightbox | enable after change
4096
4097      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
4098        if (lightboxAttr) {
4099          $('a.off-click[rel="lightbox"]', slider).removeClass('off-click').on('click', clickEvent);
4100        }
4101      });
4102
4103    });
4104  }
4105
4106  // Slider | Testimonials
4107
4108  function sliderTestimonials() {
4109
4110    var pager = function(el, i) {
4111      var img = $(el.$slides[i]).find('.single-photo-img').html();
4112      return '<a>' + img + '</a>';
4113    };
4114
4115    $('.testimonials_slider_ul').each(function() {
4116
4117      var slider = $(this);
4118
4119      slider.slick({
4120        cssEase: 'ease-out',
4121        dots: true,
4122        infinite: true,
4123        touchThreshold: 10,
4124        speed: 300,
4125
4126        prevArrow: '<a class="button the-icon slider_prev" href="#"><span class="button_icon"><i class="icon-left-open-big" aria-label="previous slide"></i></span></a>',
4127        nextArrow: '<a class="button the-icon slider_next" href="#"><span class="button_icon"><i class="icon-right-open-big" aria-label="next slide"></i></span></a>',
4128
4129        adaptiveHeight: true,
4130        appendDots: slider.siblings('.slider_pager'),
4131        customPaging: pager,
4132
4133        rtl: rtl ? true : false,
4134        autoplay: mfn.slider.testimonials ? true : false,
4135        autoplaySpeed: mfn.slider.testimonials ? mfn.slider.testimonials : 5000,
4136
4137        slidesToShow: 1,
4138        slidesToScroll: 1
4139      });
4140
4141    });
4142  }
4143
4144  /**
4145   * GDPR
4146   */
4147
4148  // GDPR | Close notice on click | BIND
4149
4150  $('.mfn-gdpr-button').on('click', function(){
4151    var closeAnimation = $('.mfn-gdpr-button').attr('data-animation');
4152    var barAligment = $('#mfn-gdpr').attr('data-aligment');
4153
4154    switch(true){
4155      case 'none' === closeAnimation:
4156        $('#mfn-gdpr').css('display', 'none');
4157        break;
4158      case 'fade' === closeAnimation:
4159        $('#mfn-gdpr').fadeOut(300);
4160        break;
4161      case 'slide' === closeAnimation && 'top' === barAligment:
4162        $('#mfn-gdpr').slideUp(300);
4163        break;
4164      default:
4165        $('#mfn-gdpr').slideToggle(300);
4166        break;
4167    }
4168
4169    // wait for animation end, then remove clasa and set cookies
4170    setTimeout(function(){
4171      $('#mfn-gdpr').removeClass('show');
4172      gdpr_set_cookie();
4173    }, 300);
4174  });
4175
4176  // GDPR | Set the cookie
4177
4178  function gdpr_set_cookie(){
4179    if(navigator.cookieEnabled) {
4180      var cookieDays = $('.mfn-gdpr-button').attr('data-cookiedays') || 365;
4181      var cookieDate = new Date();
4182      var cookieText = '';
4183
4184      cookieDate.setTime(cookieDate.getTime() + (cookieDays * 24 * 60 * 60 * 1000));
4185      cookieText += "mfn-gdpr=1";
4186      cookieText += "; expires=" + cookieDate.toUTCString() + ';';
4187      cookieText += "; path=" + mfn.home_url + '/';
4188
4189      document.cookie = cookieText;
4190    }
4191  }
4192
4193  // GDPR | Display, if cookie not accepted
4194
4195  function gdpr(){
4196    if (document.cookie !== "") {
4197      var cookies = document.cookie.split(/; */);
4198
4199      for (var cookie of cookies) {
4200        var [ cookieName ] = cookie.split("=");
4201
4202        if (cookieName === 'mfn-gdpr') {
4203          return; // cookie exists
4204        }
4205      }
4206    }
4207
4208    $('#mfn-gdpr').addClass('show'); //cookie does NOT exist
4209  }
4210
4211  /*
4212   * Infinite scroll functionality
4213   */
4214
4215  function infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection){
4216
4217    // for proper check, if we need to fetch posts again.
4218    var screenHeight = document.body.clientHeight;
4219
4220    if ( infiniteLoadContainer.attr('data-attr') === $(infiniteLoadButton).attr('href') ) {
4221      return; // it means, that maximum length of pages is crossed
4222    } else if (scrollDirection === 'down') {
4223
4224      // attach link for check, and click the load more button!
4225      infiniteLoadContainer.attr('data-attr', $(infiniteLoadButton).attr('href'));
4226      infiniteLoadButton.click();
4227
4228      // prevention, when height did not change enought, load again
4229      setTimeout(function(){
4230        var heightAfterLoadDifference = (document.body.clientHeight - screenHeight);
4231
4232        if( heightAfterLoadDifference < 249 ) {
4233          infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection);
4234        }
4235      }, 500);
4236
4237    }
4238  }
4239
4240/*  function infiniteScrollPortfolio(){
4241    var infiniteLoadContainer = $('.mfn-infinite-load-button');
4242    var infiniteLoadButton = $('.mfn-infinite-load-button a');
4243
4244    $(infiniteLoadContainer).waypoint({
4245      handler: function(direction) {
4246        infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, direction);
4247      },
4248      offset: function(){
4249        //after each load, calc the offset of element to know when posts should be loaded
4250        var offsetPosition = - ( ($(this)[0].element.scrollHeight) - (window.innerHeight / 1.2) );
4251        return offsetPosition;
4252      }
4253    });
4254
4255
4256  } */
4257
4258  /*
4259   * Table of Contents | toc
4260   */
4261
4262  $('body').on('click', ".table_of_content .toggle", function(e){
4263
4264    e.preventDefault();
4265
4266    if( $('.table_of_content').hasClass('hide') ){
4267
4268      $('.table_of_content').removeClass('hide');
4269
4270      $('.table_of_content_wrapper').slideDown( {
4271        duration: 400,
4272        always: function(){
4273          $('.table_of_content').removeClass('hide_on_start');
4274        }
4275      });
4276
4277    } else {
4278
4279      $('.table_of_content_wrapper').slideUp( {
4280        duration: 400
4281      });
4282
4283      $('.table_of_content').addClass('hide');
4284
4285    }
4286
4287  });
4288
4289  function tableContentAttachId(){
4290    const container = $('.table_of_content');
4291    let tags;
4292    let anchorNumber = 0;
4293    let anchorDom = $('.table_of_content_wrapper').find('a');
4294
4295
4296    if(tags = container.attr('data-tags')){
4297      tags = tags.split(/[ ,]+/).join(','); //remove spaces, add commas
4298
4299      // muffin builder, gutenberg, elementor
4300      let columns = $('#Content .mfn-builder-content .column_column, #Content .mfn-builder-content .column_heading, #Content .mfn-builder-content .column_fancy_heading, .the_content_wrapper:not(.is-elementor), .elementor-widget:not(.elementor-widget-mfn_table_of_contents)');
4301
4302      $(columns).each( ( index, element ) => {
4303        let headingsNoticed = $(element).find(tags); //look for headings
4304
4305        $(headingsNoticed).each( ( index, element ) => {
4306
4307          if( $(element).attr('id') ) { //replace toc_X with user assigned ID
4308
4309            const idSet = '#'+$(element).attr('id');
4310            $(anchorDom[anchorNumber]).attr('href', idSet );
4311
4312          }else{
4313
4314            let id = $(anchorDom[anchorNumber]).attr('href');
4315            $(element).attr('id', id.substr(1) );
4316
4317          }
4318
4319          anchorNumber++;
4320        })
4321
4322      })
4323
4324    }
4325  }
4326
4327  /**
4328   * Off-canvas sidebar
4329   */
4330
4331  var offCanvasSidebar = {
4332    init: function() {
4333      $(document).on('click', '.mfn-off-canvas-switcher', function(e) {
4334        e.preventDefault();
4335        if( $('html').hasClass('mfn-ofcs-opened') ){
4336          $('html').removeClass('mfn-ofcs-opened');
4337        }else{
4338          $('html').addClass('mfn-ofcs-opened');
4339        }
4340      });
4341    },
4342    mobile: function() {
4343      if( $('.sidebar .widget-area').length && $('body').hasClass('ofcs-mobile') ){
4344
4345        if( !$('.mfn-off-canvas-sidebar').length ){
4346          $('body').append('<div class="mfn-off-canvas-overlay"></div><div class="mfn-off-canvas-sidebar"><div class="mfn-off-canvas-switcher"><i class="icon-list" aria-label="off-canvas sidebar toggle"></i></div><div class="mfn-off-canvas-content-wrapper"><div class="mfn-off-canvas-content"></div></div></div>');
4347        }
4348
4349        if( $('body').hasClass('woocommerce-shop') && !$('.mfn-woo-filters-wrapper .mfn-off-canvas-switcher').length ){
4350          $('.mfn-woo-filters-wrapper').append('<a class="open-filters mfn-off-canvas-switcher" href="#"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-label="off-canvas sidebar toggle"><defs><style>.path{fill:none;stroke:#000;stroke-miterlimit:10;}</style></defs><g><line x1="8" y1="11" x2="14" y2="11" class="path"></line><line x1="2" y1="11" x2="4" y2="11" class="path"></line><line x1="12" y1="5" x2="14" y2="5" class="path"></line><line x1="2" y1="5" x2="8" y2="5" class="path"></line><circle cx="6" cy="11" r="2" class="path"></circle><circle cx="10" cy="5" r="2" class="path"></circle></g></svg></a>');
4351        }
4352
4353        var $ofcs = $('.mfn-off-canvas-sidebar .mfn-off-canvas-content-wrapper .mfn-off-canvas-content');
4354        $ofcs.empty();
4355
4356        $('.sidebar .widget-area').each(function() {
4357          //var $sdbr = $(this).clone(true);
4358          $ofcs.append( $(this) );
4359          //$(this).hide();
4360        });
4361
4362        offCanvasSidebar.init();
4363
4364      }
4365    }
4366  }
4367
4368  function alignHeights(){
4369    var i = 0;
4370    if( !$('.mfn-align-heights').length ) return;
4371    $('.mfn-align-heights').each(function() {
4372      var max=0;
4373      var newclass = 'mfn-align-cont-'+i;
4374      $(this).addClass(newclass);
4375      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: auto;} </style>").appendTo("body");
4376      $("."+newclass+" .mfn-align-me").each(function() {
4377        if($(this).outerHeight() > max){max = $(this).outerHeight();}
4378      });
4379      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: "+max+"px;} </style>").appendTo("body");
4380      i++;
4381    });
4382  }
4383
4384  $(window).on('debouncedresize', alignHeights);
4385
4386  var headerMegamenu = {
4387    init: function() {
4388
4389      if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children').length ){
4390        $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children > a').on('click', function(e) {
4391          let href = $(this).attr('href');
4392          if( !$(this).parent('li').hasClass('mfn-li-childrens-show') ){
4393            e.preventDefault();
4394            e.stopPropagation();
4395            $(this).siblings('ul').slideDown(300);
4396            $(this).parent('li').addClass('mfn-li-childrens-show');
4397          }else if( href == '' || href == '#' ){
4398            e.preventDefault();
4399            e.stopPropagation();
4400            $(this).siblings('ul').slideUp(300);
4401            $(this).parent('li').removeClass('mfn-li-childrens-show');
4402          }
4403        });
4404      }
4405
4406      /**
4407       * Submenu in mega menu
4408       * */
4409
4410      if( $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li').length ){
4411        $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li > a').on('click', function(e) {
4412          if( $(this).closest('li').hasClass('menu-item-has-children') && !$(this).closest('li').hasClass('mfn-li-hover') ){
4413            e.preventDefault();
4414            e.stopPropagation();
4415            $(this).closest('li').addClass('mfn-li-hover');
4416          }
4417        });
4418      }
4419
4420      if( $('ul.mfn-menu-submenu-on-hover li.mfn-menu-item-has-megamenu, li.mfn-theme-options-menu.mfn-menu-item-has-megamenu').length ){
4421        $('ul.mfn-menu-submenu-on-hover li.mfn-menu-item-has-megamenu, li.mfn-theme-options-menu.mfn-menu-item-has-megamenu').on('mouseenter', function() {
4422          if( $(this).find('.mfn-megamenu-full-width').length || $(this).find('.mfn-megamenu-grid').length ){
4423            headerMegamenu.setLeft($(this));
4424          }
4425        });
4426      }
4427
4428      if( $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu').length ){
4429
4430        $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu > a.mfn-menu-link').on('click', function(e) {
4431          let href = $(this).attr('href');
4432
4433          if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ){
4434            headerMegamenu.setLeft($(this).closest('li'));
4435          }
4436
4437          if( href == '' || href == '#' ){
4438            e.preventDefault();
4439            e.stopPropagation();
4440            if( $(this).closest('li').hasClass('mfn-li-hover') ) {
4441              $(this).closest('li').removeClass('mfn-li-hover');
4442              $(document).unbind('click', headerTemplate.bindUnclick);
4443              $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
4444            }else{
4445              $(this).closest('li').addClass('mfn-li-hover');
4446              $(document).bind('click', headerTemplate.bindUnclick);
4447              headerTemplate.animContentAddClass();
4448            }
4449          }else if( !$(this).closest('li').hasClass('mfn-li-hover') ){
4450            e.preventDefault();
4451            e.stopPropagation();
4452            $('.mfn-header-tmpl ul li.mfn-li-hover').removeClass('mfn-li-hover');
4453            if( !$(this).closest('.mfn-megamenu-menu').length && !$(this).closest('li.mfn-li-hover').length ) {
4454              if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').length ){
4455                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show ul').slideUp();
4456                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').removeClass('mfn-li-childrens-show');
4457              }
4458            }
4459            headerTemplate.animContentAddClass();
4460            $(this).parent('li').addClass('mfn-li-hover');
4461            $(document).bind('click', headerTemplate.bindUnclick);
4462          }
4463
4464        });
4465
4466      }
4467
4468    },
4469    setLeft: function($li) {
4470      var $mm = $li.find('.mfn-menu-item-megamenu');
4471      var left = $li.offset().left;
4472      $mm.css('width', $(window).width()+'px');
4473      $mm.css('left', '-'+left+'px');
4474
4475      //$(window).trigger('resize');
4476    }
4477  }
4478
4479  var footerTemplate = {
4480    init: function() {
4481      if( $('body').hasClass('mfn-footer-stick') ){
4482        footerTemplate.isSticky();
4483      }
4484      if( $('body').hasClass('mfn-footer-sliding') || $('body').hasClass('mfn-footer-fixed') ){
4485        footerTemplate.isSliding();
4486      }
4487      return;
4488    },
4489    isSticky: function() {
4490      var offsetTop = $('.mfn-footer-tmpl').offset().top + $('.mfn-footer-tmpl').outerHeight();
4491      if( offsetTop < $(window).height() ){
4492        $('.mfn-footer-tmpl').addClass('is-sticky');
4493      }else{
4494        $('.mfn-footer-tmpl').removeClass('is-sticky');
4495      }
4496    },
4497    isSliding: function() {
4498      var footer = $('.mfn-footer-tmpl').outerHeight();
4499      $('#Content').css('margin-bottom', footer);
4500    }
4501  }
4502
4503  var headerTemplate = {
4504    hasSticky: false,
4505    isMobile: false,
4506    offsetScroll: 60,
4507    hasBodyOffset: false,
4508    height: 0,
4509    type: 'default',
4510    animContentOnHover: function() {
4511
4512      if( $('.mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu').hasClass('mfn-menu-submenu-on-hover') ){
4513        $('.mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu.mfn-menu-submenu-on-hover > li.mfn-menu-item-has-megamenu, .mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu.mfn-menu-submenu-on-hover > li.menu-item-has-children').on('mouseenter', function() {
4514          headerTemplate.animContentAddClass();
4515        });
4516      }
4517
4518      $('.mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu.mfn-menu-submenu-on-hover > li.mfn-menu-item-has-megamenu, .mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu.mfn-menu-submenu-on-hover > li.menu-item-has-children').on('mouseleave', function() {
4519        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
4520      });
4521
4522    },
4523    animContentAddClass: function() {
4524      if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-blur') ){
4525        $('body').addClass('mfn-content-blur');
4526      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-gray') ){
4527        $('body').addClass('mfn-content-gray');
4528      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-overlay') ){
4529        $('body').addClass('mfn-content-overlay');
4530      }
4531    },
4532    openOnClick: function() {
4533
4534      // common
4535      $('.mfn-header-tmpl .mfn-header-menu.mfn-menu-submenu-on-click li.menu-item-has-children > a.mfn-menu-link').off().on('click', function(e) {
4536        let href = $(this).attr('href');
4537
4538        if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ){
4539          headerMegamenu.setLeft($(this).closest('li'));
4540        }
4541
4542        if( href == '' || href == '#' ){
4543          e.preventDefault();
4544          e.stopPropagation();
4545          if( $(this).closest('li').hasClass('mfn-li-hover') ) {
4546            $(this).closest('li').removeClass('mfn-li-hover');
4547            $(document).unbind('click', headerTemplate.bindUnclick);
4548            $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
4549          }else{
4550            $(this).closest('li').addClass('mfn-li-hover');
4551            $(document).bind('click', headerTemplate.bindUnclick);
4552            headerTemplate.animContentAddClass();
4553          }
4554        }else if( !$(this).closest('li').hasClass('mfn-li-hover') ){
4555          e.preventDefault();
4556          e.stopPropagation();
4557          //$('.mfn-header-tmpl ul li.mfn-li-hover').removeClass('mfn-li-hover');
4558          headerTemplate.animContentAddClass();
4559          $(this).parent('li').addClass('mfn-li-hover');
4560          $(document).bind('click', headerTemplate.bindUnclick);
4561        }
4562
4563      });
4564
4565    },
4566    bindUnclick: function(e) {
4567      var $li = $('.mfn-header-tmpl ul li.mfn-li-hover');
4568      if (!$li.is(e.target)) {
4569        $li.removeClass('mfn-li-hover');
4570        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
4571        $(document).unbind('click', headerTemplate.bindUnclick);
4572      }
4573    },
4574    closeable: function() {
4575      // common
4576      $('.mfn-header-tmpl .close-closeable-section').on('click', function() {
4577        var $section = $(this).closest('.mcb-section');
4578        $section.addClass('closeable-hidden').slideUp(300, function() {
4579          headerTemplate.resetOffset();
4580          headerTemplate.offset();
4581        });
4582
4583        if( typeof $section.attr('data-close-days') !== 'undefined' && $section.attr('data-close-days') != '0' ){
4584          var days = $section.attr('data-close-days');
4585          var uid = $section.attr('data-uid');
4586          var date=new Date();
4587          date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
4588          var expires="; expires="+date.toGMTString();
4589          document.cookie="mfn_closed_section="+uid+expires+"; path=/"
4590        }
4591
4592      });
4593    },
4594    resetOffset: function() {
4595      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
4596        $('#Wrapper').css({ 'padding-top': $('.mfn-header-tmpl').outerHeight() });
4597      }
4598    },
4599    offset: function() {
4600      if( headerTemplate.hasSticky && !headerTemplate.isMobile ) return;
4601      headerTemplate.offsetScroll = 0;
4602      var _screen = 'default';
4603      if( $(window).width() < 767 ) _screen = 'header-mobile';
4604      $('.mfn-header-tmpl .mfn-'+_screen+'-section.hide-on-scroll:not(.closeable-hidden)').each(function() {
4605          headerTemplate.offsetScroll += $(this).outerHeight();
4606      });
4607
4608    },
4609    init: function() {
4610      headerTemplate.hasBodyOffset = false;
4611
4612      if( $(window).width() < 767 && $('.mfn-header-tmpl').hasClass('mfn-hasMobile') ){
4613        headerTemplate.isMobile = true;
4614        headerTemplate.type = $('.mfn-header-tmpl').attr('data-mobile-type');
4615        if( $('.mfn-header-tmpl').hasClass('mfn-mobile-header-body-offset') ) {
4616          headerTemplate.hasBodyOffset = true;
4617        }else{
4618          headerTemplate.hasBodyOffset = false;
4619        }
4620      }else{
4621        headerTemplate.isMobile = false;
4622        headerTemplate.type = $('.mfn-header-tmpl').attr('data-type');
4623        if( $('.mfn-header-tmpl').hasClass('mfn-header-body-offset') ) {
4624          headerTemplate.hasBodyOffset = true;
4625        }else{
4626          headerTemplate.hasBodyOffset = false;
4627        }
4628      }
4629
4630      // init submenu show on click
4631      if( $('.mfn-header-tmpl .mfn-menu-submenu-on-click').length ) {
4632        headerTemplate.openOnClick();
4633      }
4634
4635      if( $('.mfn-header-tmpl').hasClass('mfn-header-content-blur') || $('.mfn-header-tmpl').hasClass('mfn-header-content-gray') || $('.mfn-header-tmpl').hasClass('mfn-header-content-overlay') ){
4636        headerTemplate.animContentOnHover();
4637      }
4638
4639      // sticky header
4640      /*if( $('.mfn-header-tmpl .mfn-header-sticky-section').length ) {
4641        if( !headerTemplate.isMobile ){
4642          headerTemplate.hasSticky = true;
4643          $('.mfn-header-tmpl').addClass('mfn-hasSticky');
4644        }else{
4645          headerTemplate.hasSticky = false;
4646          $('.mfn-header-tmpl').removeClass('mfn-hasSticky');
4647        }
4648      }*/
4649
4650      if( $('.mfn-header-tmpl').hasClass('mfn-hasSticky') ) {
4651        headerTemplate.hasSticky = true;
4652      }else{
4653        headerTemplate.hasSticky = false;
4654      }
4655
4656      if( $('body style.tmp-mfn-header-template').length ) $('body style.tmp-mfn-header-template').remove();
4657
4658      if( $('.mfn-header-tmpl .close-closeable-section').length ) headerTemplate.closeable();
4659
4660      if( $('body').hasClass('mfn-header-scrolled') && !$('.mfn-builder-active').length ) $('body').removeClass('mfn-header-scrolled');
4661
4662      headerTemplate.getHeight();
4663      headerTemplate.offset();
4664
4665      headerTemplate.scroll();
4666
4667      if( $(window).scrollTop() > 10 ){
4668        $(window).trigger('scroll');
4669      }
4670    },
4671    scroll: function() {
4672
4673      // relative header prevent skip with sticky
4674      if( $('.mfn-header-tmpl').hasClass('mfn-header-tmpl-default') && headerTemplate.hasSticky && !headerTemplate.isMobile ) {
4675        $('body').append('<style class="tmp-mfn-header-template">html body.mfn-header-scrolled{padding-top: '+headerTemplate.height+'px;}</style>');
4676      }
4677
4678      $(window).scroll(function() {
4679        var scrolled = $(this).scrollTop();
4680        var scroll_offset = headerTemplate.offsetScroll;
4681        if( headerTemplate.hasSticky ) scroll_offset = headerTemplate.height;
4682
4683        if(scrolled > scroll_offset){
4684            $('body').addClass('mfn-header-scrolled');
4685
4686            if( $('.mfn-header-tmpl').hasClass('mfn-header-tmpl-fixed') && $('.mfn-header-tmpl .hide-on-scroll:not(.closeable-hidden)').length ){
4687              if( headerTemplate.hasSticky ){
4688                $('.mfn-header-tmpl').css({'top': 0});
4689              }else{
4690                $('.mfn-header-tmpl').css({'top': '-'+headerTemplate.offsetScroll+'px'});
4691              }
4692            }
4693
4694          }else{
4695            $('body').removeClass('mfn-header-scrolled');
4696
4697            if( $('.mfn-header-tmpl').hasClass('mfn-header-tmpl-fixed') && $('.mfn-header-tmpl .hide-on-scroll:not(.closeable-hidden)').length ){
4698              $('.mfn-header-tmpl').css({'top': '-'+scrolled+'px'});
4699            }
4700
4701          }
4702      });
4703    },
4704    getHeight: function() {
4705      headerTemplate.height = $('.mfn-header-tmpl').outerHeight();
4706      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
4707        $('#Wrapper').css({ 'padding-top' : headerTemplate.height });
4708      }else{
4709        $('#Wrapper').removeAttr('style');
4710      }
4711      $('.mfn-header-tmpl').removeAttr('style');
4712    },
4713  }
4714
4715
4716  /**
4717   *
4718   * Popup template
4719   *
4720   * */
4721
4722  let mfnPopup = {
4723
4724    init: function() {
4725
4726      if( $('.open-mfn-popup').length ){
4727        $('.open-mfn-popup').on('click', function(e) {
4728          e.preventDefault();
4729          let popup_id = $(this).attr('data-mfnpopup');
4730
4731          if( popup_id == 'popup_id_required' ){
4732            alert('Popup ID id required');
4733          }else if( !$(popup_id).length ){
4734            alert('We cannot find popup with inserted ID');
4735          }else{
4736            mfnPopup.showPopup($(popup_id));
4737          }
4738        });
4739      }
4740
4741      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').length ) mfnPopup.showOnScroll();
4742      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').length ) mfnPopup.showOnDelay();
4743      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').length ) mfnPopup.showOnExit();
4744      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').length ) mfnPopup.showOnScrollToElement();
4745      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').length ) mfnPopup.showOnStart();
4746
4747      $(document).on('click', '.exit-mfn-popup', function(e) {
4748        e.preventDefault();
4749        let $popup = $(this).closest('.mfn-popup-tmpl');
4750        mfnPopup.hidePopup($popup);
4751      });
4752
4753    },
4754
4755    hidePopup: function( $popup ) {
4756      $popup.removeClass('mfn-popup-active');
4757      $('html').removeClass('mfn-popup-template-visible');
4758
4759      if( $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).length ){
4760        $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).remove();
4761      }
4762
4763      if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') || $popup.hasClass('mfn-popup-tmpl-display-one') ){
4764        let days = 365;
4765
4766        if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') ) days = parseInt($popup.attr('data-cookie'));
4767
4768        let cookie_name = 'mfn_popup_'+$popup.attr('data-id');
4769        mfnPopup.addCookie(days, cookie_name);
4770      }
4771
4772    },
4773
4774    showPopup: function( $popup ){
4775      if( !$popup.hasClass('mfn-popup-active') ) $popup.addClass('mfn-popup-active mfn-popup-showed');
4776
4777      if( $popup.hasClass('mfn-popup-tmpl-hide-automatically-delay') ) mfnPopup.hideAutomatically($popup);
4778      if( $popup.hasClass('mfn-popup-tmpl-close-button-show-delay') ) mfnPopup.showExitButton($popup);
4779
4780      if( !$('body').hasClass('mfn-ui') && $popup.hasClass('mfn-popup-close-on-overlay-click') ){
4781        $popup.bind('click',  mfnPopup.closeOverlayClick);
4782      }
4783
4784      if( typeof $popup.attr('data-blur') !== 'undefined' ){
4785        $('body').append('<style class="mfn-popup-tmpl-blur-'+$popup.attr('data-id')+'">#Wrapper{ filter: blur('+$popup.attr('data-blur')+'px) }</style>');
4786      }
4787
4788      $('html').addClass('mfn-popup-template-visible');
4789
4790      $(document).trigger('mfnPopupInit');
4791    },
4792
4793    closeOverlayClick: function(e) {
4794      var div = $(e.delegateTarget).find('.mfn-popup-tmpl-content-wrapper');
4795      if (!div.is(e.target) && div.has(e.target).length === 0){
4796          mfnPopup.hidePopup($(e.delegateTarget));
4797          $(e.delegateTarget).unbind('click', mfnPopup.closeOverlayClick);
4798      }
4799    },
4800
4801    hideAutomatically: function($popup) {
4802        if( $('body').hasClass('mfn-ui') ) return;
4803        let delay = parseInt( $popup.attr('data-hidedelay') );
4804        setTimeout(function() { mfnPopup.hidePopup($popup); }, delay);
4805    },
4806
4807    showExitButton: function($popup) {
4808      let delay = parseInt( $popup.attr('data-closebuttondelay') );
4809      setTimeout(function() { $popup.addClass('mfn-closebutton-active'); }, delay);
4810    },
4811
4812    showOnScroll: function() {
4813      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').each(function() {
4814        let $popup = $(this);
4815        let scroll_offset = parseInt( $popup.attr('data-display') );
4816
4817        $(window).on('scroll', function() {
4818          if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
4819        });
4820
4821      });
4822    },
4823
4824    showOnScrollToElement: function() {
4825      $('body').imagesLoaded(function() {
4826        $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').each(function() {
4827          let $popup = $(this);
4828          let scroll_offset = $($popup.attr('data-display')).length ? parseInt( $($popup.attr('data-display')).offset().top ) : 100;
4829
4830          $(window).on('scroll', function() {
4831            if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
4832          });
4833
4834        });
4835      });
4836    },
4837
4838    showOnDelay: function() {
4839      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').each(function() {
4840        let $popup = $(this);
4841        let delay = parseInt( $popup.attr('data-display') );
4842
4843        setTimeout(function() {
4844          mfnPopup.showPopup($popup)
4845        }, delay);
4846      });
4847    },
4848
4849    showOnExit: function() {
4850      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').each(function() {
4851        let $popup = $(this);
4852
4853        $(document).on('mouseleave', function() {
4854          mfnPopup.showPopup($popup)
4855        });
4856      });
4857    },
4858
4859    showOnStart: function() {
4860      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').each(function() {
4861        let $popup = $(this);
4862        mfnPopup.showPopup($popup)
4863      });
4864    },
4865
4866    addCookie(days, cookie_name){
4867
4868      let date=new Date();
4869      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
4870      let expires="; expires="+date.toGMTString();
4871      document.cookie=cookie_name+"=true"+expires+"; path=/";
4872
4873    }
4874
4875  }
4876
4877  /**
4878   * Lazy Load images
4879   */
4880
4881  document.addEventListener('DOMContentLoaded', () => {
4882
4883    const images = Array.from(document.querySelectorAll('img.mfn-lazy'));
4884
4885    if ('IntersectionObserver' in window) {
4886      const imageObserver = new IntersectionObserver((entries, observer) => {
4887        entries.forEach(entry => {
4888          if (entry.isIntersecting) {
4889            const image = entry.target;
4890            image.src = image.dataset.src;
4891            imageObserver.unobserve(image);
4892            window.dispatchEvent(new Event('resize'));
4893          }
4894        });
4895      });
4896
4897      images.forEach(img => imageObserver.observe(img));
4898    }
4899
4900  });
4901
4902})(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.