PageSourceSearch

https://ancientathens3d.com/wp-content/themes/betheme/js/scripts.js?ver=27.2.7

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