PageSourceSearch

https://www.marqalicante.com/wp-content/themes/betheme/js/scripts.js?ver=28.3

js marqalicante.com collected 2026-10-02 03:23:52 UTC 188,464 bytes, 6,538 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:not(.mfn-initialized)').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
30  // fix safari
31  jQuery('.gallery.equal-heights:not(.mfn-images-loaded)').each(function() {
32    var $el = jQuery(this);
33    $el.imagesLoaded(function() {
34      $el.addClass('mfn-images-loaded');
35    });
36  });
37
38  jQuery('.sections_group .gallery, .mcb-section .gallery, .elementor-section .gallery').each(function() {
39
40    var $el = jQuery(this);
41    var id = $el.attr('id');
42
43    if( $el.hasClass('mfn-initialized') ) return;
44
45    $el.children('br').remove();
46
47    $el.find('.gallery-icon').children('a')
48      .wrap('<div class="image_frame scale-with-grid"><div class="image_wrapper"></div></div>')
49      .prepend('<div class="mask"></div>')
50      .children('img')
51      /*.css('height', 'auto')
52      .css('width', '100%')*/;
53
54    // lightbox | link to media file
55
56    if ($el.hasClass('file')) {
57      $el.find('.gallery-icon a')
58        .attr('rel', 'prettyphoto[' + id + ']')
59        .attr('data-elementor-lightbox-slideshow', id); // FIX: elementor lightbox gallery
60    }
61
62    $el.find( '.gallery-item' ).each(function(){
63      var title = jQuery(this).data('title');
64      var description = jQuery(this).data('description');
65      jQuery('.gallery-icon a', jQuery(this))
66        .attr('data-elementor-lightbox-title', title)
67        .attr('data-elementor-lightbox-description', description);
68    });
69
70    // isotope for masonry layout
71
72    if ($el.hasClass('masonry')) {
73
74      /*mfnIsotope.addIsotopeLocation({
75        name: 'Wordpress && Elementor - Masonry gallery',
76        location: $el,
77        settings: {
78          itemSelector: '.gallery-item',
79          layoutMode: 'masonry',
80          isOriginLeft: rtl ? false : true
81        }
82      })
83
84      mfnIsotope.runIsotopes();*/
85
86      $el.imagesLoaded(function() {
87
88        $el.isotope({
89          itemSelector: '.gallery-item',
90          layoutMode: 'masonry',
91          isOriginLeft: jQuery('body').hasClass('rtl') ? false : true
92        });
93
94        $el.addClass('mfn-initialized');
95
96      });
97
98    }
99
100  });
101}
102
103function redrawAllRevolutionSliders() {
104  let slidersFound = false;
105  for (const prop in window) {
106    if (prop.startsWith('revapi') && typeof window[prop] === 'object' && window[prop] !== null) {
107      const revapiInstance = window[prop];
108
109      if (typeof revapiInstance.revredraw === 'function') {
110        slidersFound = true;
111        setTimeout(function() {
112          revapiInstance.revredraw();
113          console.log(`Revolution Slider instance (${prop}) redrawn.`);
114        }, 50);
115      }
116    }
117  }
118}
119
120(function($) {
121
122  "use strict";
123
124  var scrollTicker, lightboxAttr, sidebar,
125    body = $('body'),
126    rtl = $('body').hasClass('rtl'),
127    simple = $('body').hasClass('style-simple'),
128    isBlocks = $('body').hasClass('builder-blocks'),
129    topBarTop = '0',
130    headerH = 0,
131    currWidth = $(window).width(),
132    newWidth = $(window).width(),
133    screen = 'desktop',
134    mobileInitW = mfn.mobileInit ? mfn.mobileInit : 1240,
135    consents = {}; // GDPR 2.0
136
137  /**
138   * Lightbox | Magnific Popup
139   */
140
141  if ( ! mfn.lightbox.disable ) {
142    if ( ! ( mfn.lightbox.disableMobile && ( window.innerWidth < 768 ) ) ) {
143      lightboxAttr = {
144        title: mfn.lightbox.title ? mfn.lightbox.title : false,
145      };
146    }
147  }
148
149  /**
150   * Cookies support
151   */
152
153  var cookies = {
154
155    // cookies.get()
156
157    get: function(name){
158
159      if (document.cookie !== "") {
160        var cookies = document.cookie.split(/; */);
161
162        for (var cookie of cookies) {
163          var [ cookieName, cookieVal ] = cookie.split("=");
164
165          if (cookieName === name) {
166            // console.log(cookieVal);
167            return decodeURIComponent(cookieVal);
168          }
169        }
170      }
171
172      return false;
173    },
174
175    // cookies.set();
176
177    set: function(name, value, expires){
178
179      if(navigator.cookieEnabled) {
180
181        var cookieDate = new Date();
182        var cookieText = '';
183
184        expires = expires || 365;
185        value = encodeURIComponent(value);
186
187        cookieDate.setTime(cookieDate.getTime() + (expires * 24 * 60 * 60 * 1000));
188        cookieText += name +"="+ value;
189        cookieText += "; expires=" + cookieDate.toUTCString() + ';';
190        cookieText += "; path=" + mfn.home_url + '/';
191
192        document.cookie = cookieText;
193      }
194
195    },
196
197  };
198
199  /**
200   * Google Consent Mode gtag
201   */
202
203  var consent = {
204
205    popup : $('#mfn-consent-mode'),
206
207    // consent.tabs()
208
209    tabs : function($el, id){
210
211      var $li;
212
213      if( $el ){
214        $li = $el.closest('li');
215        id = $li.data('id');
216      } else {
217        $li = $('.tab[data-id="'+ id +'"]');
218      }
219
220      // active
221
222      $li.addClass('is-active')
223        .siblings().removeClass('is-active');
224
225      // open tab
226
227      $('#'+ id).addClass('is-active')
228        .siblings().removeClass('is-active');
229
230      // middle button
231
232      $('.mfn-cookies').attr('data-tab',id);
233
234    },
235
236    // consent.open()
237
238    open : function(){
239
240      if( ! this.popup.length ){
241        return;
242      }
243
244      if( $('body').hasClass('mfn-ui') ) return;
245
246      consents = cookies.get('mfnConsent');
247
248      try {
249
250        consents = JSON.parse(consents);
251
252        if ( ! consents ){
253          throw new Error('');
254        }
255
256        // gtag update
257        gtag('consent', 'update', consents);
258
259      } catch (e) {
260
261        consents = {
262          'ad_storage': 'denied',
263          'ad_user_data': 'denied',
264          'ad_personalization': 'denied',
265          'analytics_storage': 'denied'
266        }
267
268        body.addClass('mfn-cookies-open');
269        if( body.hasClass('gdpr2-scroll-disable') ){
270          $('html').addClass('mfn-popup-browser-scroll-disabled');
271        }
272
273      }
274
275    },
276
277    // consent.reopen()
278
279    reopen : function(){
280
281      if( $('body').hasClass('mfn-ui') ) return;
282
283      body.addClass('mfn-cookies-open');
284      this.popup.show()
285        .children().show();
286
287      if( body.hasClass('gdpr2-scroll-disable') ){
288        $('html').addClass('mfn-popup-browser-scroll-disabled');
289      }
290
291    },
292
293    // consent.close()
294
295    close : function(){
296
297      var closeAnimation = this.popup.attr('data-animation');
298
299      switch(true){
300        case 'fade' === closeAnimation:
301          this.popup.fadeOut(300);
302          break;
303        case 'slide' === closeAnimation:
304          this.popup.fadeOut(300);
305          this.popup.children().slideUp(300);
306          break;
307        default:
308          body.removeClass('mfn-cookies-open');
309      }
310
311      // wait for animation end, then remove clasa and set cookies
312      setTimeout(function(){
313        body.removeClass('mfn-cookies-open');
314        if( body.hasClass('gdpr2-scroll-disable') ){
315          $('html').removeClass('mfn-popup-browser-scroll-disabled');
316        }
317        $(document).trigger('mfn:gdpr2:close');
318      }, 300);
319
320    },
321
322    // consent.set()
323
324    set : function(){
325
326      var expires = this.popup.attr('data-expires');
327      expires = parseInt(expires) || 365;
328
329      // gtag update
330      gtag('consent', 'update', consents);
331
332      // cookies set
333      cookies.set('mfnConsent', JSON.stringify(consents), expires);
334
335      // popup close
336      consent.close();
337
338    },
339
340    // consent.all()
341
342    all : function(){
343
344      consents = {
345        'ad_storage': 'granted',
346        'ad_user_data': 'granted',
347        'ad_personalization': 'granted',
348        'analytics_storage': 'granted'
349      }
350
351      consent.set();
352
353    },
354
355    // consent.selected()
356
357    selected : function(){
358
359      if( $('#cookies_analytics').is(":checked") ){
360        consents.analytics_storage = 'granted';
361      }
362
363      if( $('#cookies_marketing').is(":checked") ){
364        consents.ad_storage = 'granted';
365        consents.ad_user_data = 'granted';
366        consents.ad_personalization = 'granted';
367      }
368
369      consent.set();
370
371    },
372
373    // consent.deny()
374
375    deny : function(){
376
377      consents = {
378        'ad_storage': 'denied',
379        'ad_user_data': 'denied',
380        'ad_personalization': 'denied',
381        'analytics_storage': 'denied'
382      }
383
384      consent.set();
385
386    },
387
388  };
389
390  /**
391   * Calculate top bar initial position for sticky header and fixed headers like modern
392   */
393
394  function topBarTopPosition(){
395
396    topBarTop = parseInt($('#Top_bar').css('top'), 10);
397
398    // page has already been scrolled and is refreshed or is opened with #hash
399
400    var scrollPos = $(window).scrollTop();
401
402    if( scrollPos > 0 ){
403      window.scrollTo(0, 0);
404      $(window).scrollTop(0);
405      topBarTop = parseInt($('#Top_bar').css('top'), 10);
406      window.scrollTo(0, scrollPos);
407    }
408
409    // negative top bar top value
410
411    if (topBarTop < 0){
412      topBarTop = 0;
413    }
414
415    topBarTop = topBarTop + 'px';
416
417  }
418
419  /**
420   * Admin Bar & WooCommerce Store Notice
421   */
422
423  function adminBarH() {
424
425    var height = 0;
426
427    // WP adminbar
428
429    if ($('body').hasClass('admin-bar')) {
430      var actionBarH = $('#wpadminbar').innerHeight() || 0;
431      height += actionBarH;
432    }
433
434    // WC demo store
435
436    if ($('body').hasClass('woocommerce-demo-store')) {
437      var demoStoreH = $('body > p.demo_store').innerHeight() || 0;
438      height += demoStoreH;
439    }
440
441    return height;
442  }
443
444  /**
445   * Header | Sticky
446   */
447
448  function mfnSticky() {
449
450    if( ! $('body').hasClass('sticky-header') ){
451      return false;
452    }
453
454    if( $('body').hasClass('header-creative') && window.innerWidth >= 768 ){
455      return false;
456    }
457
458    var startY = headerH;
459    var windowY = $(window).scrollTop();
460    var topBarH = $('#Top_bar').height() || 0;
461
462    if ( windowY > startY ) {
463
464      if ( ! ( $('#Top_bar').hasClass('is-sticky') ) ) {
465
466        $('.header_placeholder').css('height', topBarH);
467
468        $('#Top_bar')
469          .addClass('is-sticky')
470          .css('top', -60)
471          .animate({
472            'top': adminBarH() + 'px'
473          }, 300);
474
475        headerWidth();
476
477        $(document).trigger('mfn:header:sticky:on');
478      }
479
480    } else {
481
482      if ($('#Top_bar').hasClass('is-sticky')) {
483
484        $('.header_placeholder').css('height', 0);
485        $('#Top_bar').stop()
486          .removeClass('is-sticky')
487          .css('top', topBarTop);
488
489        stickyLogo();
490        headerWidth();
491
492        $(document).trigger('mfn:header:sticky:off');
493
494      }
495
496    }
497
498  }
499
500  /**
501   * Header | Sticky | Retina Logo - max height
502   */
503
504  function stickyLogo() {
505
506    // ! retina display
507
508    if( window.devicePixelRatio <= 1 ){
509      return false;
510    }
511
512    var parent = $('#Top_bar #logo'),
513      el = $('img.logo-main', parent),
514      height = el.data('height');
515
516    // ! retina logo set
517    if ( ! parent.hasClass('retina')) {
518      return false;
519    }
520
521    if ( $('body').hasClass('logo-overflow') ) {
522      // do nothing
523    } else if ( height > parent.data('height') ) {
524      height = parent.data('height');
525    }
526
527    el.css('max-height', height + 'px');
528
529  }
530
531  /**
532   * Header | Sticky | Height
533   */
534
535  function mfnStickyH() {
536
537    var topBarH = $('#Top_bar').innerHeight() || 0;
538
539    if ( $('body').hasClass('header-below') ) {
540
541      // header below slider
542
543      var sliderH = $('.mfn-main-slider').innerHeight() || 0;
544
545      headerH = topBarH + sliderH;
546
547    } else {
548
549      // default
550
551      var actionBarH = $('#Action_bar').innerHeight() || 0;
552
553      headerH = topBarH + actionBarH;
554
555    }
556
557  }
558
559  /**
560   * Header | Sticky | Mobile
561   */
562
563  function mfnMobileSticky() {
564
565    if( ! $('body').hasClass('.mobile-sticky') ){
566      return false;
567    }
568
569    if( $(window).width() >= 768 ){
570      return false;
571    }
572
573    var menuH,
574      windowH = $(window).height() || 0,
575      logoH = $('#Top_bar .logo').height() || 0,
576      offset = adminBarH() + logoH;
577
578    if ( ( ! $('#Top_bar').hasClass('is-sticky')) && $('#Action_bar').is(':visible') ) {
579      offset += $('#Action_bar').height() || 0;
580    }
581
582    menuH = windowH - offset;
583
584    if (menuH < 176) {
585      menuH = 176;
586    }
587
588    $('#Top_bar #menu').css('max-height', menuH + 'px');
589
590  }
591
592  /**
593   * Header | Top bar left | Width
594   */
595
596  function headerWidth() {
597
598    var rightW = $('.top_bar_right').outerWidth() || 0;
599
600    rightW = Math.ceil( rightW );
601
602    if( $('body').hasClass('header-modern') ){
603      rightW += 10;
604    }
605
606    var parentW = $('#Top_bar .one').width() || 0;
607    var leftW = parentW - rightW;
608
609  }
610
611  /**
612   * FIX | Header | Sticky | Height
613   */
614
615  function fixStickyHeaderH() {
616
617    var stickyH = 0;
618
619    // FIX | sticky top bar height
620
621    var topBar = $('.sticky-header #Top_bar');
622
623    if( topBar.length ){
624
625      // default headers
626
627      if (topBar.hasClass('is-sticky')) {
628        stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
629      } else {
630        topBar.addClass('is-sticky');
631        stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
632        topBar.removeClass('is-sticky');
633      }
634
635    } else if( $('.mfn-header-tmpl-builder').length ) {
636
637      var height = 15;
638      var shift = 0;
639
640      if( $('#mfn-header-template').hasClass('mfn-hasSticky') ){
641        height = $('#mfn-header-template').outerHeight();
642        shift = parseFloat($('#mfn-header-template').css('top'));
643      }else if( $('#mfn-header-template').hasClass('mfn-header-tmpl-fixed') ){
644        height = $('#mfn-header-template').outerHeight();
645        shift = parseFloat($('#mfn-header-template').css('top'));
646      }else if( $('#mfn-header-template').hasClass('mfn-mobile-header-tmpl-fixed') && $(window).width() < 767 ) {
647        height = $('#mfn-header-template').outerHeight();
648        shift = parseFloat($('#mfn-header-template').css('top'));
649      }
650
651      stickyH = height + shift;
652
653      return stickyH;
654
655    }
656
657    // FIX | responsive
658
659    if ( $(window).width() < mobileInitW ) {
660
661      if ( $(window).width() < 768 ) {
662
663        // mobile
664        if (!$('body').hasClass('mobile-sticky')) {
665          stickyH = 0;
666        }
667
668      } else {
669
670        // tablet
671        if (!$('body').hasClass('tablet-sticky')) {
672          stickyH = 0;
673        }
674
675      }
676
677    } else {
678
679      // desktop
680
681      // FIX | header creative
682      if ($('body').hasClass('header-creative')) {
683        stickyH = 0;
684      }
685
686    }
687
688    return stickyH;
689  }
690
691  /**
692   * Sidebar | Height
693   */
694
695  function mfnSidebar() {
696    if ($('.mcb-sidebar').length) {
697
698      var maxH = $('#Content .sections_group').outerHeight();
699
700      $('.mcb-sidebar').each(function() {
701        $(this).css('min-height', 0);
702        if ($(this).height() > maxH) {
703          maxH = $(this).height();
704        }
705      });
706
707      $('.mcb-sidebar').css('min-height', maxH + 'px');
708
709      if( sidebar ){
710        sidebar.stickySidebar('updateSticky');
711      }
712
713    }
714  }
715
716
717  /**
718   * Into | Full Screen
719   */
720
721  function mfnIntroH() {
722
723    var windowH = $(window).height() || 0;
724    var headerWrapperH = $('#Header_wrapper').height() || 0;
725
726    windowH = windowH - headerWrapperH - adminBarH();
727
728    $('#Intro.full-screen').each(function() {
729
730      var el = $(this),
731        inner = $('.intro-inner', el),
732        innerH = inner.height() || 0;
733
734      el.css('padding', 0).css('min-height', windowH);
735
736      var padding = ( windowH - innerH ) / 2;
737      inner.css('padding-top', padding).css('padding-bottom', padding);
738
739    });
740  }
741
742  /**
743   * Footer | Sliding | Height
744   */
745
746  function mfnFooter() {
747
748    var footerH = $('#Footer').height() || 0;
749
750    // Fixed, Sliding
751
752    if ($('.footer-fixed #Footer, .footer-sliding #Footer').length) {
753
754      footerH = footerH - 1;
755      $('#Content').css('margin-bottom', footerH + 'px');
756
757    }
758
759    // Stick to bottom
760
761    if ($('.footer-stick #Footer').length) {
762
763      var headerWrapperH = $('#Header_wrapper').height() || 0;
764
765      var headerFooterH = headerWrapperH + footerH;
766
767      var documentH = $(document).height() - adminBarH();
768
769      if ( ( documentH <= $(window).height() ) && ( headerFooterH <= $(window).height() ) ) {
770        $('#Footer').addClass('is-sticky');
771      } else {
772        $('#Footer').removeClass('is-sticky');
773      }
774
775    }
776
777  }
778
779  /**
780   * Back To Top | Sticky / Show on scroll
781   */
782
783  function backToTopSticky() {
784
785    if ($('#back_to_top.sticky.scroll').length) {
786      var el = $('#back_to_top.sticky.scroll');
787
788      // Clear Timeout if one is pending
789      if (scrollTicker) {
790        window.clearTimeout(scrollTicker);
791        scrollTicker = null;
792      }
793
794      el.addClass('focus');
795
796      // Set Timeout
797      scrollTicker = window.setTimeout(function() {
798        el.removeClass('focus');
799      }, 1500); // Timeout in msec
800
801    }
802
803  }
804
805  /**
806   * Preloader
807   */
808
809  function preloader(){
810    $('body.preloader').animate({
811      opacity: 1
812    }, 100, function(){
813      $('html').removeClass('preloading');
814    });
815  }
816
817  /**
818   * # Hash smooth navigation
819   */
820
821  function hashNav() {
822
823    var hash = window.location.hash;
824
825    if (hash) {
826
827      // FIX | Master Slider
828
829      if (hash.indexOf("&") > -1 || hash.indexOf("/") > -1 || hash.indexOf("?") > -1) {
830        return false;
831      }
832
833      // Contact Form 7 in popup
834
835      if (hash.indexOf("wpcf7") > -1) {
836        cf7popup(hash);
837      }
838
839      if ($(hash).length) {
840
841        $(window).scrollTop(0, 0);
842
843        setTimeout(function() {
844
845          var offset = 0,
846            headerH = fixStickyHeaderH(),
847            tabH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
848
849          // header builder
850
851          if( $('body').hasClass('mhb') ){
852
853            var currentView = $('.mhb-view').filter(':visible');
854            headerH = currentView.height() || 0;
855
856          }
857
858          offset = headerH + tabH;
859
860          $('html, body').animate({
861            scrollTop: $(hash).offset().top - offset
862          }, 500);
863
864        }, 500);
865
866      }
867
868
869    }
870
871  }
872
873  /**
874   * One Page | Scroll Active
875   */
876
877  function onePageActive() {
878    if ($('body').hasClass('one-page')) {
879
880      var stickyH = $('.sticky-header #Top_bar').innerHeight() || 0;
881      if( $('#mfn-header-template').length ) stickyH = $('#mfn-header-template').innerHeight() || 0;
882      var windowT = $(window).scrollTop();
883      var start = windowT + stickyH + adminBarH() + 1;
884      var first = false;
885
886      $('[data-id]:not(.elementor-element), section[data-id]').each(function() {
887
888        // FIX | elementor adds own data-id for each section
889
890        if( $(this).attr('data-id') && ( -1 == $(this).attr('data-id').indexOf('#') ) ){
891          return true;
892        }
893
894        if ($(this).visible(true)) {
895
896          if (!first) {
897            first = $(this);
898          } else if (($(this).offset().top < start) && ($(this).offset().top > first.offset().top)) {
899            first = $(this);
900          }
901        }
902
903        if (first) {
904
905          var newActive = first.attr('data-id');
906          var active = '[data-hash="' + newActive + '"]';
907
908          if (newActive) {
909            var menu = $('#menu, .mhb-menu');
910            if( $('#mfn-header-template').length ) menu = $('#mfn-header-template .mfn-header-menu');
911            menu.find('li').removeClass('current-menu-item current-menu-parent current-menu-ancestor current_page_item current_page_parent current_page_ancestor');
912            $(active, menu)
913              .closest('li').addClass('current-menu-item')
914              .closest('.menu > li').addClass('current-menu-item');
915          }
916
917        }
918
919      });
920
921    }
922  }
923
924  /**
925   * Contact Form 7 | Popup
926   */
927
928  function cf7popup(hash) {
929    if (hash && $(hash).length) {
930      var id = $(hash).closest('.popup-content').attr('id');
931
932      $('a.popup-link[href="#' + id + '"]:not(.once)')
933        .addClass('once')
934        .trigger('click');
935
936    }
937  }
938
939  /**
940   * $(document).mfnPopupInit
941   * init js plugins on popup open
942   */
943
944  $(document).on('mfnPopupInit', function() {
945
946    // chart
947
948    if( $('.mfn-popup-tmpl.mfn-popup-active .chart:not(.mfn-initialized)').length ){
949      $('.mfn-popup-tmpl.mfn-popup-active .chart:not(.mfn-initialized)').each(function() {
950          var lineW = simple ? 4 : 8;
951          $(this).addClass('mfn-initialized');
952          $(this).easyPieChart({
953            animate: 1000,
954            lineCap: 'circle',
955            lineWidth: lineW,
956            size: 140,
957            scaleColor: false
958          });
959
960      });
961    }
962
963    // before after
964
965    if( $('.mfn-popup-tmpl.mfn-popup-active .before_after.twentytwenty-container:not(.mfn-initialized)').length ){
966
967      $('.mfn-popup-tmpl.mfn-popup-active .before_after.twentytwenty-container:not(.mfn-initialized)').each(function(){
968
969        var el = $(this);
970        el.addClass('mfn-initialized');
971        el.imagesLoaded().done(function(instance, image){
972          queueMicrotask(() => el.twentytwenty());
973        });
974
975      });
976    }
977
978    // countdown
979
980    if( $('.mfn-popup-tmpl.mfn-popup-active .downcount:not(.mfn-initialized)').length ){
981      $('.mfn-popup-tmpl.mfn-popup-active .downcount:not(.mfn-initialized)').each(function() {
982        var el = $(this);
983        el.addClass('mfn-initialized');
984        el.downCount({
985          date: el.attr('data-date'),
986          offset: el.attr('data-offset')
987        });
988      });
989    }
990
991    // counter
992
993    if( $('.mfn-popup-tmpl.mfn-popup-active .animate-math .number:not(.mfn-initialized)').length ){
994      $('.mfn-popup-tmpl.mfn-popup-active .animate-math .number:not(.mfn-initialized)').each(function() {
995
996        var el = $(this);
997        var duration = Math.floor((Math.random() * 1000) + 1000);
998        var to = el.attr('data-to');
999
1000        el.addClass('mfn-initialized');
1001
1002        $({
1003          property: 0
1004        }).animate({
1005          property: to
1006        }, {
1007          duration: duration,
1008          easing: 'linear',
1009          step: function() {
1010            el.text(Math.floor(this.property));
1011          },
1012          complete: function() {
1013            el.text(this.property);
1014          }
1015        });
1016
1017      });
1018    }
1019
1020  });
1021
1022  $(document).on('mfn:ajax:refresh', function() {
1023
1024    if( $('.mfn-looped-items-slider').length ){
1025      queryLoopSlider();
1026    }
1027
1028    bannerBox.init();
1029
1030    mfnReadMore.prepare();
1031
1032    mfnTabber.sliding_bg();
1033
1034    if( $('.mfn-advanced-filters').length ) mfnAdvancedFilters.prepare();
1035
1036    if( $('.mfn-floating-placeholder').length ){
1037      $('.mfn-floating-placeholder .mfn-input-wrapper input').each(function() {
1038        if( $(this).val().length ){
1039          $(this).closest('.mfn-input-wrapper').addClass('mfn-not-empty');
1040        }else{
1041          $(this).closest('.mfn-input-wrapper').removeClass('mfn-not-empty');
1042        }
1043      });
1044    }
1045
1046    $('.downcount:not(.mfn-initialized)').each(function() {
1047      var el = $(this);
1048      el.addClass('mfn-initialized');
1049      el.downCount({
1050        date: el.attr('data-date'),
1051        offset: el.attr('data-offset')
1052      });
1053    });
1054
1055  })
1056
1057  /**
1058   * $(document).ready
1059   * Specify a function to execute when the DOM is fully loaded.
1060   */
1061
1062  $(document).ready(function() {
1063
1064    if( $('.mfn-off-canvas-sidebar').length ){
1065      offCanvasSidebar.init();
1066    }
1067
1068    if( $('.mfn-advanced-filters').length ){
1069      mfnAdvancedFilters.init();
1070    }
1071
1072    mfnTabber.init();
1073
1074
1075    if( $(window).width() < 767 && !$('.mfn-off-canvas-sidebar').length ){
1076      offCanvasSidebar.mobile();
1077      screen = 'mobile';
1078    }else if($(window).width() < 959){
1079      screen = 'tablet';
1080    }
1081
1082    if( $('.mfn-floating-placeholder').length ){
1083      $(document).on('blur change', '.mfn-floating-placeholder .mfn-input-wrapper input', function() {
1084        if( $(this).val().length ){
1085          $(this).closest('.mfn-input-wrapper').addClass('mfn-not-empty');
1086        }else{
1087          $(this).closest('.mfn-input-wrapper').removeClass('mfn-not-empty');
1088        }
1089      });
1090
1091      $('.mfn-floating-placeholder .mfn-input-wrapper input').each(function() {
1092        if( $(this).val().length ){
1093          $(this).closest('.mfn-input-wrapper').addClass('mfn-not-empty');
1094        }else{
1095          $(this).closest('.mfn-input-wrapper').removeClass('mfn-not-empty');
1096        }
1097      });
1098    }
1099
1100    /**
1101     *
1102     * ELEMENTOR fix single post
1103     *
1104     * */
1105
1106    if( $('body').hasClass('single-post') && $('.mfn-tmp-elementor-content').length && $('.column.column_post_content').length ){
1107      $('.column.column_post_content .mcb-item-post_content-inner').html( $('.mfn-tmp-elementor-content').html() );
1108      $('.mfn-tmp-elementor-content').remove();
1109    }
1110
1111    if( $('.mfn-share-post-copy-link').length ){
1112      $('.mfn-share-post-copy-link').on('click', function(e) {
1113        e.preventDefault();
1114        var $link = $(this);
1115        navigator.clipboard.writeText( window.location.href );
1116        $link.addClass('tooltip').attr('data-tooltip', mfn.translation.success_message);
1117        setTimeout(function() {
1118          $link.removeClass('tooltip').removeAttr('data-tooltip');
1119        }, 2000);
1120      });
1121    }
1122
1123    if( $('.mfn-image-hotspot').length ){
1124
1125      mfn_hotspot.init();
1126
1127    }
1128
1129    /**
1130     *
1131     * Link go to section
1132     *
1133     * */
1134
1135    if( $('.mfn-go-to').length ){
1136      $(document).on('click', '.mfn-go-to', function(e) {
1137        e.preventDefault();
1138        let target = $(this).attr('data-mfngoto');
1139        let offset = 0;
1140
1141        if( target == 'last' ){
1142          offset = $('#Content .mfn-builder-content > .section').last().offset().top;
1143        }else if( target == 'prev' ){
1144          if( !$(this).closest('.section').prev('.section').length ) {console.error('BeTheme: Prev section doesnt exists'); return; }
1145          offset = $(this).closest('.section').prev('.section').offset().top;
1146        }else{
1147          if( !$(this).closest('.section').next('.section').length ) {console.error('BeTheme: Next section doesnt exists'); return; }
1148          offset = $(this).closest('.section').next('.section').offset().top;
1149        }
1150
1151        offset = offset - ( fixStickyHeaderH() + adminBarH() );
1152
1153        $('html,body').animate({ scrollTop: offset }, 500);
1154
1155
1156      });
1157    }
1158
1159
1160    let js_tooltip = {
1161      button: false,
1162      offset_top: false,
1163      offset_left: false,
1164      init: function() {
1165        $('.js-tooltip').on('mouseenter', function() {
1166          js_tooltip.button = $(this);
1167          if( typeof js_tooltip.button.attr('data-tooltip') == 'undefined' ) return;
1168
1169          $('body').append('<span class="js-tooltip-txt">'+js_tooltip.button.attr('data-tooltip')+'</span>');
1170          js_tooltip.position();
1171
1172        }).on('mouseleave', function() {
1173          if( $('.js-tooltip-txt').length ) $('.js-tooltip-txt').remove();
1174          js_tooltip.button = false;
1175        });
1176
1177        $(window).on('scroll', function() {
1178          if( js_tooltip.button ) js_tooltip.position();
1179        });
1180
1181      },
1182      position: function() {
1183        let offset = js_tooltip.button.offset();
1184        js_tooltip.offset_top = offset.top - $(window).scrollTop() - 8;
1185        js_tooltip.offset_left = offset.left + (js_tooltip.button.outerWidth()/2);
1186
1187        if( js_tooltip.button && $('.js-tooltip-txt').length ) $('.js-tooltip-txt').css({ top: js_tooltip.offset_top+'px', left: js_tooltip.offset_left+'px' });
1188      }
1189    }
1190
1191    if( $('.js-tooltip').length ) js_tooltip.init();
1192
1193
1194
1195    /**
1196     *
1197     * Button copy to clipboard
1198     *
1199     * */
1200
1201    if( $('.mfn-copy-to-clipboard').length ) {
1202      $(document).on('click', '.mfn-copy-to-clipboard', function(e) {
1203        e.preventDefault();
1204        let code = $(this).attr('data-mfncopycode');
1205        let button = $(this);
1206        let org_label = button.find('.button_label').text();
1207        let copied_txt = button.attr('data-mfncopyconfirm');
1208
1209        navigator.clipboard.writeText(code);
1210
1211        if( button.hasClass('js-tooltip') ) {
1212          org_label = button.attr('data-tooltip');
1213          button.attr('data-tooltip', copied_txt);
1214          if( $('.js-tooltip-txt').length ) $('.js-tooltip-txt').remove();
1215          button.trigger('mouseenter');
1216        }else{
1217          button.find('.button_label').text(copied_txt);
1218        }
1219
1220        button.on('mouseleave', function() {
1221          button.blur();
1222        });
1223
1224        setTimeout(function() {
1225          if( button.hasClass('js-tooltip') ) {
1226            button.attr('data-tooltip', org_label);
1227            if( $('.js-tooltip-txt').length ) $('.js-tooltip-txt').remove();
1228            button.trigger('mouseenter');
1229          }else{
1230            button.find('.button_label').text(org_label);
1231          }
1232        }, 2000);
1233
1234      });
1235    }
1236
1237    /**
1238     *
1239     * WPML language switcher
1240     *
1241     * */
1242
1243    if( $('.mfn-language-switcher-dropdown:not(.mfn-initialized)').length ) {
1244      $('.mfn-language-switcher-dropdown:not(.mfn-initialized)').each(function() {
1245        let that = $(this);
1246        that.addClass('mfn-initialized');
1247
1248        let $ul = that.find('ul');
1249        let $current = $ul.find('li.wpml-ls-current-language');
1250
1251        $current.append($ul.clone());
1252
1253        $ul.children('li:not(.wpml-ls-current-language)').remove();
1254
1255        $current.find('ul li.wpml-ls-current-language').remove();
1256
1257        if( that.hasClass('mfn-language-switcher-dropdown-icon') ){
1258          let icon_html = '';
1259          if( that.attr('data-icon') == 'image' ){
1260            icon_html = '<span class="mfn-arrow-icon"><img src="'+that.attr('data-path')+'" alt=""></span>';
1261          }else if( that.attr('data-icon') == 'icon' ){
1262            icon_html = '<span class="mfn-arrow-icon"><i class="'+that.attr('data-path')+'"></i></span>';
1263          }
1264
1265          $current.children('a').append(icon_html);
1266        }
1267
1268      });
1269
1270      $(document).on('click', '.mfn-language-switcher-dropdown ul li.wpml-ls-current-language > a', function(e) {
1271        if( $(window).width() < 1240 ) e.preventDefault();
1272        $(this).parent('li').toggleClass('hover');
1273      }).on('mouseleave', '.mfn-language-switcher-dropdown ul li.wpml-ls-current-language.hover', function(e) {
1274        $('.mfn-language-switcher-dropdown ul li.hover').removeClass('hover');
1275      });
1276
1277    }
1278
1279    /**
1280     * Isotope
1281     */
1282
1283    class Isotope {
1284      constructor(){
1285        this.runIsotopes = this.runIsotopes.bind(this);
1286        this.itemToModify = {};
1287        this.ajaxObjects = [];
1288      }
1289
1290      get getList() {
1291        return [
1292          {
1293            name: 'Portfolio - Isotope',
1294            location: '.blog_wrapper .isotope:not( .masonry ), .portfolio_wrapper .isotope:not( .masonry-flat, .masonry-hover, .masonry-minimal )',
1295            beforeActive: () => null,
1296            afterActive: () => null,
1297            settings: {
1298              itemSelector: '.isotope-item',
1299              layoutMode: 'fitRows',
1300              isOriginLeft: rtl ? false : true
1301            }
1302          },
1303          {
1304            name: 'Portfolio - Masonry Flat',
1305            location: '.portfolio_wrapper .masonry-flat',
1306            beforeActive: () => null,
1307            afterActive: () => null,
1308            settings: {
1309              itemSelector: '.isotope-item',
1310              percentPosition: true,
1311              masonry: { columnWidth: 1 },
1312              isOriginLeft: rtl ? false : true
1313            }
1314          },
1315          {
1316            name: 'Blog & Portfolio & Shop - Masonry',
1317            location: '.isotope.masonry, .isotope.masonry-hover, .isotope.masonry-minimal',
1318            beforeActive: () => null,
1319            afterActive: () => null,
1320            settings: {
1321              itemSelector: '.isotope-item',
1322              layoutMode: 'masonry',
1323              isOriginLeft: rtl ? false : true
1324            }
1325          },
1326          /*{
1327            name: 'General - Masonry Isotope',
1328            location: '.masonry.isotope, .masonry.gallery',
1329            beforeActive: () => null,
1330            afterActive: () => null,
1331            settings: {}
1332          },
1333          {
1334            name: 'General - Isotope',
1335            location: '.isotope',
1336            beforeActive: () => null,
1337            afterActive: () => null,
1338            settings: {},
1339          },*/
1340          {
1341            name: 'Filters - Isotope Event on Click',
1342            location: 'body:not(.tax-portfolio-types,.archive.category,.archive.tag,.archive.author) .isotope-filters .filters_wrapper',
1343            beforeActive: () => null,
1344            afterActive: ({location}) => {
1345              const filterButtons = $(location).find('li:not(.close) a');
1346              filterButtons.on('click', (e) => {
1347                e.preventDefault();
1348                const buttonClicked = $(e.target);
1349
1350                let isoWrapper = $('.isotope'),
1351                    filters = buttonClicked.closest('.isotope-filters'),
1352                    parent = filters.attr('data-parent');
1353
1354                if (parent) {
1355                  parent = filters.closest('.' + parent);
1356                  isoWrapper = parent.find('.isotope').first();
1357                }
1358
1359                filters.find('li').removeClass('current-cat');
1360                buttonClicked.closest('li').addClass('current-cat');
1361
1362                // $('.isotope-filters .filters_wrapper').find('li').removeClass('current-cat');
1363                this.isotopeFilter(buttonClicked, isoWrapper);
1364              })
1365            },
1366            settings: 'do-not-run'
1367          },
1368          ...this.ajaxObjects //dynamical loaded content, like load more.
1369        ]
1370      }
1371
1372      // One liners, queries to isotope API
1373      addEventListener(onEvent, doWhat) {
1374        return $(document).on( `isotope:${onEvent}`, doWhat)
1375      }
1376      queryIsotopeAPI(location, apiAction, actionToPass) {
1377        return $(location).isotope(apiAction, actionToPass);
1378      };
1379      triggerIsotopeEvent(doWhat) {
1380        return $(document).trigger(`isotope:${doWhat}`)
1381      }
1382
1383      // Add elements which require isotope and are loaded on the fly
1384      addIsotopeLocation( payload ) {
1385        if ( !payload.location ) return console.error('MfnIsotope Error: No Location Provided!');
1386
1387        // Push it to object
1388        this.ajaxObjects.push(
1389          {
1390            name: payload.name ? payload.name : 'No name applied - Dynamic Isotope Function',
1391            location: payload.location,
1392            beforeActive: payload.beforeActive ? payload.beforeActive : () => null,
1393            afterActive: payload.afterActive ? payload.afterActive : () => null,
1394            settings: payload.settings ? payload.settings : {}
1395          }
1396        );
1397
1398        // Reload it anyway while using that option
1399        $( payload.location ).isotope( payload.settings )
1400      }
1401
1402      isotopeFilter( domEl, isoWrapper ) {
1403        if( !domEl || !isoWrapper ) return console.error('MfnIsotope Error: isotopeFilter, missing one of the values!');
1404        const filter = domEl.attr('data-rel');
1405
1406        isoWrapper.isotope({ filter });
1407
1408        queueMicrotask(() => $(window).trigger('resize'));
1409
1410        setTimeout(function() {
1411          mfnIsotope.triggerIsotopeEvent('arrange');
1412        }, 500);
1413      }
1414
1415      // Usually for init, turn on all of the isotopes!
1416      runIsotopes( resize = true ) {
1417        const isotopeList = this.getList;
1418
1419        isotopeList.map(item => {
1420
1421          if( $(item.location).length ) {
1422            // HOOK, before isotope binding
1423            item.beforeActive(item)
1424
1425            // Trigger resize to recalculate some plugins stuff
1426            if( resize ){
1427                $(window).trigger('resize');
1428            }
1429
1430            // Isotope init
1431            if( 'do-not-run' !== item.settings ){
1432              queueMicrotask(() => $( item.location ).isotope( item.settings ));
1433            }
1434
1435            // HOOK, after isotope binding
1436            item.afterActive(item);
1437          }
1438        });
1439      }
1440    }
1441
1442    const mfnIsotope = new Isotope;
1443    mfnIsotope.runIsotopes();
1444
1445    /**
1446     * Waypoints
1447    */
1448
1449    class Waypoints {
1450      constructor(){
1451        this.runWaypoints = this.runWaypoints.bind(this);
1452      }
1453
1454      get getList() {
1455        return [
1456          {
1457            name: 'Chart',
1458            location: '.sections_group .chart, .elementor-section .chart',
1459            beforeActive: () => {},
1460            afterActive: () => {},
1461            settings: () => {
1462              return {
1463                offset: '100%',
1464                triggerOnce: true,
1465                handler: function(){
1466                  var el = $(this.element).length ? $(this.element) : $(this);
1467                  var lineW = simple ? 4 : 8;
1468
1469                  el.easyPieChart({
1470                    animate: 1000,
1471                    lineCap: 'circle',
1472                    lineWidth: lineW,
1473                    size: 140,
1474                    scaleColor: false
1475                  });
1476
1477                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1478                    this.destroy();
1479                  }
1480                }
1481              }
1482            }
1483          },
1484          {
1485            name: 'Progress Icons',
1486            location: '.progress_icons',
1487            beforeActive: () => {},
1488            afterActive: () => {},
1489            settings: () => {
1490              return {
1491                offset: '100%',
1492                triggerOnce: true,
1493                handler: function() {
1494                  var el = $(this.element).length ? $(this.element) : $(this);
1495                  var active = el.attr('data-active');
1496                  var color = el.attr('data-color');
1497                  var transparent = el.hasClass('transparent');
1498                  var icon = el.find('.progress_icon');
1499                  var timeout = 200; // timeout in milliseconds
1500
1501                  icon.each(function(i) {
1502                    if (i < active) {
1503                      var time = (i + 1) * timeout;
1504                      setTimeout(function() {
1505
1506                        $(icon[i]).addClass('themebg');
1507
1508                        if( transparent ){
1509                          $(icon[i]).css('color', color);
1510                        } else {
1511                          $(icon[i]).css('background-color', color);
1512                        }
1513
1514                      }, time);
1515                    }
1516                  });
1517
1518                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1519                    this.destroy();
1520                  }
1521                }
1522              }
1523            }
1524          },
1525          {
1526            name: 'Animate Math | Counter, Quick Fact, etc.',
1527            location: '#Wrapper .animate-math .number',
1528            beforeActive: () => {},
1529            afterActive: () => {},
1530            settings: () => {
1531              return {
1532                offset: '100%',
1533                triggerOnce: true,
1534                handler: function() {
1535                  var el = $(this.element).length ? $(this.element) : $(this);
1536                  var duration = el.attr('data-duration') * 1 || Math.floor((Math.random() * 1000) + 1000);
1537                  var thousands_separator = el.attr('data-thousands-separator') || 0;
1538                  var to = el.attr('data-to');
1539
1540                  $({
1541                    property: 0
1542                  }).animate({
1543                    property: to
1544                  }, {
1545                    duration: duration,
1546                    easing: 'linear',
1547                    step: function() {
1548                      if( 'comma' == thousands_separator ){
1549                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","))
1550                      }
1550 else if( 'dot' == thousands_separator ){
1551                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."))
1552                      } else if( 'space' == thousands_separator ){
1553                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "))
1554                      } else {
1555                        el.text(Math.floor(this.property));
1556                      }
1557                    },
1558                    complete: function() {
1559                      if( 'comma' == thousands_separator ){
1560                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","))
1561                      } else if( 'dot' == thousands_separator ){
1562                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."))
1563                      } else if( 'space' == thousands_separator ){
1564                        el.text(Math.floor(this.property).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "))
1565                      } else {
1566                        el.text(Math.floor(this.property));
1567                      }
1568                    }
1569                  });
1570
1571                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1572                    this.destroy();
1573                  }
1574                }
1575              }
1576            }
1577          },
1578          {
1579            name: 'Infinite Scroll | Blog & Portfolio',
1580            location: '.mfn-infinite-load-button',
1581            infiniteLoadButton: $('.mfn-infinite-load-button a'),
1582            beforeActive: () => {},
1583            afterActive: ({infiniteLoadButton}) => {
1584              // Leave it, probably will be necessary soon.
1585              // const itemProvided = $('.column_portfolio').length ? '.column_portfolio' : '.column_blog';
1586
1587              // $(`html, ${itemProvided}`).waypoint({
1588              //   handler: function(direction) {
1589              //     infiniteScrollFunction($(location), infiniteLoadButton, direction);
1590              //   },
1591              //   offset: 'bottom-in-view'
1592              // });
1593            },
1594            settings: ({infiniteLoadButton, location}) => {
1595              return {
1596                handler: function(direction) {
1597                  infiniteScrollFunction($(location), infiniteLoadButton, direction);
1598                },
1599                offset: function(){
1600                  //after each load, calc the offset of element to know when posts should be loaded
1601                  var offsetPosition = - ( ($(this)[0].element.scrollHeight) - (window.innerHeight / 1.2) );
1602                  return offsetPosition;
1603                }
1604              }
1605            }
1606          },
1607          {
1608            name: 'Bars List',
1609            location: '.bars_list',
1610            beforeActive: () => {},
1611            afterActive: ({infiniteLoadButton}) => {},
1612            settings: () => {
1613              return {
1614                offset: '100%',
1615                triggerOnce: true,
1616                handler: function() {
1617
1618                  var el = $(this.element).length ? $(this.element) : $(this);
1619
1620                  el.addClass('hover');
1621
1622                  if (typeof this.destroy !== 'undefined' && $.isFunction(this.destroy)) {
1623                    this.destroy();
1624                  }
1625                }
1626              }
1627            }
1628          }
1629        ]
1630      }
1631
1632
1633      runWaypoints(){
1634        const waypoints = this.getList;
1635
1636        waypoints.map(item => {
1637          if( $(item.location).length ) {
1638            // HOOK, before waypoints binding
1639            item.beforeActive(item)
1640
1641            // waypoints init
1642            queueMicrotask(() => $(item.location).waypoint(item.settings( item )) );
1643
1644            // HOOK, after waypoints binding
1645            item.afterActive(item);
1646          }
1647        })
1648      }
1649    }
1650
1651    const mfnWaypoints = new Waypoints;
1652          mfnWaypoints.runWaypoints();
1653
1654    $(document).on('mfn:waypoints', function() {
1655      mfnWaypoints.runWaypoints();
1656    })
1657
1658    /**
1659     * Header template
1660     */
1661
1662    if( $('.promo_bar_slider').length ){
1663      promoBarSlider();
1664    }
1665
1666    if( $('.mfn-looped-items-slider').length ){
1667      queryLoopSlider();
1668    }
1669
1670    headerTemplate.init();
1671    footerTemplate.init();
1672    bannerBox.init();
1673
1674    mfnSideMenu.init();
1675    mfnReadMore.init();
1676
1677    if( $('.mfn-menu-item-megamenu').length ){
1678      headerMegamenu.init();
1679    }
1680
1681    // topBarTop = parseInt($('#Top_bar').css('top'), 10);
1682    // if (topBarTop < 0) topBarTop = 61;
1683    // topBarTop = topBarTop + 'px';
1684
1685    /**
1686     * Sticky | Sidebar
1687     */
1688
1689    function sidebarSticky() {
1690
1691      var spacing = fixStickyHeaderH();
1692
1693      if( ! mfn.sidebarSticky ){
1694        return false;
1695      }
1696
1697      if( $('.woocommerce-store-notice').length ){
1698        spacing += $('.woocommerce-store-notice').outerHeight() || 0;
1699      }
1700
1701      sidebar = $('.mcb-sidebar .widget-area').stickySidebar({
1702        topSpacing: spacing
1703      });
1704
1705    }
1706
1707    sidebarSticky();
1708
1709    $(window).on('debouncedresize', function() {
1710
1711      if( $(window).width() < 767 ){
1712        screen = 'mobile';
1713      }else if($(window).width() < 959){
1714        screen = 'tablet';
1715      }else if($(window).width() > 960){
1716        screen = 'desktop';
1717      }
1718
1719      bannerBox.init();
1720
1721      newWidth = $(window).width();
1722
1723      if( newWidth != currWidth ){
1724        currWidth = $(window).width();
1725        headerTemplate.init();
1726        footerTemplate.init();
1727      }
1728
1729      // stickyWrap.reset();
1730
1731      if( $(window).width() < 767 && !$('.mfn-off-canvas-sidebar').length ){
1732        offCanvasSidebar.mobile();
1733      }else{
1734        $('html').removeClass('mfn-ofcs-opened');
1735      }
1736
1737    });
1738
1739    /**
1740     * Menu | Overlay
1741     */
1742
1743    $('.overlay-menu-toggle').on('click',function(e) {
1744      e.preventDefault();
1745
1746      $(this).toggleClass('focus');
1747      $('#Overlay').stop(true, true).fadeToggle(500);
1748
1749      var menuH = $('#Overlay nav').height() || 0;
1750      menuH = menuH / 2;
1751
1752      $('#Overlay nav').css('margin-top', '-' + menuH + 'px');
1753    });
1754
1755    $('#Overlay').on('click', '.menu-item > a', function() {
1756      $('.overlay-menu-toggle').trigger('click');
1757    });
1758
1759    $( '.header-overlay' ).on( 'keydown', function(event) {
1760      if ( 27 == event.keyCode ) {
1761        $('.overlay-menu-toggle.focus').trigger('click');
1762      }
1763    });
1764
1765    /**
1766     * Menu | Responsive | button
1767     */
1768
1769    $('.responsive-menu-toggle').on('click', function(e) {
1770      e.preventDefault();
1771
1772      var el = $(this);
1773      var menu = $('#Top_bar #menu');
1774      var menuWrap = menu.closest('.top_bar_left');
1775
1776      el.toggleClass('active');
1777
1778      // sticky menu button
1779      if (el.hasClass('is-sticky') && el.hasClass('active') && (window.innerWidth < 768)) {
1780
1781        var top = 0;
1782        if (menuWrap.length) {
1783          top = menuWrap.offset().top - adminBarH();
1784        }
1785        $('body,html').animate({
1786          scrollTop: top
1787        }, 200);
1788
1789      }
1790
1791      menu.stop(true, true).slideToggle(200);
1792    });
1793
1794    // close menu after link click
1795
1796    $('#Top_bar #menu').on('click', 'a:not(.menu-toggle)', function(){
1797      var $menuButton = $('.responsive-menu-toggle.active');
1798
1799      if( $menuButton.length ){
1800        setTimeout(function(){
1801          $menuButton.trigger('click');
1802        },300);
1803      }
1804
1805    });
1806
1807
1808    /**
1809     * Menu | Responsive | Side Slide
1810     */
1811
1812    function sideSlide() {
1813
1814      //if( $('body').hasClass('mfn-header-template') ) return;
1815
1816      var slide = $('#Side_slide');
1817      var overlay = $('#body_overlay');
1818      var ssMobileInitW = mobileInitW;
1819      var pos = 'right';
1820
1821      var shiftSlide = -slide.data('width');
1822      var shiftBody = shiftSlide / 2;
1823
1824      // constructor
1825
1826      var constructor = function() {
1827        if (!slide.hasClass('enabled')) {
1828
1829          $('nav#menu').detach().appendTo('#Side_slide .menu_wrapper');
1830          slide.addClass('enabled');
1831
1832        }
1833      };
1834
1835      // destructor
1836
1837      var destructor = function() {
1838        if (slide.hasClass('enabled')) {
1839
1840          close();
1841          $('nav#menu').detach().prependTo('#Top_bar .menu_wrapper');
1842          slide.removeClass('enabled');
1843
1844        }
1845      };
1846
1847      // reload
1848
1849      var reload = function() {
1850
1851        if ( window.innerWidth < ssMobileInitW ) {
1852          constructor();
1853        } else if( $('body').hasClass('header-shop') ) {
1854          if ($('#Top_bar').hasClass('is-sticky')) {
1855            $(document).trigger('mfn:header:sticky:on');
1856          } else {
1857            $(document).trigger('mfn:header:sticky:off');
1858          }
1859        } else {
1860          destructor();
1861        }
1862
1863      };
1864
1865      // init
1866
1867      var init = function() {
1868
1869        if (slide.hasClass('left')) {
1870          pos = 'left';
1871        }
1872
1873        // responsive off
1874        if ($('body').hasClass('responsive-off')) {
1875          ssMobileInitW = 0;
1876        }
1877
1878        // header simple
1879        if ($('body').hasClass('header-simple')) {
1880          ssMobileInitW = 9999;
1881        }
1882
1883        //  header style: shop | top bar is sticky
1884        if ($('#Top_bar').hasClass('is-sticky')) {
1885          $(document).trigger('mfn:header:sticky:on');
1886        }
1887
1888        reload();
1889      };
1890
1891      // reset to default
1892
1893      var reset = function(time) {
1894
1895        $('.lang-active.active', slide).removeClass('active').children('i').attr('class', 'icon-down-open-mini');
1896        $('.lang-wrapper', slide).fadeOut(0);
1897
1898        $('.icon.search.active', slide).removeClass('active');
1899        $('.search-wrapper', slide).fadeOut(0);
1900
1901        $('.menu_wrapper, .social', slide).fadeIn(time);
1902
1903      };
1904
1905      // menu button
1906
1907      var button = function() {
1908
1909        // show
1910
1911        if (pos == 'left') {
1912          slide.animate({
1913            'left': 0
1914          }, 300);
1915          $('body').animate({
1916            'right': shiftBody
1917          }, 300);
1918        } else {
1919          slide.animate({
1920            'right': 0
1921          }, 300);
1922          $('body').animate({
1923            'left': shiftBody
1924          }, 300);
1925        }
1926
1927        overlay.fadeIn(300);
1928
1929        $('body').addClass('side-slide-is-open');
1930
1931        // reset
1932
1933        reset(0);
1934
1935      };
1936
1937      // close
1938
1939      var close = function() {
1940
1941        if (pos == 'left') {
1942          slide.animate({
1943            'left': shiftSlide
1944          }, 300);
1945          $('body').animate({
1946            'right': 0
1947          }, 300);
1948        } else {
1949          slide.animate({
1950            'right': shiftSlide
1951          }, 300);
1952          $('body').animate({
1953            'left': 0
1954          }, 300);
1955        }
1956
1957        overlay.fadeOut(300);
1958
1959        $('body').removeClass('side-slide-is-open');
1960
1961        /* Just to be sure, change aria. */
1962        if ( $('body').hasClass('keyboard-support') ) {
1963          $('#Side_slide').attr('aria-expanded', 'false');
1964        }
1965
1966        // if page contains revolution slider, trigger resize
1967
1968        if ($('rs-module').length) {
1969          setTimeout(function() {
1970            $(window).trigger('resize');
1971            redrawAllRevolutionSliders();
1972          }, 310);
1973        }
1974
1975      };
1976
1977      // search
1978
1979      $('.icon.search', slide).on('click', function(e) {
1980
1981        e.preventDefault();
1982
1983        var el = $(this);
1984
1985        if (el.hasClass('active')) {
1986
1987          $('.search-wrapper', slide).fadeOut(0);
1988          $('.menu_wrapper, .social', slide).fadeIn(300);
1989
1990        } else {
1991
1992          $('.search-wrapper', slide).fadeIn(300);
1993          $('.menu_wrapper, .social', slide).fadeOut(0);
1994
1995          $('.lang-active.active', slide).removeClass('active').children('i').attr('class', 'icon-down-open-mini');
1996          $('.lang-wrapper', slide).fadeOut(0);
1997
1998        }
1999
2000        el.toggleClass('active');
2001      });
2002
2003      // search form submit
2004
2005      $('a.submit', slide).on('click', function(e) {
2006        e.preventDefault();
2007        $('#side-form').submit();
2008      });
2009
2010      // lang menu
2011
2012      $('.lang-active', slide).on('click', function(e) {
2013        e.preventDefault();
2014
2015        var el = $(this);
2016
2017        if (el.hasClass('active')) {
2018
2019          $('.lang-wrapper', slide).fadeOut(0);
2020          $('.menu_wrapper, .social', slide).fadeIn(300);
2021          el.children('i').attr('class', 'icon-down-open-mini');
2022
2023        } else {
2024
2025          $('.lang-wrapper', slide).fadeIn(300);
2026          $('.menu_wrapper, .social', slide).fadeOut(0);
2027          el.children('i').attr('class', 'icon-up-open-mini');
2028
2029          $('.icon.search.active', slide).removeClass('active');
2030          $('.search-wrapper', slide).fadeOut(0);
2031
2032        }
2033
2034        el.toggleClass('active');
2035      });
2036
2037      // bind ---
2038
2039      // click | menu button
2040
2041      $('.responsive-menu-toggle').off('click');
2042
2043      $('.responsive-menu-toggle').on('click', function(e) {
2044        e.preventDefault();
2045        button();
2046      });
2047
2048      // click | close
2049
2050      overlay.on('click', function(e) {
2051        close();
2052      });
2053
2054      $('.close', slide).on('click', function(e) {
2055        e.preventDefault();
2056        close();
2057      });
2058
2059      $(slide).on('click', '.menu_wrapper a:not(.menu-toggle), .action_button', function(e) {
2060
2061        if( $(this).hasClass('mega-menu-link') ){
2062          return; // FIX: plugin maxmegamenu
2063        }
2064
2065        if( '#' == $(this).attr('href') ){
2066          e.preventDefault();
2067          return;
2068        }
2069
2070        setTimeout(function(){
2071          close();
2072        },500);
2073
2074      });
2075
2076      // click | below search or languages menu
2077
2078      $(slide).on('click', function(e) {
2079        if ($(e.target).is(slide)) {
2080          reset(300);
2081        }
2082      });
2083
2084      // debouncedresize
2085
2086      $(window).on('debouncedresize', reload);
2087
2088      // header style: shop | sticky
2089
2090      if( $('body').hasClass('header-shop') ){
2091
2092        $(document).on('mfn:header:sticky:on', function(){
2093          if( window.innerWidth >= ssMobileInitW ){
2094            $('#Top_bar .menu_wrapper').css('min-height', '70px');
2095            constructor();
2096          }
2097        });
2098
2099        $(document).on('mfn:header:sticky:off', function(){
2100          if( window.innerWidth >= ssMobileInitW ){
2101            destructor();
2102          }
2103        });
2104
2105      }
2106
2107      // init
2108
2109      init();
2110
2111    }
2112
2113    if ($('body').hasClass('mobile-side-slide')) {
2114      sideSlide();
2115    }
2116
2117    /**
2118     * Gallery | WordPress Gallery
2119     */
2120
2121    // WordPress <= 4.9 | content
2122
2123    msnryGalleryInit();
2124
2125    // WordPress >
2125= 5.0 | content
2126
2127    $('.sections_group .wp-block-gallery').each(function(index) {
2128
2129      var el = $(this);
2130      var link = $('.blocks-gallery-item a, .wp-block-image a', el);
2131
2132      // lightbox | link to media file
2133
2134      if ((/\.(gif|jpg|jpeg|png)$/i).test(link.attr('href'))) {
2135        link.attr('rel', 'prettyphoto[wp5-gallery-' + index + ']');
2136      }
2137
2138    });
2139
2140    // widgets
2141
2142    $('.widget_media_gallery .gallery').each(function() {
2143
2144      var el = $(this);
2145      var id = el.attr('id');
2146
2147      // lightbox | link to media file
2148
2149      $('.gallery-icon a', el).attr('rel', 'prettyphoto[widget-' + id + ']');
2150
2151    });
2152
2153    /**
2154     * Lightbox | PrettyPhoto
2155     */
2156
2157    $('a[rel^="prettyphoto[portfolio]"]').each(function() {
2158
2159      var el = $(this);
2160      var parent = el.closest('.column');
2161      var index = $('.column').index(parent);
2162
2163      el.attr('rel', 'prettyphoto[portfolio-' + index + ']');
2164
2165    });
2166
2167    // FIX: elementor + single product | disable duplicated futured image lightbox
2168
2169    $('.elementor-page .woocommerce-product-gallery .woocommerce-product-gallery__image a').attr('href','');
2170
2171    /**
2172     * Lightbox | Magnific Popup
2173     * with prettyPhoto backward compatibility
2174     */
2175
2176    function lightbox() {
2177
2178      var galleries = [];
2179
2180      // init
2181
2182      var init = function() {
2183
2184        if (lightboxAttr) {
2185          compatibility();
2186          setType();
2187          constructor();
2188        }
2189
2190      };
2191
2192      // backward compatibility for prettyPhoto
2193
2194      var compatibility = function() {
2195
2196        $('a[rel^="prettyphoto"], a.prettyphoto, a[rel^="prettyphoto"]').each(function() {
2197
2198          var el = $(this);
2199          var rel = el.attr('rel');
2200
2201          if (rel) {
2202            rel = rel.replace('prettyphoto', 'lightbox');
2203          } else {
2204            rel = 'lightbox';
2205          }
2206
2207          el.removeClass('prettyphoto').attr('rel', rel);
2208
2209        });
2210
2211      };
2212
2213      // check if item is a part of gallery
2214
2215      var isGallery = function(rel) {
2216
2217        if (!rel) {
2218          return false;
2219        }
2220
2221        var regExp = /\[(?:.*)\]/;
2222        var gallery = regExp.exec(rel);
2223
2224        if (gallery) {
2225          gallery = gallery[0];
2226          gallery = gallery.replace('[', '').replace(']', '');
2227          return gallery;
2228        }
2229
2230        return false;
2231      };
2232
2233      // set array of names of galleries
2234
2235      var setGallery = function(gallery) {
2236
2237        if (galleries.indexOf(gallery) == -1) {
2238          galleries.push(gallery);
2239          return true;
2240        }
2241
2242        return false;
2243      };
2244
2245      // get file type by link
2246
2247      var getType = function(src) {
2248
2249        if (src.match(/youtube\.com\/watch/i) || src.match(/youtube\.com\/embed/i) || src.match(/youtu\.be/i)) {
2250          return 'iframe';
2251
2252        } else if (src.match(/youtube-nocookie\.com/i)) {
2253          return 'iframe';
2254
2255        } else if (src.match(/vimeo\.com/i)) {
2256          return 'iframe';
2257
2258        } else if (src.match(/\biframe=true\b/i)) {
2259          return 'ajax';
2260
2261        } else if (src.match(/\bajax=true\b/i)) {
2262          return 'ajax';
2263
2264        } else if (src.match(/\.mp4/i)) {
2265          return 'mp4';
2266
2267        } else if (src.substr(0, 1) == '#') {
2268          return 'inline';
2269
2270        } else {
2271          return 'image';
2272
2273        }
2274      };
2275
2276      // set file type
2277
2278      var setType = function() {
2279
2280        $('a[rel^="lightbox"]').each(function() {
2281
2282          var el = $(this);
2283          var href = el.attr('href');
2284          var rel = el.attr('rel');
2285
2286          // FIX: WPBakery Page Builder duplicated lightbox
2287          if ( el.closest('.wpb_column').length ){
2288            // return true;
2289          }
2290
2291          if (href) {
2292
2293            // gallery
2294
2295            var gallery = isGallery(rel);
2296
2297            if (gallery) {
2298              el.attr('data-lightbox-type', 'gallery');
2299              setGallery(gallery);
2300              return true;
2301            }
2302
2303            el.attr('data-lightbox-type', getType(href));
2304
2305            // iframe paremeters
2306
2307            if (getType(href) == 'iframe') {
2308              el.attr('href', href.replace('&rel=0', ''));
2309            }
2310          }
2311
2312        });
2313
2314      };
2315
2316      // constructor
2317
2318      var constructor = function() {
2319
2320        // Dividing plugins into separate files fix
2321        if( !galleries.length
2322          && !$('a[rel^="lightbox"][data-lightbox-type="image"]').length
2323          && !$('a[rel^="lightbox"][data-lightbox-type="iframe"]').length
2324          && !$('a[rel^="lightbox"][data-lightbox-type="inline"]').length
2325          && !$('a[rel^="lightbox"][data-lightbox-type="mp4"]').length
2326          && !$('a[rel^="pdf-lightbox"]').length
2327        ) return;
2328
2329        var attr = {
2330          autoFocusLast: false,
2331          removalDelay: 160,
2332          image: {
2333            titleSrc: function(item) {
2334              var img = item.el.closest('.image_wrapper, li').find('img').first();
2335              if (lightboxAttr.title && img.length) {
2336                return img.attr('alt');
2337              } else {
2338                return false;
2339              }
2340            }
2341          }
2342        };
2343
2344        // image
2345
2346        $('a[rel^="lightbox"][data-lightbox-type="image"]').magnificPopup({
2347          autoFocusLast: attr.autoFocusLast,
2348          removalDelay: attr.removalDelay,
2349          type: 'image',
2350          image: attr.image
2351        });
2352
2353        // iframe | video
2354
2355        $('a[rel^="lightbox"][data-lightbox-type="iframe"]').magnificPopup({
2356          autoFocusLast: attr.autoFocusLast,
2357          removalDelay: attr.removalDelay,
2358          type: 'iframe',
2359          iframe: {
2360            patterns: {
2361              youtube: {
2362                index: 'youtube.com/',
2363                id: 'v=',
2364                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
2365              },
2366              youtu_be: {
2367                index: 'youtu.be/',
2368                id: '/',
2369                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
2370              },
2371              nocookie: {
2372                index: 'youtube-nocookie.com/embed/',
2373                id: '/',
2374                src: '//www.youtube-nocookie.com/embed/%id%?autoplay=1&rel=0'
2375              }
2376            }
2377          }
2378        });
2379
2380        // iframe | mp4
2381
2382        $('a[rel^="lightbox"][data-lightbox-type="mp4"]').magnificPopup({
2383          autoFocusLast: attr.autoFocusLast,
2384          removalDelay: attr.removalDelay,
2385          type: 'iframe',
2386          iframe: {
2387            markup: '<div class="mfp-mp4 popup-content">'+
2388              '<video controls mute autoplay>'+
2389                '<source class="mfp-source" type="video/mp4">'+
2390              '</video>'+
2391              '<div class="mfp-close"></div>'+
2392            '</div>',
2393            patterns: {
2394              mp4: {
2395                src: '%id%',
2396              }
2397            },
2398            srcAction: 'source_src',
2399          }
2400        });
2401
2402        // pdf
2403
2404        $('a[rel^="pdf-lightbox"]').magnificPopup({
2405          autoFocusLast: attr.autoFocusLast,
2406          removalDelay: attr.removalDelay,
2407          type: 'iframe'
2408        });
2409
2410        // inline
2411
2412        $('a[rel^="lightbox"][data-lightbox-type="inline"]').magnificPopup({
2413          autoFocusLast: attr.autoFocusLast,
2414          type: 'inline',
2415          midClick: true,
2416          callbacks: {
2417            open: function() {
2418              $('.mfp-content').children().addClass('mfp-inline')
2419
2420              // lazy load video and autoplay
2421              // $('.mfp-content').find('source').each(function(){
2422              //   $(this).attr('src', $(this).attr('data-src') );
2423              //   $(this).parent('video').get(0).load();
2424              //   $(this).parent('video').get(0).play();
2425              // });
2426
2427            },
2428            beforeClose: function() {
2429              $('.mfp-content').children().removeClass('mfp-inline');
2430            }
2431          }
2432        });
2433
2434        // gallery
2435
2436        for (var i = 0, len = galleries.length; i < len; i++) {
2437
2438          var gallery = '[' + galleries[i] + ']';
2439          gallery = 'a[rel^="lightbox' + gallery + '"]:visible';
2440
2441          $(gallery).magnificPopup({
2442            autoFocusLast: attr.autoFocusLast,
2443            removalDelay: attr.removalDelay,
2444            type: 'image',
2445            image: attr.image,
2446            gallery: {
2447              enabled: true,
2448              tCounter: '<span class="mfp-counter">%curr% / %total%</span>' // markup of counter
2449            }
2450
2451          });
2452
2453        }
2454
2455        // FIX: elementor | disable in Elementor wrapper
2456
2457        $('.elementor-page a[rel^="lightbox"]:not(.popup-link):not(.rs-layer):not([data-lightbox-type="iframe"])').off('click');
2458
2459        // FIX: WPBakery | disable if WPBakery lighbox is active
2460
2461        setTimeout(function(){
2462
2463          var $doc = $('body');
2464          var $events = $._data($doc[0],"events");
2465
2466          if($events && $events.click){
2467            for(var i=$events.click.length-1; i>=0; i--){
2468              var handler = $events.click[i];
2469              if( handler && handler.selector && handler.selector.indexOf('lightbox') !== -1 ){
2470                $('.wpb_column a[rel^="lightbox"]:not(.popup-link)').off('click');
2471              }
2472            }
2473          }
2474
2475        },0);
2476
2477      };
2478
2479      // reload
2480
2481      var reload = function() {
2482
2483        $('a[rel^="lightbox"]').off('click');
2484        constructor();
2485
2486      };
2487
2488      // init
2489
2490      init();
2491
2492      // isotope:arrange
2493
2494      mfnIsotope.addEventListener('arrange', reload);
2495
2496      // ajaxComplete
2497
2498      $(document).ajaxComplete(function() {
2499        reload();
2500      });
2501
2502    }
2503
2504    lightbox();
2505
2506    $(document).on('mfnPopupInit', function() {
2507      lightbox();
2508    });
2509
2510    /**
2511     * Menu | mfnMenu
2512     */
2513
2514    function mainMenu() {
2515
2516      var mmMobileInitW = mobileInitW;
2517
2518      if ($('body').hasClass('header-simple') || $('#Header_creative.dropdown').length) {
2519        mmMobileInitW = 9999;
2520      }
2521
2522      $('#menu > ul.menu').mfnMenu({
2523        addLast: true,
2524        arrows: true,
2525        mobileInit: mmMobileInitW,
2526        responsive: mfn.responsive
2527      });
2528
2529      $('#secondary-menu > ul.secondary-menu').mfnMenu({
2530        mobileInit: mmMobileInitW,
2531        responsive: mfn.responsive
2532      });
2533
2534    }
2535
2536    mainMenu();
2537
2538    /**
2539     * Menu | NOT One Page | .scroll item
2540     * Works with .scroll class
2541     * Since 4.8 replaced with: Page Options > One Page | function: onePageMenu()
2542     */
2543
2544    function onePageScroll() {
2545      if (!$('body').hasClass('one-page')) {
2546        var menu = $('#menu');
2547
2548        if (menu.find('li.scroll').length > 1) {
2549          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');
2550
2551          // menu item click
2552          menu.on('click','a',function() {
2553            $(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');
2554            $(this).closest('li').addClass('current-menu-item');
2555          });
2556        }
2557      }
2558    }
2559    onePageScroll();
2560
2561    /**
2562     * Menu | One Page | Active on Scroll & Click
2563     */
2564
2565    function onePageMenu() {
2566      if ($('body').hasClass('one-page')) {
2567
2568        var menu = $('#menu');
2569        if( $('#mfn-header-template').length ) menu = $('#mfn-header-template .mfn-header-menu');
2570
2571        // add attr [data-hash] & [data-id]
2572
2573        $('a[href]', menu).each(function() {
2574
2575          var url = $(this).attr('href');
2576          if (url && url.split('#')[1]) {
2577
2578            // data-hash
2579            var hash = '#' + url.split('#')[1];
2580            if (hash && $(hash).length) {
2581              // check if element with specified ID exists
2582              $(this).attr('data-hash', hash);
2583              $(hash).attr('data-id', hash);
2584            }
2585
2586            // Visual Composer
2587            var vcHash = '#' + url.split('#')[1];
2588            var vcClass = '.vc_row.' + url.split('#')[1];
2589            if (vcClass && $(vcClass).length) {
2590              // check if element with specified Class exists
2591              $(this).attr('data-hash', vcHash);
2592              $(vcClass).attr('data-id', vcHash);
2593            }
2594
2595          }
2596
2597        });
2598
2599        // active
2600
2601        var hash;
2602        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';
2603        var activeClasses = 'current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor';
2604
2605        if ($(activeSelector, menu).length) {
2606
2607          // remove duplicated
2608          $(activeSelector, menu)
2609            .not(':first').removeClass(activeClasses);
2610
2611          // remove if 1st link to section & section is not visible
2612          hash = $(activeSelector, menu).find('a[data-hash]').attr('data-hash');
2613
2614          if (hash) {
2615            hash = '[data-id="' + hash + '"]';
2616
2617            if ($(hash).length && $(hash).visible(true)) {
2618              // do nothing
2619            } else {
2620              $(activeSelector, menu).removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor')
2621                .closest('li').removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor');
2622            }
2623          } else {
2624            // do nothing
2625          }
2626
2627        } else {
2628
2629          // add to first if none is active
2630          var first = $('li:first-child', menu);
2631          var firstA = first.children('a');
2632
2633          if (firstA.attr('data-hash')) {
2634            hash = firstA.attr('data-hash');
2635            hash = '[data-id="' + hash + '"]';
2636
2637            if ($(hash).length && ($(hash).offset().top == adminBarH())) {
2638              first.addClass('current-menu-item');
2639            }
2640          }
2641
2642        }
2643
2644        // click
2645
2646        var menu_item = $('#menu a[data-hash]');
2647        if( $('#mfn-header-template').length ) menu_item = $('#mfn-header-template .mfn-header-menu a[data-hash]');
2648
2649        menu_item.on('click', function(e) {
2650          e.preventDefault(); // only with: body.one-page
2651
2652          if( $('html').hasClass('mfn-header-tmpl-burger-sidebar-opened') ){
2653            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2654          }
2655
2656          // active
2657
2658          menu.find('li').removeClass('current-menu-item');
2659          $(this)
2660            .closest('li').addClass('current-menu-item')
2661            .closest('.menu > li').addClass('current-menu-item');
2662
2663          var hash = $(this).attr('data-hash');
2664          hash = '[data-id="' + hash + '"]';
2665
2666          // mobile - sticky header - close menu
2667
2668          if ( window.innerWidth < 768 ) {
2669            $('.responsive-menu-toggle').removeClass('active');
2670            $('#Top_bar #menu').hide();
2671          }
2672
2673          // offset
2674
2675          var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
2676          var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
2677
2678          var offset = headerFixedAbH + tabsHeaderH + adminBarH();
2679
2680          // sticky height
2681
2682          var stickyH = fixStickyHeaderH();
2683
2684          // FIX | Header below | 1st section
2685          if ($('body').hasClass('header-below') && $('#Content').length) {
2686            if ($(hash).offset().top < ($('#Content').offset().top + 60)) {
2687              stickyH = -1;
2688            }
2689          }
2690
2691          // animate scroll
2692
2693          $('html, body').animate({
2694            scrollTop: $(hash).offset().top - offset - stickyH
2695          }, 500);
2696
2697        });
2698
2699      }
2700    }
2701    onePageMenu();
2702
2703    /**
2704     * Header | Creative
2705     */
2706
2707    var cHeader = 'body:not( .header-open ) #Header_creative',
2708      cHeaderEl = $(cHeader),
2709      cHeaderCurrnet;
2710
2711    function creativeHeader() {
2712
2713      $('.creative-menu-toggle').on('click', function(e) {
2714        e.preventDefault();
2715
2716        cHeaderEl.addClass('active');
2717        $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeOut(500);
2718        $('#Action_bar', cHeaderEl).fadeIn(500);
2719
2720      });
2721
2722    }
2723    creativeHeader();
2724
2725    $(document).on('mouseenter', cHeader, function() {
2726      cHeaderCurrnet = 1;
2727    });
2728
2729    $(document).on('mouseleave', cHeader, function() {
2730      cHeaderCurrnet = null;
2731      setTimeout(function() {
2732        if (!cHeaderCurrnet) {
2733
2734          cHeaderEl.removeClass('active');
2735          $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeIn(500);
2736          $('#Action_bar', cHeaderEl).fadeOut(500);
2737
2738        }
2739      }, 1000);
2740    });
2741
2742    // Fix: Header Creative & Mobile Sticky | On Resize > 768 px
2743    function creativeHeaderFix() {
2744      if ( $('body').hasClass('header-creative') && window.innerWidth >= 768 ) {
2745        if ($('#Top_bar').hasClass('is-sticky')) {
2746          $('#Top_bar').removeClass('is-sticky');
2747        }
2748      }
2749    }
2750
2751    /**
2752     * Header | Menu Burger
2753     */
2754
2755    $(document).on("click", ".mfn-header-tmpl .mfn-header-menu-toggle", function(e) {
2756      e.preventDefault();
2757
2758      if( $(this).closest('.mcb-column').hasClass('mfn-header-tmpl-menu-active') ){
2759        $(document).unbind('click', hideSidebarTmplBurger);
2760        $(this).closest('.mcb-column').removeClass('mfn-header-tmpl-menu-active');
2761        removeBringToFront();
2762        if( $('.mfn-header-tmpl-classic-menu').length ) $('.mfn-header-tmpl-classic-menu').remove();
2763        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', false);
2764
2765        $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2766      }else{
2767        $(document).bind('click', hideSidebarTmplBurger);
2768        $(this).closest('.mcb-column').addClass('mfn-header-tmpl-menu-active');
2769        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2770        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2771        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2772        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', true);
2773
2774        if( $(this).closest('.mcb-column-inner').find('.mfn-header-classic-mobile-menu').length ){
2775          var offset_top = $(this).closest('.section').offset().top + $(this).closest('.section').outerHeight() - $(window).scrollTop();
2776
2777          $('body').append('<style class="mfn-header-tmpl-classic-menu">.mfn-header-tmpl-menu-sidebar.mfn-header-classic-mobile-menu{ top: '+offset_top+'px; max-height: '+($(window).height() - offset_top)+'px} .column_header_burger.mfn-header-tmpl-menu-active:before{ top: '+offset_top+'px; max-height: '+($(window).height() - offset_top)+'px}</style>');
2778          //$(this).closest('.mcb-column-inner').find('.mfn-header-classic-mobile-menu').css({'top': offset_top, 'max-height': $(window).height() - offset_top});
2779        }
2780
2781        $('html').addClass('mfn-header-tmpl-burger-sidebar-opened');
2782
2783        var htmlW = $('html').width();
2784
2785        if( $('html').width() != htmlW ){
2786          $('html').addClass('scrollbar-hidden');
2787        }
2788      }
2789
2790    });
2791
2792    $(document).on("click", ".mfn-header-tmpl-menu-sidebar .mfn-header-menu .mfn-menu-li a", function (e) {
2793
2794      if( $(this).closest('#mfn-header-template').length ) return; // The header has its own functionality
2795      
2796        const $a = $(this);
2797        const href = $a.attr("href") || "";
2798        const $html = $("html");
2799        const $header = $(".mfn-header-tmpl.mfn-header-main");
2800
2801        // Case: exactly "#"
2802        if (href === "#") {
2803          e.preventDefault();
2804          $a.closest("li").toggleClass("current-menu-item");
2805          return;
2806        }
2807
2808        let hash = "";
2809        const hashIndex = href.indexOf("#");
2810        if (hashIndex !== -1) hash = href.slice(hashIndex + 1);
2811
2812        if (!hash) return;
2813
2814        const $target = $("#" + CSS.escape(hash));
2815        if (!$target.length) return;
2816
2817        e.preventDefault();
2818
2819        const isFixedOrSticky =
2820          $header.hasClass("mfn-header-tmpl-fixed") || $header.hasClass("mfn-hasSticky");
2821        const headerH = isFixedOrSticky ? $header.outerHeight() : 0;
2822
2823        const $li = $a.closest("li");
2824        $li.closest("ul").find("li.current-menu-item").removeClass("current-menu-item");
2825        $li.addClass("current-menu-item");
2826
2827        const scrollOffset = $target.offset().top - headerH;
2828        $("html, body").stop(true).animate({ scrollTop: scrollOffset }, 500);
2829
2830        $(document).off("click", hideSidebarTmplBurger);
2831        $a.closest(".mcb-column").removeClass("mfn-header-tmpl-menu-active");
2832        removeBringToFront();
2833
2834        if ($html.hasClass("mfn-header-tmpl-burger-sidebar-opened")) {
2835          $html.removeClass("mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden");
2836        }
2837      }
2838    );
2839
2840
2841
2842    $(document).on("click", ".mfn-off-canvas-sidebar .widget_nav_menu ul.menu li a", function(e) {
2843      let href = $(this).attr('href');
2844
2845      if( $(href).length && href.startsWith("#") ) {
2846        e.preventDefault();
2847        let header_h = 0;
2848        if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-tmpl-fixed') || $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-hasSticky') ){
2849          header_h = $('.mfn-header-tmpl.mfn-header-main').outerHeight();
2850        }
2851        $(this).closest('ul').find('li.current-menu-item').removeClass('current-menu-item');
2852        $(this).closest('li').addClass('current-menu-item');
2853
2854        let scroll_offset = $(href).offset().top - header_h;
2855        $('body, html').animate({ scrollTop: scroll_offset }, 500);
2856        if( $('html').hasClass('mfn-ofcs-opened') ){
2857          $('html').removeClass('mfn-ofcs-opened');
2858        }
2859      }
2860    });
2861
2862
2863    function hideSidebarTmplBurger(e){
2864        var div = $('.mfn-header-tmpl-menu-sidebar');
2865
2866        if (!div.is(e.target) && div.has(e.target).length === 0){
2867            $('.mfn-header-tmpl-menu-active').removeClass('mfn-header-tmpl-menu-active');
2868
2869            div.attr('aria-expanded', 'false');
2870
2871            $(document).unbind('click', hideSidebarTmplBurger);
2872            removeBringToFront();
2873            if( $('.mfn-header-tmpl-classic-menu').length ) $('.mfn-header-tmpl-classic-menu').remove();
2874            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2875        }
2876    }
2877
2878    function removeBringToFront(){
2879      if( $('.mfn-bring-to-front').length ) {
2880        $('.mfn-bring-to-front').removeClass('mfn-bring-to-front');
2881      }
2882    }
2883
2884    /**
2885     * Header | Search
2886     */
2887
2888    $(document).on("click", "body:not(.mfn-ui) .mfn-sidemenu-tmpl .mfn-searchbar-toggle, body:not(.mfn-ui) .mfn-header-tmpl .mfn-searchbar-toggle, .mfn-header-tmpl .search_wrapper .mfn-close-icon, .mfn-sidemenu-tmpl .search_wrapper .mfn-close-icon", function(e) {
2889      e.preventDefault();
2890
2891      if( $(this).closest('.mcb-column-inner').hasClass('mfn-searchbar-active') ){
2892        $(this).closest('.mcb-column-inner').removeClass('mfn-searchbar-active');
2893
2894        $('html').removeClass('mfn-popup-browser-scroll-disabled');
2895        $('body').removeClass('search-overlay-opened');
2896        removeBringToFront();
2897      }else{
2898        $(this).closest('.mcb-column-inner').addClass('mfn-searchbar-active');
2899        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2900        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2901        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2902
2903        if( $(this).closest('.mcb-column-inner').find('input.field').length ){
2904          $(this).closest('.mcb-column-inner').find('input.field').focus();
2905        }
2906
2907        if( $('body').hasClass('search-scroll-disable') ){
2908          $('html').addClass('mfn-popup-browser-scroll-disabled');
2909        }
2910
2911        $('body').addClass('search-overlay-opened');
2912      }
2913
2914    });
2915
2916    $(".search_button:not(.has-input), #Top_bar .icon_close").on('click', function(e) {
2917      e.preventDefault();
2918
2919      if( $(this).closest('.mfn-header-tmpl').length ){
2920        // header template
2921        $(this).closest('.mcb-column').toggleClass('mfn-searchbar-active');
2922
2923      }else{
2924        const search = $('.search_wrapper')
2925        if( search.css('display') === 'none' ){
2926          search.fadeIn().find('.field').focus();
2927
2928          if( $('body').hasClass('search-scroll-disable') ){
2929            $('html').addClass('mfn-popup-browser-scroll-disabled');
2930          }
2931
2932          $('body').addClass('search-overlay-opened');
2933
2934          setTimeout(function(){ search.addClass('mfn-loaded') }, 300);
2935        } else{
2936          search.fadeOut().removeClass('mfn-loaded');
2937
2938          $('html').removeClass('mfn-popup-browser-scroll-disabled');
2939          $('body').removeClass('search-overlay-opened');
2940        }
2941      }
2942
2943    });
2944
2945    $(document).on('keydown', function(e){
2946      if (e.key === 'Escape' && $('.search_wrapper').is(':visible') && $('body').hasClass('search-overlay-opened')) {
2947        $('.search_wrapper .icon_close').trigger('click');
2948      }
2949    });
2950
2951    /**
2952     * WPML | Language switcher in the WP Menu
2953     */
2954
2955    function mfnWPML() {
2956      $('#menu .menu-item-language:not(.menu-item-language-current)').each(function() {
2957        var el = $(this).children('a');
2958
2959        if (!el.children('span:not(.icl_lang_sel_bracket)').length) {
2960          el.wrapInner('<span></span>');
2961        }
2962
2963      });
2964
2965      $('#menu span.icl_lang_sel_bracket').each(function() {
2966        var el = $(this);
2967        el.replaceWith(el.html());
2968      });
2969
2970    }
2971    mfnWPML();
2972
2973    /**
2974     * Breadcrumbs | Remove last item link
2975     */
2976
2977    function breadcrumbsRemoveLastLink() {
2978
2979      if( !$('.breadcrumbs.no-link').length ) return;
2980
2981      $('.breadcrumbs.no-link').each(function() {
2982        var el = $(this).find('li').last();
2983        var text = el.text();
2984        el.html(text);
2985      });
2986
2987    }
2988    breadcrumbsRemoveLastLink();
2989
2990    /**
2991     * Downcount
2992     */
2993
2994    $('.downcount:not(.mfn-initialized)').each(function() {
2995      var el = $(this);
2996      el.addClass('mfn-initialized');
2997      el.downCount({
2998        date: el.attr('data-date'),
2999        offset: el.attr('data-offset')
3000      });
3001    });
3002
3003    /**
3004     * Hover | on Touch | .tooltip, .hover_box
3005     */
3006
3007    $('.tooltip, .hover_box')
3008      .on('touchstart', function() {
3009        $(this).toggleClass('hover');
3010      })
3011      .on('touchend', function() {
3012        $(this).removeClass('hover');
3013      });
3014
3015    /**
3016     * Popup | Contact Form | Button
3017     */
3018
3019    $("#popup_contact .footer_button").on('click', function(e) {
3020      e.preventDefault();
3021      $(this).parent().toggleClass('focus');
3022    });
3023
3024    /**
3025     * Scroll | niceScroll for Header Creative
3026     */
3027
3028    if ( $('#Header_creative.scroll').length && window.innerWidth >= 1240 ) {
3029      $('#Header_creative.scroll').niceScroll({
3030        autohidemode: false,
3031        cursorborder: 0,
3032        cursorborderradius: 5,
3033        cursorcolor: '#222222',
3034        cursorwidth: 0,
3035        horizrailenabled: false,
3036        mousescrollstep: 40,
3037        scrollspeed: 60
3038      });
3039    }
3040
3041    /**
3042     * Sliding Top
3043     */
3044
3045    $('.sliding-top-control').on('click', function(e) {
3046      e.preventDefault();
3047      $('#Sliding-top .widgets_wrapper').slideToggle();
3048      $('#Sliding-top').toggleClass('active');
3049    });
3050
3051    /**
3052     * Alert
3053     */
3054
3055    $('body').on('click', '.alert .close', function(e) {
3056      e.preventDefault();
3057      $(this).closest('.alert').hide(300);
3058    });
3059
3060    /**
3061     * Navigation Arrows | Sticky
3062     */
3063
3064    $('.fixed-nav').appendTo('body');
3065
3066    /**
3067     * Feature List
3068     */
3069
3070    $('.feature_list').each(function() {
3071      var col = $(this).attr('data-col') ? $(this).attr('data-col') : 4;
3072      $(this).find('li:nth-child(' + col + 'n):not(:last-child)').after('<hr />');
3073    });
3074
3075    /**
3076     * IE Fixes
3077     */
3078
3079    function checkIE() {
3080      // IE 9
3081      var ua = window.navigator.userAgent;
3082      var msie = ua.indexOf("MSIE ");
3083      if (msie > 0 && parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) == 9) {
3084        $("body").addClass("ie");
3085      }
3086    }
3087    checkIE();
3088
3089    /**
3090     * Parallax
3091     */
3092
3093    var ua = navigator.userAgent,
3094      isMobileWebkit = /WebKit/.test(ua) && /Mobile/.test(ua);
3095
3096    if ( ! isMobileWebkit && window.innerWidth >= 768 ) {
3097
3098      if (mfn.parallax == 'stellar') {
3099
3100        // Stellar
3101        $.stellar({
3102          horizontalScrolling: false,
3103          responsive: true
3104        });
3105
3106      } else {
3107
3108        $(window).enllax();
3109
3110      }
3111
3112    } else {
3113
3114      $('div[data-enllax-ratio], div[data-stellar-ratio]').css('background-attachment', 'scroll');
3115
3116    }
3117
3118    /**
3119     * Infinite Load More | Query Pagination Ajax
3120     */
3121
3122    if( $('.mfn-query-pagination-infiniteload .next').length ){
3123      var mfnQueryPaginationWaypoint = new Waypoint({
3124        element: $('.mfn-query-pagination-infiniteload .next'),
3125        handler: function(direction) {
3126          $(this.element).trigger('click');
3127        },
3128        offset: '100%'
3129      })
3130    }
3131
3132    /**
3133     * Load More | Query Pagination Ajax
3134     */
3135
3136    if( $('.mfn-query-pagination-loadmore .next').length ){
3137      $(document).on('click', '.mfn-query-pagination-loadmore .next', function(e) {
3138        e.preventDefault();
3139
3140        if( $(this).hasClass('loading') ) return;
3141
3142        let button = $(this);
3143        let wrapper = '.'+button.closest('.mcb-section').attr('class').replaceAll('  ', '.').replaceAll(' ', '.');
3144        let href = button.attr('href');
3145
3146        button.addClass('loading');
3147
3148        $.get( href, function( data ) {
3149
3150          $(wrapper+' .section_wrapper').append( $(wrapper+' .section_wrapper', data).html() );
3151          if( $(wrapper+' .mfn-query-pagination', data).length ) $(wrapper+' .mfn-query-pagination').replaceWith($(wrapper+' .mfn-query-pagination', data));
3152
3153          if( $(wrapper+' .isotope').length ){
3154            $(wrapper+' .isotope').imagesLoaded().progress(function() {
3155              $(wrapper+' .isotope').isotope('reloadItems');
3156            });
3157          }
3158
3159          lightbox();
3160
3161          if( $(wrapper).find('.mfn-query-loop-masonry').length ){
3162            queryLoopMasonry();
3163          }
3164
3165
3166          if( $(wrapper+' .mfn-query-pagination').hasClass('mfn-query-pagination-infiniteload') ){
3167            mfnQueryPaginationWaypoint.destroy();
3168
3169
3170
3171            $(wrapper).imagesLoaded(function() {
3172
3173              $(window).trigger('resize');
3174
3175              if( $('.mfn-query-pagination-infiniteload .next').length ){
3176                mfnQueryPaginationWaypoint = new Waypoint({
3177                  element: $('.mfn-query-pagination-infiniteload .next'),
3178                  handler: function(direction) {
3179                    $(this.element).trigger('click');
3180                  },
3181                  offset: '100%'
3182                })
3183
3184              }
3185
3186            });
3187          }
3188
3189        });
3190
3191      });
3192    }
3193
3194    /**
3195     * Load More | Ajax
3196     */
3197
3198    $(document).on('click', '.pager_load_more', function(e) {
3199      e.preventDefault();
3200
3201      var el = $(this);
3202      var pager = el.closest('.pager_lm');
3203
3204      var href = el.attr('href');
3205
3206      // index | for many items on the page
3207      var index = $('.content_wrapper .lm_wrapper').index( el.closest('.mcb-column-inner').find('.lm_wrapper') );
3208
3209      el.fadeOut(50);
3210      pager.addClass('loading');
3211
3212      $.get( href, function( data ) {
3213
3214        // content
3215
3216        // var content = $('.content_wrapper .lm_wrapper', data).html();
3217        // var $content = $(content);
3218
3219		    var content = $('.content_wrapper .lm_wrapper', data).eq(index).html();
3220        var $content;
3221
3222        if (content.indexOf('<') === -1) {
3223          $content = $('<div>').text(content);
3224        } else {
3225          $content = $(content);
3226        }
3227
3228        href = $('.content_wrapper .lm_wrapper:eq(' + index + ')', data).next().find('.pager_load_more').attr('href');
3229
3230        if ($('.content_wrapper .lm_wrapper:eq(' + index + ')').hasClass('isotope')) {
3231
3232          // isotope
3233
3234          const location = '.content_wrapper .lm_wrapper:eq(' + index + ')';
3235          $(location).append( $content );
3236
3237          mfnIsotope.queryIsotopeAPI(location, 'appended', $content);
3238          mfnIsotope.addIsotopeLocation({ name: 'Load More - Ajax', location });
3239
3240          if( $(location).find('.isotope-item').length ){
3241            $(location).imagesLoaded().progress(function() {
3242              $(location).isotope('reloadItems');
3243            });
3244          }
3245
3246        } else if ($('.content_wrapper .lm_wrapper:eq(' + index + ')').hasClass('mfn-woo-products')) {
3247
3248          // different .pager_load_more DOM location
3249          if (typeof href === 'undefined'){
3250            href = $('.content_wrapper .lm_wrapper:eq(' + index + ') .pager_load_more', data).attr('href');
3251          }
3252
3253          $('.content_wrapper .lm_wrapper:eq(' + index + ') ul.products').append( $content.html() );
3254
3255          var $listing = $('.content_wrapper .lm_wrapper:eq(' + index + ') ul.products.isotope');
3256
3257          if( $listing.length ){
3258            $listing.imagesLoaded().progress(function() {
3259              $listing.isotope('reloadItems');
3260            });
3261          }
3262
3263        } else {
3264          // default
3265          $content.hide().appendTo('.content_wrapper .lm_wrapper:eq(' + index + ')').fadeIn(1000);
3266        }
3267
3268        // next page link
3269
3270        pager.removeClass('loading');
3271        if (href) {
3272          el.fadeIn();
3273          el.attr('href', href);
3274        }
3275
3276        // refresh some staff
3277
3278        lightbox();
3279
3280        // isotope fix: second resize
3281
3282        if( $('.lm_wrapper.isotope').length ){
3283          $('.lm_wrapper.isotope').imagesLoaded().progress(function() {
3284            mfnIsotope.queryIsotopeAPI( '.lm_wrapper.isotope' );
3285          });
3286        }
3287
3288      });
3289
3290    });
3291
3292    /**
3293     * Filters | Blog & Portfolio
3294     */
3295
3296    $('.filters_buttons .open').on('click', function(e) {
3297      e.preventDefault();
3298      var type = $(this).closest('li').attr('class');
3299
3300      $('.filters_wrapper').show(200);
3301      $('.filters_wrapper ul.' + type).show(200);
3302      $('.filters_wrapper ul:not(.' + type + ')').hide();
3303    });
3304
3305    $('.filters_wrapper .close a').on('click', function(e) {
3306      e.preventDefault();
3307      $('.filters_wrapper').hide(200);
3308    });
3309
3310    /**
3311     * Portfolio List | Next v / Prev ^ buttons
3312     */
3313
3314    $('.portfolio_next_js').on('click', function(e) {
3315      e.preventDefault();
3316
3317      var item = $(this).closest('.portfolio-item').next();
3318
3319      if (item.length) {
3320        $('html, body').animate({
3321          scrollTop: item.offset().top - fixStickyHeaderH()
3322        }, 500);
3323      }
3324    });
3325
3326    $('.portfolio_prev_js').on('click', function(e) {
3327      e.preventDefault();
3328
3329      var item = $(this).closest('.portfolio-item').prev();
3330
3331      if (item.length) {
3332        $('html, body').animate({
3333          scrollTop: item.offset().top - fixStickyHeaderH()
3334        }, 500);
3335      }
3336    });
3337
3338    /**
3339     * Link | Smooth Scroll | .scroll
3340     */
3341
3342    $('body').on('click', '.scroll > a, a.scroll, .mcb-column.scroll a', function(e) {
3343
3344      // prevent default if link directs to the current page
3345
3346      // var urlL = location.href.replace(/\/#.*|#.*/, '');
3347      // var urlT = this.href.replace(/\/#.*|#.*/, ''); // remove also trailing slash
3348
3349      var urlL = location.href.replace(/#.*/, '');
3350      var urlT = this.href.replace(/#.*/, '');
3351
3352      if (urlL == urlT) {
3353        e.preventDefault();
3354      }
3355
3356      var hash = this.hash;
3357
3358      // offset
3359
3360      var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
3361      var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
3362
3363      var offset = headerFixedAbH + tabsHeaderH + adminBarH();
3364
3365      // table of contents
3366
3367      if( $(this).parents('.table_of_content').length ){
3368        offset += 30;
3369      }
3370
3371      // animate scroll
3372
3373      if (hash && $(hash).length) {
3374
3375        // do scroll
3376
3377        $('html, body').animate({
3378          scrollTop: $(hash).offset().top - offset - fixStickyHeaderH()
3379        }, 500);
3380      }
3381    });
3382
3383    /**
3384     * Tabs
3385     */
3386
3387    $('.jq-tabs').tabs();
3388
3389    /**
3390     * Fake tabs
3391     */
3392
3393    $('.fake-tabs > ul').on('click', 'a', function(e) {
3394      e.preventDefault();
3395
3396      var $li = $(this).closest('li');
3397
3398      var tab = $li.data('tab');
3399
3400      if( $li.hasClass('active') ){
3401        return;
3402      }
3403
3404      $li.addClass('active')
3405        .siblings().removeClass('active');
3406
3407      $('.tab-'+ tab ).addClass('active').attr('tabindex', 0)
3408        .siblings('.tab').removeClass('active').attr('tabindex', -1);
3409
3410      $(window).trigger('resize');
3411    });
3412
3413    /**
3414     * Toggle
3415     */
3416
3417    $('body').on('click', '.mfn-toggle .toggle-bar', function() {
3418
3419      var $parent = $(this).parent(),
3420        $toggle = $(this).closest('.mfn-toggle');
3421      var speed = 100;
3422
3423      if ( $parent.hasClass('active') ) {
3424
3425        if( $toggle.is('.mfn-toggle-open-all') ){
3426          return;
3427        }
3428
3429        $parent.removeClass('active')
3430          .children('.toggle-content').slideUp(speed);
3431
3432      } else {
3433
3434        $parent.addClass('active')
3435          .children('.toggle-content').slideDown(speed);
3436
3437        if( ! $toggle.is('.mfn-toggle-open-more') ){
3438          $parent.siblings().removeClass('active')
3439            .children('.toggle-content').slideUp(speed);
3440        }
3441
3442      }
3443
3444      setTimeout(function() {
3445        $(window).trigger('resize');
3446      }, speed);
3447
3448    });
3449
3450    /**
3451     * Accordion & FAQ
3452     */
3453
3454    $('.mfn-acc').each(function() {
3455      var el = $(this);
3456
3457      if (el.hasClass('openAll') || el.find('.wpb_toggle_title_active').length) {
3458
3459        // show all
3460        el.find('.question')
3461          .addClass('active')
3462          .children(".answer")
3463          .show();
3464
3465      } else {
3466
3467        // show one
3468        var activeTab = el.attr('data-active-tab');
3469        if (el.hasClass('open1st')) activeTab = 1;
3470
3471        if (activeTab) {
3472          el.find('.question').eq(activeTab - 1)
3473            .addClass('active')
3474            .children(".answer")
3475            .show();
3476        }
3477
3478      }
3479    });
3480
3481    $('.mfn-acc .question > .title').on('click', function() {
3482
3483      if ($(this).parent().hasClass('active')) {
3484
3485        $(this).parent().removeClass('active').children(".answer").slideToggle(100);
3486
3487      } else {
3488
3489        if (!$(this).closest('.mfn-acc').hasClass('toggle')) {
3490          $(this).parents(".mfn-acc").children().each(function() {
3491            if ($(this).hasClass('active')) {
3492              $(this).removeClass('active').children(".answer").slideToggle(100);
3493            }
3494          });
3495        }
3496        $(this).parent().addClass('active');
3497        $(this).next(".answer").slideToggle(100);
3498
3499      }
3500
3501      setTimeout(function() {
3502        $(window).trigger('resize');
3503      }, 50);
3504
3505    });
3506
3507    // Visual Composer | Accordion | Sidebar height
3508    $('.wpb_wrapper .vc_tta-panel-title').on('click', 'a', function() {
3509
3510      setTimeout(function() {
3511        $(window).trigger('resize');
3512      }, 50);
3513
3514    });
3515
3516    /**
3517     * Helper
3518     */
3519
3520    $('.helper .link.toggle').on('click', function(e) {
3521
3522      e.preventDefault();
3523
3524      var el = $(this);
3525      var id = el.attr('data-rel');
3526      var parent = el.closest('.helper');
3527
3528      if (el.hasClass('active')) {
3529
3530        el.removeClass('active');
3531        parent.find('.helper_content > .item-' + id).slideUp(200);
3532
3533        setTimeout(function() {
3534          parent.find('.helper_content > .item-' + id).removeClass('active');
3535        }, 200);
3536
3537      } else {
3538
3539        parent.find('.links > .link.active').removeClass('active');
3540        parent.find('.helper_content > .item.active').slideUp(200);
3541
3542        el.addClass('active');
3543        parent.find('.helper_content > .item-' + id).addClass('active').hide().slideDown(200);
3544
3545      }
3546
3547      setTimeout(function() {
3548        $(window).trigger('resize');
3549      }, 50);
3550
3551    });
3552
3553    /**
3554     * Love
3555     */
3556
3557    $(document).on('click', '.mfn-love', function(e) {
3558      e.preventDefault();
3559      var el = $(this);
3560
3561      if (el.hasClass('loved')) {
3562        return false;
3563      }
3564      el.addClass('loved');
3565
3566      var post = {
3567        action: 'mfn_love',
3568        post_id: el.attr('data-id')
3569      };
3570
3571      $.post(mfn.ajax, post, function(data) {
3572        el.find('.label').html(data);
3573      });
3574
3575      return false;
3576    });
3577
3578    /**
3579     * Go to top
3580     */
3581
3582    $('#back_to_top').on('click', function() {
3583      $('body,html').animate({
3584        scrollTop: 0
3585      }, 500);
3586      return false;
3587    });
3588
3589    /**
3590     * Section | Next v / Prev ^ navigation arrows
3591     */
3592
3593    $('.section .section-nav').on('click', function() {
3594
3595      var el = $(this);
3596      var section = el.closest('.section');
3597
3598      var offset = fixStickyHeaderH() + adminBarH();
3599
3600      if (el.hasClass('prev')) {
3601
3602        // Previous Section
3603        if (section.prev().length) {
3604          $('html, body').animate({
3605            scrollTop: section.prev().offset().top - offset
3606          }, 500);
3607        }
3608
3609      } else {
3610
3611        // Next Section
3612        if (section.next().length) {
3613          $('html, body').animate({
3614            scrollTop: section.next().offset().top - offset
3615          }, 500);
3616        }
3617
3618      }
3619    });
3620
3621    /**
3622     * Intro | Scroll v arrow
3623     */
3624
3625    $('#Intro .intro-next').on('click', function() {
3626      var intro = $(this).closest('#Intro');
3627
3628      if (intro.next().length) {
3629        $('html, body').animate({
3630          scrollTop: intro.next().offset().top - fixStickyHeaderH() - adminBarH()
3631        }, 500);
3632      }
3633    });
3634
3635    /**
3636     * Widget | Muffin Menu | Hover on click
3637     */
3638
3639    $('.widget_mfn_menu ul.submenus-click, .widget_mfn_menu ul.submenus-click-mobile').each(function() {
3640
3641      var el = $(this);
3642
3643      if( el.is('.submenus-click-mobile') && $(window).width() > 767 ){
3644        return;
3645      }
3646
3647      $('a', el).on('click', function(e) {
3648        var li = $(this).closest('li');
3649
3650        if (li.hasClass('hover') || !li.hasClass('menu-item-has-children')) {
3651          // link click
3652        } else {
3653          e.preventDefault();
3654          li.siblings('li').removeClass('hover')
3655            .find('li').removeClass('hover');
3656          $(this).closest('li').addClass('hover');
3657        }
3658
3659      });
3660
3661    });
3662
3663    /**
3664     * WooCommerce | Add to cart
3665     */
3666
3667    function addToCart() {
3668
3669      $('body').on('click', '.add_to_cart_button', function() {
3670        $(this)
3671          .closest('.product')
3672          .addClass('adding-to-cart')
3673          .removeClass('added-to-cart');
3674      });
3675
3676      $('body').on('added_to_cart', function() {
3677        $('.adding-to-cart')
3678          .removeClass('adding-to-cart')
3679          .addClass('added-to-cart');
3680      });
3681    }
3682    addToCart();
3683
3684    /**
3685     * WooCommerce | Rating click
3686     */
3687
3688    $('.woocommerce-product-rating').on('click', function(){
3689
3690      var el;
3691
3692      if( $('.product_tabs_wrapper.fake-tabs').length ){
3693
3694        el = $('.product_tabs_wrapper.fake-tabs');
3695        $('li[data-tab="reviews"] a', el).trigger('click');
3696
3697      } else if( $('.woocommerce-content .jq-tabs').length ){
3698
3699        el = $('.woocommerce-content .jq-tabs');
3700        $('.ui-tabs-nav a[href="#tab-reviews"]', el).trigger('click');
3701
3702      } else {
3703
3704        el = $('.woocommerce-content .accordion');
3705        $('#reviews').closest('.question:not(.active)').children('.title').trigger('click');
3706
3707      }
3708
3709      // offset
3710
3711      var actionBarH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
3712      var offset = actionBarH + adminBarH();
3713
3714      // animate scroll
3715
3716      $('html, body').animate({
3717        scrollTop: el.offset().top - offset - fixStickyHeaderH()
3718      }, 500);
3719
3720    });
3721
3722    /**
3723     * WooCommerce | Quantity change
3724     */
3725
3726    $('body').on('click', '.quantity-change', function(e){
3727
3728      e.preventDefault();
3729
3730      var $el = $(this),
3731        $input = $(this).siblings('input');
3732
3733      var step = parseFloat($input.attr('step')) || 1,
3734        minAttr = $input.attr('min'),
3735        min = typeof minAttr !== typeof undefined && minAttr !== false ? parseFloat(minAttr) : 1,
3736        max = parseFloat($input.attr('max')) || 9999,
3737        current = $input.val() ? parseFloat($input.val()) : min,
3738        val = 0;
3739
3740      if( $el.hasClass('plus') ){
3741        val = current + step;
3742        if( val > max ){
3743          val = current;
3744        }
3745      } else {
3746        val = current - step;
3747        if( val < min ){
3748          val = current;
3749        }
3750      }
3751
3752      val = Math.round(val * 10) / 10;
3753
3754      $input.val(val).trigger('change');
3755
3756    });
3757
3758    /**
3759     * Ajax | Complete
3760     */
3761
3762    $(document).ajaxComplete(function() {
3763
3764      setTimeout(function() {
3765        $(window).trigger('resize');
3766        mfnSidebar();
3767      }, 100);
3768
3769    });
3770
3771    /**
3772     * $(window).on('debouncedresize')
3773     * Specify a function to execute on window resize
3774     */
3775
3776    $(window).on('debouncedresize', function() {
3777
3778      // isotope
3779      mfnIsotope.runIsotopes( false );
3780
3781      // sliding footer height
3782
3783      mfnFooter();
3784
3785      // header width
3786
3787      headerWidth();
3788
3789      // sidebar height
3790
3791      mfnSidebar();
3792
3793      // intro header
3794
3795      mfnIntroH();
3796
3797      // mobile sticky for header creative
3798
3799      creativeHeaderFix();
3800
3801    });
3802
3803    /**
3804     * Bind()
3805     */
3806
3807    // consent
3808
3809    $('.mfn-cookies').on('click','.cookies-tab-nav a', function(e){
3810      e.preventDefault();
3811      consent.tabs($(this), false);
3812    });
3813
3814    $('.mfn-cookies').on('click','#consent_customize', function(e){
3815      e.preventDefault();
3816      consent.tabs(false, 'details');
3817    });
3818
3819    $('.mfn-cookies').on('click','#consent_allow', function(e){
3820      e.preventDefault();
3821      consent.all();
3822    });
3823
3824    $('.mfn-cookies').on('click','#consent_selected', function(e){
3825      e.preventDefault();
3826      consent.selected();
3827    });
3828
3829    $('.mfn-cookies').on('click','#consent_deny', function(e){
3830      e.preventDefault();
3831      consent.deny();
3832    });
3833
3834    $('.mfn-cookies-reopen').on('click', function(e){
3835      consent.reopen();
3836    });
3837
3838    /**
3839     * document.ready
3840     * Initialize document ready functions
3841     */
3842
3843    mfnSliderBlog();
3844    mfnSliderClients();
3845    mfnSliderOffer();
3846    mfnSliderOfferThumb();
3847    mfnSliderShop();
3848
3849    sliderPortfolio();
3850    sliderTestimonials();
3851
3852    // sliding footer height
3853
3854    mfnFooter();
3855
3856    // header width
3857
3858    headerWidth();
3859
3860    // sidebar height
3861
3862    mfnSidebar();
3863
3864    // intro header
3865
3866    mfnIntroH();
3867
3868    // hash navigation
3869
3870    hashNav();
3871
3872    // GDPR container display
3873
3874    gdpr(); // gdpr 1.0
3875    consent.open(); // gdpr 2.0
3876
3877    // table of contents
3878
3879    tableContentAttachId();
3880
3881    // top bar top position
3882
3883    topBarTopPosition();
3884
3885    if( !$('body').hasClass('mfn-ui') ) mfnPopup.init();
3886
3887  });
3888
3889  /**
3890   * $(window).on('scroll')
3891   * The scroll event is sent to an element when the user scrolls to a different place in the element.
3892   */
3893
3894  $(window).on('scroll', function() {
3895
3896    // sticky header
3897
3898    mfnSticky();
3899    mfnMobileSticky();
3900
3901    // sticky back to top
3902
3903    backToTopSticky();
3904
3905    // one page scroll active
3906
3907    onePageActive();
3908
3909  });
3910
3911  /**
3912   * $(window).on('load')
3913   * window.load
3914   */
3915
3916  $(window).on('load', function() {
3917
3918    preloader();
3919
3920    queryLoopMasonry();
3921
3922    // align divs heights
3923
3924    alignHeights();
3925
3926    /**
3927     * Elementor plugin
3928     * Disable built-in one page
3929     */
3930
3931    function elementorDisableOnePage(){
3932
3933      if( ! $('body').hasClass('one-page') ){
3934        return false;
3935      }
3936
3937      setTimeout(function(){
3938        var doc=$(document),
3939          $events=$("a[href*='#']").length ? $._data(doc[0],"events") : null;
3940        if($events && $events.click){
3941          for(var i=$events.click.length-1; i>=0; i--){
3942            var handler=$events.click[i];
3943            if(handler && handler.namespace != "mPS2id" && handler.selector === 'a[href*="#"]' ) doc.off("click",handler.handler);
3944          }
3945        }
3946      }, 300);
3947
3948    }
3949
3950    elementorDisableOnePage();
3951
3952    /**
3953     * Live search item
3954     * z-index for live search item parents
3955     */
3956
3957    function liveSearchItemZindex(){
3958
3959      $('.column_livesearch').each(function(){
3960        $(this).closest('.mcb-wrap').addClass('has-live-search-element')
3961          .closest('.mcb-section').addClass('has-live-search-element');
3962      });
3963
3964    }
3965
3966    liveSearchItemZindex();
3967
3968    /**
3969     * Retina Logo
3970     */
3971
3972    function retinaLogo() {
3973
3974      // ! retina display
3975
3976      if( window.devicePixelRatio <= 1 ){
3977        return false;
3978      }
3979
3980      var el, src, height,
3981        parent = $('#Top_bar #logo'),
3982        parentH = parent.data('height');
3983
3984      var maxH = {
3985        sticky: {
3986          init: 35,
3987          noPadding: 60,
3988          overflow: 110
3989        },
3990        mobile: {
3991          mini: 50,
3992          miniNoPadding: 60
3993        },
3994        mobileSticky: {
3995          init: 50,
3996          noPadding: 60,
3997          overflow: 80
3998        }
3999      };
4000
4001      $('#Top_bar #logo img').each(function(index) {
4002
4003        el = $(this);
4004        src = el.data('retina');
4005        height = el.height() || 0;
4006
4007        // main
4008
4009        if (el.hasClass('logo-main')) {
4010
4011          if ($('body').hasClass('logo-overflow')) {
4012
4013            // do nothing
4014
4015          } else if (height > parentH) {
4016
4017            height = parentH;
4018
4019          }
4020
4021        }
4022
4023        // sticky
4024
4025        if (el.hasClass('logo-sticky')) {
4026
4027          if ($('body').hasClass('logo-overflow')) {
4028
4029            if (height > maxH.sticky.overflow) {
4030              height = maxH.sticky.overflow;
4031            }
4032
4033          } else if ($('body').hasClass('logo-no-sticky-padding')) {
4034
4035            if (height > maxH.sticky.noPadding) {
4036              height = maxH.sticky.noPadding;
4037            }
4038
4039          } else if (height > maxH.sticky.init) {
4040
4041            height = maxH.sticky.init;
4042
4043          }
4044
4045        }
4046
4047        // mobile
4048
4049        if (el.hasClass('logo-mobile')) {
4050
4051          if ($('body').hasClass('mobile-header-mini')) {
4052
4053            if (parent.data('padding') > 0) {
4054
4055              if (height > maxH.mobile.mini) {
4056                height = maxH.mobile.mini;
4057              }
4058
4059            } else {
4060
4061              if (height > maxH.mobile.miniNoPadding) {
4062                height = maxH.mobile.miniNoPadding;
4063              }
4064
4065            }
4066
4067          }
4068
4069        }
4070
4071        // mobile-sticky
4072
4073        if (el.hasClass('logo-mobile-sticky')) {
4074
4075          if ($('body').hasClass('logo-no-sticky-padding')) {
4076
4077            if (height > maxH.mobileSticky.noPadding) {
4078              height = maxH.mobileSticky.noPadding;
4079            }
4080
4081          } else if (height > maxH.mobileSticky.init) {
4082            height = maxH.mobileSticky.init;
4083          }
4084
4085        }
4086
4087        // SET
4088
4089        if (src) {
4090          el.parent().addClass('retina');
4091          el.attr('src', src).css('max-height', height + 'px');
4092        }
4093
4094      });
4095
4096    }
4097
4098    setTimeout(function() {
4099      retinaLogo();
4100    }, 0); // jQuery 3.5 window.load
4101
4102    /**
4103     * Before After | TwentyTwenty
4104     */
4105
4106    $('#Wrapper .before_after.twentytwenty-container:not(.mfn-initialized)').each(function(){
4107
4108      var el = $(this);
4109
4110      el.addClass('mfn-initialized');
4111      el.imagesLoaded().done(function(instance, image){
4112
4113        queueMicrotask(() => el.twentytwenty());
4114
4115      });
4116
4117    });
4118
4119    // Visual Composer prettyPhoto | off
4120
4121    if ( lightboxAttr ) {
4122      $('a[data-rel^="prettyPhoto"]:not(.popup-link), a[rel^="lightbox"]:not(.popup-link)').each(function() {
4123        $(this).off('click.prettyphoto');
4124      });
4125    }
4126
4127    /**
4128     * Reload some functions on window.load
4129     */
4130
4131    // sticky header
4132
4133    mfnStickyH();
4134    mfnSticky();
4135    mfnMobileSticky();
4136
4137    // intro header
4138
4139    mfnIntroH();
4140
4141    // FIX | jQuery 3.5 window.load
4142
4143    setTimeout(function() {
4144
4145      // triger resize to recalculate some plugins stuff
4146      $(window).trigger('resize');
4147
4148      // sidebar height
4149
4150      mfnSidebar();
4151
4152      // sliders
4153
4154      sliderSlider();
4155
4156    }, 0);
4157
4158  });
4159
4160  /**
4161   * $(document).on('mouseup')
4162   * Specify a function to execute when the DOM is fully loaded.
4163   * Close some modals when click outside
4164   */
4165
4166  $(document).on('mouseup',function(e) {
4167
4168    // Widget | Muffin menu | Hover on click
4169
4170    if ($('.widget_mfn_menu ul.submenus-click').length && ($('.widget_mfn_menu ul.submenus-click').has(e.target).length === 0) ) {
4171      $('.widget_mfn_menu ul.submenus-click li').removeClass('hover');
4172    }
4173
4174    // Mobile menu | Classic
4175
4176    if ($('.menu_wrapper').length && ( $('.menu_wrapper').has(e.target).length === 0 )) {
4177      if( $('.responsive-menu-toggle').hasClass('active') ){
4178        $('.responsive-menu-toggle').trigger('click');
4179      }
4180    }
4181
4182    // Popup contact form
4183
4184    if ($('#popup_contact').length && ( $('#popup_contact').has(e.target).length === 0 )) {
4185      if( $('#popup_contact').hasClass('focus') ){
4186        $('#popup_contact .footer_button').trigger('click');
4187      }
4188    }
4189
4190    // Off canvas sidebar
4191
4192    if($('html').hasClass('mfn-ofcs-opened') && !$('.mfn-off-canvas-sidebar').is(e.target) && $('.mfn-off-canvas-sidebar').has(e.target).length === 0){
4193      $('html').removeClass('mfn-ofcs-opened');
4194    }
4195
4196  });
4197
4198  /**
4199   * Sliders configuration
4200   */
4201
4202  // Slick Slider | Auto responsive
4203
4204  function slickAutoResponsive(slider, max, size, round = false) {
4205
4206    if (!max){
4207      max = 5;
4208    }
4209    if (!size){
4210      size = 380;
4211    }
4212
4213    var width = slider.width() || 0;
4214    var count;
4215
4216    if ( round ) {
4217      count = Math.floor(width / size);
4218    } else {
4219      count = Math.ceil(width / size);
4220    }
4221
4222    if (count < 1) count = 1;
4223    if (count > max) count = max;
4224
4225    return count;
4226  }
4227
4228  // Slider | Offer Thumb
4229
4230  function mfnSliderOfferThumb() {
4231
4232    var pager = function(el, i) {
4233      var img = $(el.$slides[i]).find('.thumbnail:first').html();
4234      return '<a>' + img + '</a>';
4235    };
4236
4237    $('.offer_thumb_ul').each(function() {
4238
4239      var slider = $(this);
4240
4241      slider.slick({
4242        cssEase: 'ease-out',
4243        arrows: false,
4244        dots: true,
4245        infinite: true,
4246        touchThreshold: 10,
4247        speed: 300,
4248
4249        adaptiveHeight: true,
4250        appendDots: slider.siblings('.slider_pagination'),
4251        customPaging: pager,
4252
4253        rtl: rtl ? true : false,
4254        autoplay: mfn.slider.offer ? true : false,
4255        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
4256
4257        slidesToShow: 1,
4258        slidesToScroll: 1
4259      });
4260
4261      // ON | debouncedresize
4262
4263      $(window).on('debouncedresize', function() {
4264        // set slider min-height to thumbnails height
4265        var height = slider.siblings('.slider_pagination').height();
4266        slider.closest('.offer_thumb ').css('min-height',height);
4267      });
4268
4269    });
4270  }
4271
4272  // Slider | Offer
4273
4274  function mfnSliderOffer() {
4275    $('.offer_ul').each(function() {
4276
4277      var slider = $(this);
4278
4279      slider.slick({
4280        cssEase: 'ease-out',
4281        dots: false,
4282        infinite: true,
4283        touchThreshold: 10,
4284        speed: 300,
4285
4286        prevArrow: '<a class="slider_prev" href="#" aria-label="previous slide"><span class="button_icon"><i class="icon-up-open-big"></i></span></a>',
4287        nextArrow: '<a class="slider_next" href="#" aria-label="next slide"><span class="button_icon"><i class="icon-down-open-big"></i></span></a>',
4288
4289        adaptiveHeight: true,
4290        //customPaging 	: pager,
4291
4292        rtl: rtl ? true : false,
4293        autoplay: mfn.slider.offer ? true : false,
4294        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
4295
4296        slidesToShow: 1,
4297        slidesToScroll: 1
4298      });
4299
4300      // Pagination | Show (css)
4301
4302      slider.siblings('.slider_pagination').addClass('show');
4303
4304      // Pager | Set slide number after change
4305
4306      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
4307        slider.siblings('.slider_pagination').find('.current').text(currentSlide + 1);
4308      });
4309
4310    });
4311  }
4312
4313  // Slider | Shop
4314
4315  function mfnSliderShop() {
4316
4317    var pager = function(el, i) {
4318      return '<a>' + i + '</a>';
4319    };
4320
4321    $('.shop_slider_ul').each(function() {
4322
4323      var slider = $(this);
4324      var slidesToShow = 4;
4325
4326      var count = slider.closest('.shop_slider').data('count');
4327      if (slidesToShow > count) {
4328        slidesToShow = count;
4329        if (slidesToShow < 1) {
4330          slidesToShow = 1;
4331        }
4332      }
4333
4334      slider.slick({
4335        cssEase: 'ease-out',
4336        dots: true,
4337        infinite: true,
4338        touchThreshold: 10,
4339        speed: 300,
4340
4341        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4342        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4343        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
4344
4345        appendDots: slider.siblings('.slider_pager'),
4346        customPaging: pager,
4347
4348        rtl: rtl ? true : false,
4349        autoplay: mfn.slider.shop ? true : false,
4350        autoplaySpeed: mfn.slider.shop ? mfn.slider.shop : 5000,
4351
4352        slidesToShow: slickAutoResponsive(slider, slidesToShow),
4353        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
4354      });
4355
4356      // ON | debouncedresize
4357
4358      $(window).on('debouncedresize', function() {
4359        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
4360        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
4361      });
4362
4363    });
4364  }
4365
4366  // Slider | Blog
4367
4368  function mfnSliderBlog() {
4369
4370    var pager = function(el, i) {
4371      return '<a>' + i + '</a>';
4372    };
4373
4374    $('.blog_slider_ul').each(function() {
4375
4376      var slider = $(this);
4377      var slidesToShow = 4;
4378
4379      var count = slider.closest('.blog_slider').data('count');
4380      var singlePostMode = slider.closest('.blog_slider').hasClass('single_post_mode');
4381
4382      if (slidesToShow > count) {
4383        slidesToShow = count;
4384        if (slidesToShow < 1) {
4385          slidesToShow = 1;
4386        }
4387      }
4388
4389      if (singlePostMode) {
4390        slidesToShow = 1;
4391      }
4392
4393      slider.slick({
4394        cssEase: 'ease-out',
4395        dots: true,
4396        infinite: true,
4397        touchThreshold: 10,
4398        speed: 300,
4399
4400        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4401        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4402        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
4403
4404        appendDots: slider.siblings('.slider_pager'),
4405        customPaging: pager,
4406
4407        rtl: rtl ? true : false,
4408        autoplay: mfn.slider.blog ? true : false,
4409        autoplaySpeed: mfn.slider.blog ? mfn.slider.blog : 5000,
4410
4411        slidesToShow: slickAutoResponsive(slider, slidesToShow),
4412        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
4413      });
4414
4415      // On | debouncedresize
4416
4417      $(window).on('debouncedresize', function() {
4418        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
4419        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
4420      });
4421
4422    });
4423  }
4424
4425  // Slider | Clients
4426
4427  function mfnSliderClients() {
4428    $('.clients_slider_ul').each(function() {
4429
4430      var slider = $(this);
4431
4432      var clientsPerSlide = slider.closest('.clients_slider').attr('data-client-per-slide') ? parseInt(slider.closest('.clients_slider').attr('data-client-per-slide')) : 4;
4433      var navigationPosition = slider.closest('.clients_slider').attr('data-navigation-position') || false;
4434      var appendArrows = ( navigationPosition == 'content' ) ? slider : slider.siblings('.blog_slider_header').children('.slider_navigation');
4435      var size = 400;
4436
4437      var calc = () => slickAutoResponsive(slider, clientsPerSlide, size - (clientsPerSlide * 40), true);
4438      var calcScroll = calc;
4439      var slidesToScroll = slider.closest('.clients_slider').attr('data-sli
4439des-to-scroll') ? parseInt(slider.closest('.clients_slider').attr('data-slides-to-scroll')) : calc();
4440
4441      if( 1 === slidesToScroll ){
4442        calcScroll = () => slickAutoResponsive(slider, 1, size - (clientsPerSlide * 40), true);
4443      }
4444
4445      slider.slick({
4446        cssEase: 'ease-out',
4447        dots: false,
4448        infinite: true,
4449        touchThreshold: 10,
4450        speed: 300,
4451
4452        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4453        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4454        appendArrows: appendArrows,
4455
4456        rtl: rtl ? true : false,
4457        autoplay: mfn.slider.clients ? true : false,
4458        autoplaySpeed: mfn.slider.clients ? mfn.slider.clients : 5000,
4459
4460        slidesToShow: calc(),
4461        slidesToScroll: calcScroll()
4462      });
4463
4464      // ON | debouncedresize
4465
4466      $(window).on('debouncedresize', function() {
4467        slider.slick('slickSetOption', 'slidesToShow', calc(), false);
4468        slider.slick('slickSetOption', 'slidesToScroll', calcScroll(), true);
4469      });
4470
4471    });
4472  }
4473
4474  // Slider | Portfolio
4475
4476  function sliderPortfolio() {
4477
4478    $('.portfolio_slider_ul').each(function() {
4479
4480      var slider = $(this);
4481      var size = 380;
4482      var scroll = 5;
4483
4484      if (slider.closest('.portfolio_slider').data('size')) {
4485        size = slider.closest('.portfolio_slider').data('size');
4486      }
4487
4488      if (slider.closest('.portfolio_slider').data('size')) {
4489        scroll = slider.closest('.portfolio_slider').data('scroll');
4490      }
4491
4492      slider.slick({
4493        cssEase: 'ease-out',
4494        dots: false,
4495        infinite: true,
4496        touchThreshold: 10,
4497        speed: 300,
4498
4499        prevArrow: '<a class="slider_nav slider_prev themebg" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4500        nextArrow: '<a class="slider_nav slider_next themebg" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4501
4502        rtl: rtl ? true : false,
4503        autoplay: mfn.slider.portfolio ? true : false,
4504        autoplaySpeed: mfn.slider.portfolio ? mfn.slider.portfolio : 5000,
4505
4506        slidesToShow: slickAutoResponsive(slider, 5, size),
4507        slidesToScroll: slickAutoResponsive(slider, scroll, size)
4508      });
4509
4510      // ON | debouncedresize
4511      $(window).on('debouncedresize', function() {
4512        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, 5, size), false);
4513        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, scroll, size), true);
4514      });
4515
4516    });
4517  }
4518
4519  // header promo bar | Slider
4520
4521  function promoBarSlider() {
4522    $('.promo_bar_slider').each(function() {
4523      var $slider = $(this);
4524
4525      if ($slider.hasClass('mfn-initialized')) return;
4526      $slider.addClass('mfn-initialized');
4527
4528      var speedAttr = $slider.attr('data-speed');
4529      var speed = parseInt(speedAttr, 10);
4530      if (isNaN(speed) || speed <= 0) speed = 5;
4531      speed *= 1000;
4532
4533      var $slides = $slider.find('.pbs_one');
4534      if (!$slides.length) return;
4535
4536      $slides.removeClass('pbs-active pbs-active-ends');
4537      $slides.first().addClass('pbs-active');
4538
4539      var transitionDuration = 300;
4540
4541      function changeSlide() {
4542        var $current = $slider.find('.pbs_one.pbs-active');
4543        var $next = $current.next('.pbs_one');
4544
4545        if (!$next.length) $next = $slides.first();
4546
4547        $current.addClass('pbs-active-ends');
4548
4549        setTimeout(function() {
4550          $current.removeClass('pbs-active pbs-active-ends');
4551          $next.addClass('pbs-active');
4552        }, transitionDuration);
4553      }
4554
4555      if ($slides.length > 1) {
4556        setInterval(changeSlide, speed);
4557      }
4558    });
4559  }
4560
4561
4562
4563  // section slider
4564
4565  function queryLoopSlider() {
4566    $('body:not(.mfn-ui) .mfn-looped-items-slider').each(function(i) {
4567
4568      const swipers = [];
4569
4570      var $slider = $(this);
4571
4572      let swiperClass = 'mfn-ql-slider-'+i;
4573
4574      $slider.addClass(swiperClass);
4575
4576      var swiperParams = {
4577        spaceBetween: parseInt($slider.attr('data-space_mobile')),
4578        slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-mobile')),
4579      };
4580
4581      if( typeof $slider.attr('data-dots') !== 'undefined' && $slider.attr('data-dots') == '1' ) {
4582        $slider.parent().append('<div class="swiper-pagination mfn-swiper-pagination-'+i+'"></div>');
4583        swiperParams['pagination'] = {
4584          el: ".mfn-swiper-pagination-"+i,
4585          clickable: true,
4586        };
4587
4588        if( $slider.attr('data-dots-count') == 'dynamic' ) {
4589          swiperParams['pagination']['dynamicBullets'] = true;
4590        }
4591      }
4592
4593      if( $slider.closest('.mfn-looped-items').hasClass('mfn-ql-slider-wrapper-offset') && $slider.attr('data-infinity') == '1' ) {
4594        swiperParams['loop'] = true;
4595        swiperParams['centeredSlides'] = true;
4596        $slider.parent().css({ 'max-width': '100%'});
4597      }else if( $slider.attr('data-infinity') == '1' ) {
4598        swiperParams['loop'] = true;
4599      }
4600
4601      /*if( $slider.attr('data-pausehover') == '1' ) {
4602
4603      }*/
4604
4605      swiperParams['speed'] = parseFloat($slider.attr('data-speed'));
4606
4607      if( $slider.attr('data-arrows') == '1' ){
4608        $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>');
4609        swiperParams['navigation'] = {
4610          nextEl: ".mfn-swiper-button-next-"+i,
4611          prevEl: ".mfn-swiper-button-prev-"+i,
4612        };
4613      }
4614
4615      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-autoplay') !== 'undefined' && parseFloat($slider.attr('data-autoplay')) > 0 ) {
4616        swiperParams['autoplay'] = {
4617          delay: $slider.hasClass('mfn-slider-linear') ? 0.1 : parseFloat($slider.attr('data-autoplay')),
4618          disableOnInteraction: true,
4619        };
4620
4621        if( $slider.attr('data-pausehover') == '1' ){
4622          // swiperParams['autoplay']['disableOnInteraction'] = true;
4623          swiperParams['autoplay']['pauseOnMouseEnter'] = true;
4624        }else{
4625          // swiperParams['autoplay']['disableOnInteraction'] = false;
4626          swiperParams['autoplay']['pauseOnMouseEnter'] = false;
4627        }
4628      }
4629
4630      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-mousewheel') !== 'undefined' && $slider.attr('data-mousewheel') > 0 ) {
4631        swiperParams['mousewheel'] = true;
4632      }
4633
4634      if( $('body').hasClass('mfn-ui') ) {
4635        swiperParams['allowTouchMove'] = true;
4636      }
4637
4638      // popup fix
4639      if( $slider.closest('.mfn-popup-tmpl').length ){
4640        swiperParams['observer'] = true;
4641        swiperParams['observeParents'] = true;
4642      }
4643
4644      swiperParams['breakpoints'] = {
4645        768: {
4646          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4647          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-tablet'))
4648        },
4649        960: {
4650          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4651          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-laptop'))
4652        },
4653        1441: {
4654          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4655          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns'))
4656        }
4657      };
4658
4659      if( $slider.attr('data-animationtype') != 'slide' ) {
4660        swiperParams['effect'] = $slider.attr('data-animationtype');
4661        swiperParams['grabCursor'] = true;
4662
4663         if( $slider.attr('data-animationtype') == 'fade' ) {
4664          swiperParams['fadeEffect'] = { crossFade: true };
4665          swiperParams['centeredSlides'] = true;
4666         }
4667
4668      }
4669
4670      swipers[i] = new Swiper('.'+swiperClass, swiperParams);
4671
4672      swipers[i].on('slideChange', function () {
4673        $(window).trigger('scroll');
4674      });
4675
4676      if( ($slider.attr('data-animationtype') == 'cube' || $slider.attr('data-animationtype') == 'flip' || $slider.attr('data-animationtype') == 'cards' ) && $slider.closest('.mfn-looped-items-slider-wrapper').hasClass('mfn-arrows-standard') ) {
4677        let sw_arr_wi = $slider.closest('.mfn-looped-items-slider-wrapper').find('.mfn-swiper-arrow').outerWidth()+'px';
4678        $('body').append('<style>.mfn-ql-slider-'+i+'{ --mfn-swiper-arrow-width: '+sw_arr_wi+' }</style>')
4679        $(window).trigger('resize');
4680      }
4681
4682    });
4683  }
4684
4685  // Slider | Slider
4686
4687  function sliderSlider() {
4688
4689    var pager = function(el, i) {
4690      return '<a>' + i + '</a>';
4691    };
4692
4693    $('.content_slider_ul').each(function() {
4694
4695      var slider = $(this);
4696      var count = 1;
4697      var centerMode = false;
4698
4699      if (slider.closest('.content_slider').hasClass('carousel')) {
4700        count = slickAutoResponsive(slider);
4701
4702        $(window).on('debouncedresize', function() {
4703          slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider), false);
4704          slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider), true);
4705        });
4706      }
4707
4708      if (slider.closest('.content_slider').hasClass('center')) {
4709        centerMode = true;
4710      }
4711
4712      slider.slick({
4713        cssEase: 'cubic-bezier(.4,0,.2,1)',
4714        dots: true,
4715        infinite: true,
4716        touchThreshold: 10,
4717        speed: 300,
4718
4719        centerMode: centerMode,
4720        centerPadding: '20%',
4721
4722        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4723        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4724
4725        adaptiveHeight: true,
4726        appendDots: slider.siblings('.slider_pager'),
4727        customPaging: pager,
4728
4729        rtl: rtl ? true : false,
4730        autoplay: mfn.slider.slider ? true : false,
4731        autoplaySpeed: mfn.slider.slider ? mfn.slider.slider : 5000,
4732
4733        slidesToShow: count,
4734        slidesToScroll: count
4735      });
4736
4737      // Lightbox | disable on dragstart
4738
4739      var clickEvent = false;
4740
4741      slider.on('dragstart', '.slick-slide a[rel="lightbox"]', function(event) {
4742        if (lightboxAttr) {
4743          var events = $._data(this,'events');
4744          if( events && Object.prototype.hasOwnProperty.call(events, 'click') ){
4745            clickEvent = events.click[0];
4746            $(this).addClass('off-click').off('click');
4747          }
4748        }
4749      });
4750
4751      // Lightbox | enable after change
4752
4753      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
4754        if (lightboxAttr) {
4755          $('a.off-click[rel="lightbox"]', slider).removeClass('off-click').on('click', clickEvent);
4756        }
4757      });
4758
4759    });
4760  }
4761
4762  // Slider | Testimonials
4763
4764  function sliderTestimonials() {
4765
4766    var pager = function(el, i) {
4767      var img = $(el.$slides[i]).find('.single-photo-img').html();
4768      return '<a>' + img + '</a>';
4769    };
4770
4771    $('.testimonials_slider_ul').each(function() {
4772
4773      var slider = $(this);
4774
4775      slider.slick({
4776        cssEase: 'ease-out',
4777        dots: true,
4778        infinite: true,
4779        touchThreshold: 10,
4780        speed: 300,
4781
4782        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4783        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4784
4785        adaptiveHeight: true,
4786        appendDots: slider.siblings('.slider_pager'),
4787        customPaging: pager,
4788
4789        rtl: rtl ? true : false,
4790        autoplay: mfn.slider.testimonials ? true : false,
4791        autoplaySpeed: mfn.slider.testimonials ? mfn.slider.testimonials : 5000,
4792
4793        slidesToShow: 1,
4794        slidesToScroll: 1
4795      });
4796
4797    });
4798  }
4799
4800  /**
4801   *
4802   * Tabber
4803   *
4804   * */
4805
4806  let mfnTabber = {
4807    init: function() {
4808
4809      $(document).on('mouseover', '.mfn-tabber-open-on-hover .mfn-tabber-nav li a', function(e) {
4810
4811        if( !$(this).parent('li').hasClass('active') ) {
4812
4813          let tab = $(this).attr('data-tab');
4814
4815          $(this).parent('li').siblings('li').removeClass('active');
4816          $(this).closest('.mfn-section-tabber').find('.mfn-tabber-content.active').removeClass('active');
4817
4818          $(this).parent('li').addClass('active');
4819          $(this).closest('.mfn-section-tabber').find(tab).addClass('active');
4820
4821          $(document).trigger('mfn:tabber:open');
4822          $(window).trigger('resize');
4823
4824        }
4825
4826      }).on('click', '.mfn-tabber-nav li a', function(e) {
4827
4828        if( !$(this).parent('li').hasClass('active') ) {
4829          e.preventDefault();
4830          let tab = $(this).attr('data-tab');
4831
4832          $(this).parent('li').siblings('li').removeClass('active');
4833          $(this).closest('.mfn-section-tabber').find('.mfn-tabber-content.active').removeClass('active');
4834
4835          $(this).parent('li').addClass('active');
4836          $(this).closest('.mfn-section-tabber').find(tab).addClass('active');
4837
4838          $(document).trigger('mfn:tabber:open');
4839          $(window).trigger('resize');
4840
4841        }else if( $(this).attr('href') == '#' || $('body').hasClass('mfn-ui') ) {
4842          e.preventDefault();
4843        }
4844
4845      });
4846
4847
4848      if( $('body').hasClass('mfn-ui') ){
4849        setTimeout(mfnTabber.sliding_bg, 800); // must have
4850      }else{
4851        setTimeout(mfnTabber.sliding_bg, 300); // must have
4852      }
4853
4854
4855
4856    },
4857
4858    sliding_bg: function() {
4859
4860      if( !$('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding').length ) return;
4861
4862      $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding').each(function() {
4863        let wrapper = $(this);
4864        let li = wrapper.find('li.active');
4865        let helper = wrapper.find('.mfn-tabber-nav-slide-helper');
4866
4867        let offset_left = li.position().left;
4868        let offset_top = li.position().top;
4869
4870        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4871
4872      });
4873
4874      $('.mfn-tabber-open-on-click .mfn-tabber-nav.mfn-tabber-nav-hover-sliding li').on('click', function() {
4875        let li = $(this);
4876        let helper = li.closest('ul').find('.mfn-tabber-nav-slide-helper');
4877
4878        let offset_left = li.position().left;
4879        let offset_top = li.position().top;
4880
4881        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4882      });
4883
4884      $('.mfn-tabber-open-on-hover .mfn-tabber-nav.mfn-tabber-nav-hover-sliding li').on('mouseover', function() {
4885        let li = $(this);
4886        let helper = li.closest('ul').find('.mfn-tabber-nav-slide-helper');
4887
4888        let offset_left = li.position().left;
4889        let offset_top = li.position().top;
4890
4891        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4892      });
4893
4894      if( $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding li.active').length ){
4895
4896        $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding li.active')
4897
4898      }
4899
4900    }
4901
4902  }
4903
4904  /**
4905   *
4906   * Filters
4907   *
4908   * */
4909
4910  let mfnAdvancedFilters = {
4911    form: false,
4912    init: function() {
4913      if( !$('.mfn-advanced-filters').length ) return;
4914
4915      this.prepare();
4916
4917      $(document).on('click', '.mfn-advanced-filters .mfn-advanced-filters-expand', function(e) {
4918        e.preventDefault();
4919
4920        if( $(this).hasClass('mfn-expanded') ){
4921          $(this).removeClass('mfn-expanded');
4922          $(this).text($(this).attr('data-more'));
4923          $(this).closest('.mfn-form-row-wrapper').find('li.mfn-opt-expandable').addClass('mfn-opt-hidden').removeClass('mfn-opt-expandable');
4924        }else{
4925          $(this).addClass('mfn-expanded');
4926          $(this).text($(this).attr('data-less'));
4927          $(this).closest('.mfn-form-row-wrapper').find('li.mfn-opt-hidden').removeClass('mfn-opt-hidden').addClass('mfn-opt-expandable');
4928        }
4929      });
4930
4931      $(document).on('click', '.mfn-advanced-filters-accordion .mfn-advanced-filters-group-label', function(e) {
4932        e.preventDefault();
4933        let row = $(this).closest('.mfn-form-row');
4934        if( row.hasClass('open') ){
4935          row.removeClass('open');
4936          $(this).siblings('.mfn-form-row-wrapper').slideUp(300);
4937        }else{
4938          row.addClass('open');
4939          $(this).siblings('.mfn-form-row-wrapper').slideDown(300);
4940        }
4941
4942      })
4943
4944      if( $('.mfn-advanced-filters .mfn-advanced-filters-rate') ){
4945        $(document).on('click', '.mfn-advanced-filters .mfn-advanced-filters-rate li', function() {
4946          $(this).toggleClass('active');
4947
4948          let helper_arr = [];
4949
4950          $(this).closest('.mfn-advanced-filters-rate').find('li.active').each(function(el) {
4951            helper_arr.push($(this).attr('data-rate'));
4952          });
4953
4954          $(this).closest('.mfn-advanced-filters-rate').find('.mfn-advanced-rate-input').val(helper_arr.join(',')).trigger('change');
4955
4956        });
4957      }
4958
4959      $(document).on('change', 'form.mfn-active-filters input', function(e) {
4960        mfnAdvancedFilters.ajax($(this).closest('form'));
4961      });
4962
4963      $(document).on('change', 'form.mfn-advanced-filters-auto-submit input, form.mfn-advanced-filters-auto-submit select', function(e) {
4964        mfnAdvancedFilters.ajax($(this).closest('form'));
4965      }).on('submit', 'form.mfn-advanced-filters-auto-submit', function(e) {
4966        e.preventDefault();
4967        mfnAdvancedFilters.ajax($(this));
4968      });
4969
4970      $(document).on('submit', 'form.mfn-advanced-filters-ajax-submit', function(e) {
4971        e.preventDefault();
4972        mfnAdvancedFilters.ajax($(this));
4973      });
4974
4975      $(document).on('click', '.mfn-active-filters .mfn-reset-filters', function(e) {
4976        e.preventDefault();
4977        $(this).closest('form').empty();
4978        mfnAdvancedFilters.ajax($(this).closest('form'));
4979      });
4980
4981    },
4982
4983    prepare: function() {
4984
4985      if( $('.mfn-active-filters .mfn-active-filters-find-title').length ) {
4986        $('.mfn-active-filters .mfn-active-filters-find-title:not(.initialized)').each(function(i, el) {
4987
4988          $(el).addClass('initialized');
4989
4990          let selector = '[name="'+$(el).find('input').attr('name')+'"]';
4991          let searched_input = $('.mfn-advanced-filters '+selector);
4992          if( $(el).find('input').val().length ) {
4993
4994            let label = searched_input.closest('.mfn-form-row').find('.mfn-advanced-filters-label-name').length ? searched_input.closest('.mfn-form-row').find('.mfn-advanced-filters-label-name').first().text() : '';
4995
4996            if( typeof searched_input.attr('placeholder') != 'undefined' && searched_input.closest('.mfn-floating-placeholder').length ) {
4997              if( label.length ) $(el).append(label+' ');
4998              $(el).append(searched_input.attr('placeholder')+': '+$(el).find('input').val());
4999            }else if( searched_input.hasClass('mfn-advanced-rate-input') && label.length ) {
5000              if( label.length ) $(el).append(label+': ');
5001              $(el).append($(el).find('input').val());
5002            }else{
5003              $(el).append(searched_input.closest('.mfn-form-row').find('.mfn-advanced-filters-group-label h4').first().text()+': '+$(el).find('input').val());
5004            }
5005
5006          }else{
5007            $(el).remove();
5008          }
5009        });
5010      }
5011
5012      $('.mfn-advanced-filters:not(.initialized)').each(function(i, el) {
5013        mfnAdvancedFilters.form = $(el);
5014        mfnAdvancedFilters.form.addClass('initialized');
5015
5016        if( mfnAdvancedFilters.form.find('.mfn-advanced-filters-slider').length ){
5017          mfnAdvancedFilters.slider();
5018        }
5019
5020        if( mfnAdvancedFilters.form.find('.mfn-advanced-filters-range-slider').length ){
5021          mfnAdvancedFilters.slider_range();
5022        }
5023      });
5024    },
5025
5026    ajax: ($form) => {
5027
5028      var url    = $form.attr('action') || location.origin + location.pathname;
5029      var method = ($form.attr('method') || 'GET').toUpperCase();
5030      var data   = $form.serialize();
5031
5032      if( $form.closest('.mfn-sidemenu-tmpl.mfn-sidemenu-active').length ) {
5033        $form.closest('.mfn-sidemenu-tmpl.mfn-sidemenu-active').find('.mfn-sidemenu-closebutton').trigger('click');
5034      }
5035
5036      // UX: spinner/wyłączenie pól (opcjonalnie)
5037      var $content = $('#Content');
5038      $content.addClass('is-loading'); // zrób w CSS np. półprzezroczystość
5039      $form.find('input,select,button').prop('disabled', true);
5040      $form.find('button.mfn-btn').addClass('loading disabled');
5041
5042      if( $('.mfn-archive-product-tmpl-builder .mfn-woo-list-perpage li.active input').length && $('.mfn-archive-product-tmpl-builder .mfn-woo-list-perpage li.active input').val().length ) data += '&per_page='+$('.mfn-archive-product-tmpl-builder .mfn-woo-list-perpage li.active input').val();
5043      if( $('.mfn-archive-product-tmpl-builder .woocommerce-ordering select').length && $('.mfn-archive-product-tmpl-builder .woocommerce-ordering select').val().length ) data += '&orderby='+$('.mfn-archive-product-tmpl-builder .woocommerce-ordering select').val();
5044      if( $('.mfn-archive-product-tmpl-builder .mfn-woo-list-style li.active input').length && $('.mfn-archive-product-tmpl-builder .mfn-woo-list-style li.active input').val().length ) data += '&layout='+$('.mfn-archive-product-tmpl-builder .mfn-woo-list-style li.active input').val();
5045
5046      $.ajax({
5047        url: url,
5048        type: method,
5049        data: data,
5050        dataType: 'html'
5051      }).done(function(html){
5052        var $html  = $('<div>').append($.parseHTML(html));
5053        var $newContent = $html.find('#Content');
5054
5055        if ($newContent.length) {
5056          $content.replaceWith($newContent);
5057
5058          if( $('.mfn-sidemenu-tmpl').length ) {
5059            $('.mfn-sidemenu-tmpl').each(function() {
5060              let id = $(this).attr('id');
5061              $(this).replaceWith($html.find('#'+id));
5062            });
5063          }
5064
5065          if (method === 'GET') {
5066            var newUrl = url + (url.indexOf('?')>-1 ? '&' : '?') + data;
5067            window.history.replaceState({}, '', newUrl);
5068          }
5069        } else {
5070          window.location.href = method==='GET' ? (url + (url.indexOf('?')>-1?'&':'?') + data) : url;
5071        }
5072      }).fail(function(){
5073        window.location.href = method==='GET' ? (url + (url.indexOf('?')>-1?'&':'?') + data) : url;
5074      }).always(function(){
5075        $form.find('input,select,button').prop('disabled', false);
5076        $('#Content').removeClass('is-loading');
5077        $form.find('button.mfn-btn').removeClass('loading disabled');
5078
5079        $(document).trigger('mfn:ajax:refresh');
5080      });
5081    },
5082
5083    slider: function() {
5084      mfnAdvancedFilters.form.find('.mfn-advanced-filters-slider').each(function(i, slider) {
5085
5086        let input = $(this).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input');
5087
5088        let min = input.attr('min').length ? input.attr('min') : '0';
5089        let max = input.attr('max').length ? input.attr('max') : '500';
5090
5091        let val = input.val().length ? input.val() : '';
5092
5093        $(this).slider({
5094          step: 1,
5095          min: parseFloat(min),
5096          max: parseFloat(max),
5097          range: "min",
5098          value: val,
5099          create: function () {
5100            $(this).find(".ui-slider-handle").append('<span class="mfn-ui-tip"></span>');
5101            $(this).find(".mfn-ui-tip").text($(this).slider("value"));
5102          },
5103          slide: function( event, ui ) {
5104            input.val(ui.value);
5105            if( !input.parent('.mfn-input-wrapper').hasClass('mfn-not-empty') ) input.parent('.mfn-input-wrapper').addClass('mfn-not-empty');
5106            $(this).find(".mfn-ui-tip").text(ui.value);
5107          },
5108          stop: function() {
5109            input.trigger('change');
5110          }
5111        });
5112
5113      });
5114    },
5115
5116    slider_range: function() {
5117      mfnAdvancedFilters.form.find('.mfn-advanced-filters-range-slider').each(function(i, slider) {
5118
5119        let input_min = $(this).closest('.mfn-advanced-filters-slider-wrapper').find('input.mfn-ui-slider-input-min');
5120        let input_max = $(this).closest('.mfn-advanced-filters-slider-wrapper').find('input.mfn-ui-slider-input-max');
5121
5122        let min = typeof input_min.attr('min') != 'undefined' ? input_min.attr('min') : '0';
5123        let max = typeof input_max.attr('max') != 'undefined' ? input_max.attr('max') : '500';
5124
5125        let val_min = input_min.val().length ? input_min.val() : min;
5126        let val_max = input_max.val().length ? input_max.val() : max;
5127
5128        $(this).slider({
5129          range: true,
5130          step: 1,
5131          min: parseFloat(min),
5132          max: parseFloat(max),
5133          values: [ parseFloat(val_min), parseFloat(val_max) ],
5134          create: function (event, ui) {
5135            $(this).find(".ui-slider-handle").append('<span class="mfn-ui-tip"></span>');
5136            $(this).find(".mfn-ui-tip").first().text(val_min);
5137            $(this).find(".mfn-ui-tip").last().text(val_max);
5138          },
5139          slide: function( event, ui ) {
5140            $(ui.handle).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input-min').val(ui.values[ 0 ]);
5141            $(ui.handle).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input-max').val(ui.values[ 1 ]);
5142
5143            if( !$(ui.handle).closest('.mfn-form-row-wrapper').find('.mfn-input-wrapper').hasClass('mfn-not-empty') ) $(ui.handle).closest('.mfn-form-row-wrapper').find('.mfn-input-wrapper').addClass('mfn-not-empty');
5144
5145            $(ui.handle).find(".mfn-ui-tip").text(ui.value);
5146          },
5147          stop: function() {
5148            input_min.trigger('change');
5149          }
5150        });
5151
5152      });
5153    }
5154  }
5155
5156  /**
5157   * GDPR
5158   */
5159
5160  // GDPR | Close notice on click | BIND
5161
5162  $(document).on('click', '.mfn-gdpr-button', function(){
5163    var closeAnimation = $('.mfn-gdpr-button').attr('data-animation');
5164    var barAligment = $('#mfn-gdpr').attr('data-aligment');
5165
5166    switch(true){
5167      case 'none' === closeAnimation:
5168        $('#mfn-gdpr').css('display', 'none');
5169        break;
5170      case 'fade' === closeAnimation:
5171        $('#mfn-gdpr').fadeOut(300);
5172        break;
5173      case 'slide' === closeAnimation && 'top' === barAligment:
5174        $('#mfn-gdpr').slideUp(300);
5175        break;
5176      default:
5177        $('#mfn-gdpr').slideToggle(300);
5178        break;
5179    }
5180
5181    // wait for animation end, then remove clasa and set cookies
5182    setTimeout(function(){
5183      $('#mfn-gdpr').removeClass('show');
5184      gdpr_set_cookie();
5185    }, 300);
5186  });
5187
5188  // GDPR | Set the cookie
5189
5190  function gdpr_set_cookie(){
5191    if(navigator.cookieEnabled) {
5192      var cookieDays = $('.mfn-gdpr-button').attr('data-cookiedays') || 365;
5193      var cookieDate = new Date();
5194      var cookieText = '';
5195
5196      cookieDate.setTime(cookieDate.getTime() + (cookieDays * 24 * 60 * 60 * 1000));
5197      cookieText += "mfn-gdpr=1";
5198      cookieText += "; expires=" + cookieDate.toUTCString() + ';';
5199      cookieText += "; path=" + mfn.home_url + '/';
5200
5201      document.cookie = cookieText;
5202    }
5203  }
5204
5205  // GDPR | Display, if cookie not accepted
5206
5207  function gdpr(){
5208    if (document.cookie !== "") {
5209      var cookies = document.cookie.split(/; */);
5210
5211      for (var cookie of cookies) {
5212        var [ cookieName ] = cookie.split("=");
5213
5214        if (cookieName === 'mfn-gdpr') {
5215          return; // cookie exists
5216        }
5217      }
5218    }
5219
5220    $('#mfn-gdpr').addClass('show'); //cookie does NOT exist
5221  }
5222
5223  /*
5224   * Infinite scroll functionality
5225   */
5226
5227  function infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection){
5228
5229    // for proper check, if we need to fetch posts again.
5230    var screenHeight = document.body.clientHeight;
5231
5232    if ( infiniteLoadContainer.attr('data-attr') === $(infiniteLoadButton).attr('href') ) {
5233      return; // it means, that maximum length of pages is crossed
5234    } else if (scrollDirection === 'down') {
5235
5236      // attach link for check, and click the load more button!
5237      infiniteLoadContainer.attr('data-attr', $(infiniteLoadButton).attr('href'));
5238      infiniteLoadButton.click();
5239
5240      // prevention, when height did not change enought, load again
5241      setTimeout(function(){
5242        var heightAfterLoadDifference = (document.body.clientHeight - screenHeight);
5243
5244        if( heightAfterLoadDifference < 249 ) {
5245          infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection);
5246        }
5247      }, 500);
5248
5249    }
5250  }
5251
5252/*  function infiniteScrollPortfolio(){
5253    var infiniteLoadContainer = $('.mfn-infinite-load-button');
5254    var infiniteLoadButton = $('.mfn-infinite-load-button a');
5255
5256    $(infiniteLoadContainer).waypoint({
5257      handler: function(direction) {
5258        infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, direction);
5259      },
5260      offset: function(){
5261        //after each load, calc the offset of element to know when posts should be loaded
5262        var offsetPosition = - ( ($(this)[0].element.scrollHeight) - (window.innerHeight / 1.2) );
5263        return offsetPosition;
5264      }
5265    });
5266
5267
5268  } */
5269
5270  /*
5271   * Table of Contents | toc
5272   */
5273
5274  $('body').on('click', ".table_of_content .toggle", function(e){
5275
5276    e.preventDefault();
5277
5278    if( $('.table_of_content').hasClass('hide') ){
5279
5280      $('.table_of_content').removeClass('hide');
5281
5282      $('.table_of_content_wrapper').slideDown( {
5283        duration: 400,
5284        always: function(){
5285          $('.table_of_content').removeClass('hide_on_start');
5286        }
5287      });
5288
5289    } else {
5290
5291      $('.table_of_content_wrapper').slideUp( {
5292        duration: 400
5293      });
5294
5295      $('.table_of_content').addClass('hide');
5296
5297    }
5298
5299  });
5300
5301  function tableContentAttachId(){
5302    const container = $('.table_of_content');
5303    let tags;
5304    let anchorNumber = 0;
5305    let anchorDom = $('.table_of_content_wrapper').find('a');
5306
5307
5308    if(tags = container.attr('data-tags')){
5309      tags = tags.split(/[ ,]+/).join(','); //remove spaces, add commas
5310
5311      // muffin builder, gutenberg, elementor
5312      let columns = $('#Content .mfn-builder-content .column_column, #Content .mfn-builder-content .column_post_content, #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)');
5313
5314      if( $('#Content .mfn-single-post-tmpl-builder .column_post_content').length ){
5315        columns = $('#Content .mfn-single-post-tmpl-builder .column_post_content .column_column, #Content .mfn-single-post-tmpl-builder .column_post_content, #Content .mfn-single-post-tmpl-builder .column_post_content .column_heading, #Content .mfn-single-post-tmpl-builder .column_post_content .column_fancy_heading, .the_content_wrapper:not(.is-elementor), .elementor-widget:not(.elementor-widget-mfn_table_of_contents)');
5316      }else if( $('#Content .mfn-single-portfolio-tmpl-builder .column_post_content').length ){
5317        columns = $('#Content .mfn-single-portfolio-tmpl-builder .column_post_content .column_column, #Content .mfn-single-portfolio-tmpl-builder .column_post_content, #Content .mfn-single-portfolio-tmpl-builder .column_post_content .column_heading, #Content .mfn-single-portfolio-tmpl-builder .column_post_content .column_fancy_heading, .the_content_wrapper:not(.is-elementor), .elementor-widget:not(.elementor-widget-mfn_table_of_contents)');
5318      }
5319
5320
5321      $(columns).each( ( index, element ) => {
5322        let headingsNoticed = $(element).find(tags); //look for headings
5323
5324        $(headingsNoticed).each( ( index, element ) => {
5325
5326          if( $(element).attr('id') ) { //replace toc_X with user assigned ID
5327
5328            const idSet = '#'+$(element).attr('id');
5329            $(anchorDom[anchorNumber]).attr('href', idSet );
5330
5331          }else{
5332
5333            let id = $(anchorDom[anchorNumber]).attr('href');
5334            if(typeof id !== 'undefined') $(element).attr('id', id.substr(1) );
5335
5336          }
5337
5338          anchorNumber++;
5339        })
5340
5341      })
5342
5343    }
5344  }
5345
5346  /**
5347   * Off-canvas sidebar
5348   */
5349
5350  var offCanvasSidebar = {
5351    init: function() {
5352      $(document).on('click', '.mfn-off-canvas-switcher', function(e) {
5353        e.preventDefault();
5354        if( $('html').hasClass('mfn-ofcs-opened') ){
5355          $('html').removeClass('mfn-ofcs-opened');
5356        }else{
5357          $('html').addClass('mfn-ofcs-opened');
5358        }
5359      });
5360    },
5361    mobile: function() {
5362      if( $('.sidebar .widget-area').length && $('body').hasClass('ofcs-mobile') ){
5363
5364        if( !$('.mfn-off-canvas-sidebar').length ){
5365          $('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>');
5366        }
5367
5368        if( $('body').hasClass('woocommerce-shop') && !$('.mfn-woo-filters-wrapper .mfn-off-canvas-switcher').length ){
5369          $('.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>
5369.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>');
5370        }
5371
5372        var $ofcs = $('.mfn-off-canvas-sidebar .mfn-off-canvas-content-wrapper .mfn-off-canvas-content');
5373        $ofcs.empty();
5374
5375        $('.sidebar .widget-area').each(function() {
5376          //var $sdbr = $(this).clone(true);
5377          $ofcs.append( $(this) );
5378          //$(this).hide();
5379        });
5380
5381        offCanvasSidebar.init();
5382
5383      }
5384    }
5385  }
5386
5387  function alignHeights(){
5388    var i = 0;
5389    if( !$('.mfn-align-heights').length ) return;
5390    $('.mfn-align-heights').each(function() {
5391      var max=0;
5392      var newclass = 'mfn-align-cont-'+i;
5393      $(this).addClass(newclass);
5394      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: auto;} </style>").appendTo("body");
5395      $("."+newclass+" .mfn-align-me").each(function() {
5396        if($(this).outerHeight() > max){max = $(this).outerHeight();}
5397      });
5398      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: "+max+"px;} </style>").appendTo("body");
5399      i++;
5400    });
5401  }
5402
5403  $(window).on('debouncedresize', alignHeights);
5404
5405  var headerMegamenu = {
5406    init: function() {
5407
5408      if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children').length ){
5409        $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children > a').on('click', function(e) {
5410          let href = $(this).attr('href');
5411          if( !$(this).parent('li').hasClass('mfn-li-childrens-show') ){
5412            e.preventDefault();
5413            e.stopPropagation();
5414            $(this).siblings('ul').slideDown(300);
5415            $(this).parent('li').addClass('mfn-li-childrens-show');
5416          }else if( href == '' || href == '#' ){
5417            e.preventDefault();
5418            e.stopPropagation();
5419            $(this).siblings('ul').slideUp(300);
5420            $(this).parent('li').removeClass('mfn-li-childrens-show');
5421          }
5422        });
5423      }
5424
5425      /**
5426       * Submenu in mega menu
5427       * */
5428
5429      if( $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li').length ){
5430        $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li > a').on('click', function(e) {
5431          if( $(this).closest('li').hasClass('menu-item-has-children') && !$(this).closest('li').hasClass('mfn-li-hover') ){
5432            e.preventDefault();
5433            e.stopPropagation();
5434            $(this).closest('li').addClass('mfn-li-hover');
5435          }
5436        });
5437      }
5438
5439      if( $('ul.mfn-menu-submenu-on-hover li.mfn-menu-item-has-megamenu, li.mfn-theme-options-menu.mfn-menu-item-has-megamenu').length ){
5440        $('ul.mfn-menu-submenu-on-hover li.mfn-menu-item-has-megamenu, li.mfn-theme-options-menu.mfn-menu-item-has-megamenu').on('mouseenter mousemove', function() {
5441          if( $(this).find('.mfn-megamenu-full-width').length || $(this).find('.mfn-megamenu-grid').length ){
5442            headerMegamenu.setLeft($(this));
5443          }
5444        });
5445      }
5446
5447      if( $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu').length ){
5448
5449        $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu > a.mfn-menu-link').on('click', function(e) {
5450          let href = $(this).attr('href');
5451
5452          if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ){
5453            headerMegamenu.setLeft($(this).closest('li'));
5454          }
5455
5456          if( href == '' || href == '#' ){
5457            e.preventDefault();
5458            e.stopPropagation();
5459            if( $(this).closest('li').hasClass('mfn-li-hover') ) {
5460              $(this).closest('li').removeClass('mfn-li-hover');
5461              $(document).unbind('click', headerTemplate.bindUnclick);
5462              $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5463            }else{
5464              $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu.mfn-li-hover').removeClass('mfn-li-hover');
5465              $(this).closest('li').addClass('mfn-li-hover');
5466              $(document).bind('click', headerTemplate.bindUnclick);
5467              headerTemplate.animContentAddClass();
5468            }
5469          }else if( !$(this).closest('li').hasClass('mfn-li-hover') ) {
5470            e.preventDefault();
5471            e.stopPropagation();
5472            if( !$(this).closest('li.mfn-li-hover').length ) {
5473              $('.mfn-header-tmpl ul li.mfn-li-hover').removeClass('mfn-li-hover');
5474            }else if($(this).closest('li.mfn-li-hover').find('li.mfn-li-hover').length){
5475              $(this).closest('li.mfn-li-hover').find('li.mfn-li-hover').removeClass('mfn-li-hover');
5476            }
5477            if( !$(this).closest('.mfn-megamenu-menu').length && !$(this).closest('li.mfn-li-hover').length ) {
5478              if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').length ){
5479                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show ul').slideUp();
5480                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').removeClass('mfn-li-childrens-show');
5481              }
5482            }
5483            headerTemplate.animContentAddClass();
5484            $(this).parent('li').addClass('mfn-li-hover');
5485            $(document).bind('click', headerTemplate.bindUnclick);
5486          }
5487
5488          headerMegamenu.afterShow();
5489
5490        });
5491
5492      }
5493
5494    },
5495
5496    afterShow: function() {
5497      bannerBox.init();
5498      $(window).trigger('resize');
5499    },
5500
5501    setLeft: function($li) {
5502      var $mm = $li.find('.mfn-menu-item-megamenu');
5503      var left = $li.offset().left;
5504      $mm.css('width', $(window).width()+'px');
5505      $mm.css('left', '-'+left+'px');
5506      $mm.addClass('mfn-mm-grid-set');
5507    }
5508  }
5509
5510  var footerTemplate = {
5511    init: function() {
5512      if( $('body').hasClass('mfn-footer-stick') ){
5513        footerTemplate.isSticky();
5514      }
5515      if( $('body').hasClass('mfn-footer-sliding') || $('body').hasClass('mfn-footer-fixed') ){
5516        setTimeout(footerTemplate.isSliding(), 300);
5517      }
5518      return;
5519    },
5520    isSticky: function() {
5521      var offsetTop = $('.mfn-footer-tmpl').offset().top + $('.mfn-footer-tmpl').outerHeight();
5522      if( offsetTop < $(window).height() ){
5523        $('.mfn-footer-tmpl').addClass('is-sticky');
5524      }else{
5525        $('.mfn-footer-tmpl').removeClass('is-sticky');
5526      }
5527    },
5528    isSliding: function() {
5529      var footer = $('.mfn-footer-tmpl').outerHeight();
5530      $('#Content').css('margin-bottom', footer);
5531    }
5532  }
5533
5534  var bannerBox = {
5535    init: function(){
5536      // bannerBox.init()
5537      setTimeout( bannerBox.set, 300 );
5538    },
5539
5540    set: function() {
5541
5542      if( $('body').hasClass('mfn-ui') ) return;
5543
5544      if( !$('.column_banner_box .hidden-desc').length ) return;
5545
5546      if( $(".mfn-banner-box .last-visible-el").length ) {
5547          $(".mfn-banner-box .last-visible-el").removeClass('last-visible-el');
5548          $('.hidden-wrapper .hidden-desc').removeAttr('style');
5549      }
5550
5551      $( ".mfn-banner-box").each(function() {
5552
5553          if( $(this).find('.hidden-desc').length ) {
5554            if( $(this).find('.hidden-desc').prev().length ) $(this).find('.hidden-desc').prev().addClass("last-visible-el");
5555
5556            var hd_h = $(this).find('.hidden-wrapper').outerHeight();
5557            $(this).find('.hidden-desc').css( { '--mfn-banner-box-height': hd_h + 'px' } );
5558          }
5559
5560      });
5561
5562    }
5563
5564  };
5565
5566
5567  var mfn_hotspot = {
5568    init: function() {
5569
5570      if( $(window).width() >= 960 ){
5571        mfn_hotspot.hover();
5572      }else{
5573        mfn_hotspot.click();
5574      }
5575
5576    },
5577
5578    hover: function(e) {
5579      $('.mfn-image-hotspot .hotspot-point').on('mouseenter', function() {
5580        $(this).addClass('is-active');
5581      }).on('mouseleave', function() {
5582        $(this).removeClass('is-active');
5583      });
5584
5585      $('.mfn-image-hotspot').on('mouseleave', function() {
5586        $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5587      });
5588
5589    },
5590
5591    click: function() {
5592      $('.mfn-image-hotspot .hotspot-point').on('click', function() {
5593        if( $('.mfn-image-hotspot .hotspot-point.is-active').length ) $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5594        $(this).addClass('is-active');
5595        $(document).bind('click', mfn_hotspot.bindUnclick);
5596      })
5597    },
5598
5599    bindUnclick: function(e) {
5600      if (!$('.mfn-image-hotspot .hotspot-point').is(e.target) && $('.mfn-image-hotspot .hotspot-point').has(e.target).length === 0) {
5601        if( $('.mfn-image-hotspot .hotspot-point.is-active').length ) $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5602        $(document).unbind('click', mfn_hotspot.bindUnclick);
5603      }
5604    }
5605  };
5606
5607
5608  var headerTemplate = {
5609    hasSticky: false,
5610    isMobile: false,
5611    offsetScroll: 60,
5612    hasBodyOffset: false,
5613    height: 0,
5614    type: 'default',
5615    animContentOnHover: function() {
5616
5617      if( $('.mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu').hasClass('mfn-menu-submenu-on-hover') ){
5618        $('.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 mousemove', function() {
5619          headerTemplate.animContentAddClass();
5620        }).on('mouseenter', function() {
5621          $(window).trigger('resize');
5622        });
5623      }
5624
5625      $('.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() {
5626        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5627      });
5628
5629    },
5630    animContentAddClass: function() {
5631      if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-blur') ) {
5632        $('body').addClass('mfn-content-blur');
5633      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-gray') ) {
5634        $('body').addClass('mfn-content-gray');
5635      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-overlay') ) {
5636        $('body').addClass('mfn-content-overlay');
5637      }
5638    },
5639    openOnClick: function() {
5640
5641      // common
5642      $(document).on('click', '.mfn-header-tmpl .mfn-header-menu.mfn-menu-submenu-on-click li.menu-item-has-children > a.mfn-menu-link', function(e) {
5643        let href = $(this).attr('href');
5644
5645        if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ) {
5646          headerMegamenu.setLeft($(this).closest('li'));
5647        }
5648
5649        if( href == '' || href == '#' ){
5650          e.preventDefault();
5651          e.stopPropagation();
5652          if( $(this).closest('li').hasClass('mfn-li-hover') ) {
5653            $(this).closest('li').removeClass('mfn-li-hover');
5654            $(document).unbind('click', headerTemplate.bindUnclick);
5655            $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5656          }else{
5657            $(this).closest('li').siblings('li').removeClass('mfn-li-hover');
5658            $(this).closest('li').addClass('mfn-li-hover');
5659            $(document).bind('click', headerTemplate.bindUnclick);
5660            headerTemplate.animContentAddClass();
5661          }
5662        }else if( !$(this).closest('li').hasClass('mfn-li-hover') ){
5663          e.preventDefault();
5664          e.stopPropagation();
5665          $(this).closest('li').siblings('li').removeClass('mfn-li-hover');
5666          headerTemplate.animContentAddClass();
5667          $(this).parent('li').addClass('mfn-li-hover');
5668          $(document).bind('click', headerTemplate.bindUnclick);
5669        }
5670
5671
5672        $(window).trigger('resize')
5673      });
5674
5675    },
5676    bindUnclick: function(e) {
5677      var $li = $('.mfn-header-tmpl ul li.mfn-li-hover');
5678      if (!$li.is(e.target) && !$li.find(e.target).length ) {
5679        $li.removeClass('mfn-li-hover');
5680        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5681        $(document).unbind('click', headerTemplate.bindUnclick);
5682      }
5683    },
5684    closeable: function() {
5685      // common
5686
5687      if( $('body').hasClass('mfn-ui') ) return;
5688
5689      $('.mfn-header-tmpl .close-closeable-section').on('click', function() {
5690        var $section = $(this).closest('.mcb-section');
5691        $section.addClass('closeable-hidden').slideUp(300, function() {
5692          headerTemplate.resetOffset();
5693          headerTemplate.offset();
5694        });
5695
5696        if( typeof $section.attr('data-close-days') !== 'undefined' && $section.attr('data-close-days') != '0' ){
5697          var days = $section.attr('data-close-days');
5698          var uid = $section.attr('data-uid');
5699          var date=new Date();
5700          date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
5701          var expires="; expires="+date.toGMTString();
5702          document.cookie="mfn_closed_section_"+uid+"=1"+expires+"; path=/"
5703        }
5704
5705      });
5706    },
5707    resetOffset: function() {
5708      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
5709        $('#Wrapper').css({ 'padding-top': $('.mfn-header-tmpl').outerHeight() });
5710      }
5711    },
5712
5713    detectHover: function() {
5714      $('.mfn-header-tmpl .mfn-menu-submenu-on-hover .mfn-menu-item-has-megamenu.mfn-menu-li').on('mouseenter', function() {
5715        headerMegamenu.afterShow();
5716      });
5717
5718    },
5719
5720    offset: function() {
5721      if( headerTemplate.hasSticky && !headerTemplate.isMobile ) return;
5722      headerTemplate.offsetScroll = 0;
5723      var _screen = 'default';
5724      if( headerTemplate.isMobile ) _screen = 'header-mobile';
5725      $('.mfn-header-tmpl .mfn-'+_screen+'-section.hide-on-scroll:not(.closeable-hidden)').each(function() {
5726          headerTemplate.offsetScroll += $(this).outerHeight();
5727      });
5728    },
5729    init: function() {
5730      headerTemplate.hasBodyOffset = false;
5731
5732      if( !$('body').hasClass('mfn-ui') && $('.mfn-header-tmpl').find('.section.closeable-active').length ) {
5733        $('.mfn-header-tmpl').find('.section.closeable-active').each(function() {
5734          if( headerTemplate.readcookie( 'mfn_closed_section_'+$(this).attr('data-uid') ) || headerTemplate.readcookie( 'mfn_closed_section' ) == $(this).attr('data-uid') ) {
5735            $(this).remove();
5736          }else{
5737            $(this).removeClass('mfn-temporary-hidden');
5738          }
5739        });
5740      }
5741
5742      if( $(window).width() < 767 && $('.mfn-header-tmpl').hasClass('mfn-hasMobile') ){
5743        headerTemplate.isMobile = true;
5744        headerTemplate.type = $('.mfn-header-tmpl').attr('data-mobile-type');
5745        if( $('.mfn-header-tmpl').hasClass('mfn-mobile-header-body-offset') ) {
5746          headerTemplate.hasBodyOffset = true;
5747        }else{
5748          headerTemplate.hasBodyOffset = false;
5749        }
5750      }else{
5751        headerTemplate.isMobile = false;
5752        headerTemplate.type = $('.mfn-header-tmpl').attr('data-type');
5753        if( $('.mfn-header-tmpl').hasClass('mfn-header-body-offset') ) {
5754          headerTemplate.hasBodyOffset = true;
5755        }else{
5756          headerTemplate.hasBodyOffset = false;
5757        }
5758      }
5759
5760      // init submenu show on click
5761      if( $('.mfn-header-tmpl .mfn-menu-submenu-on-click:not(.initialized)').length ) {
5762        $('.mfn-header-tmpl .mfn-menu-submenu-on-click').addClass('initialized');
5763        headerTemplate.openOnClick();
5764      }
5765
5766      if( $('.mfn-header-tmpl .mfn-menu-submenu-on-hover .mfn-menu-item-has-megamenu.mfn-menu-li').length ) {
5767        headerTemplate.detectHover();
5768      }
5769
5770      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') ){
5771        headerTemplate.animContentOnHover();
5772      }
5773
5774      if( $('.mfn-header-tmpl').hasClass('mfn-hasSticky') ) {
5775        headerTemplate.hasSticky = true;
5776      }else{
5777        headerTemplate.hasSticky = false;
5778      }
5779
5780      if( $('body style.tmp-mfn-header-template').length ) $('body style.tmp-mfn-header-template').remove();
5781
5782      if( $('.mfn-header-tmpl .close-closeable-section').length ) headerTemplate.closeable();
5783
5784      if( $('body').hasClass('mfn-header-scrolled') && !$('.mfn-builder-active').length ) $('body').removeClass('mfn-header-scrolled');
5785
5786      headerTemplate.getHeight();
5787      headerTemplate.offset();
5788
5789      headerTemplate.scroll();
5790
5791      if( $(window).scrollTop() > 10 ){
5792        $(window).trigger('scroll');
5793      }
5794
5795      if( $('#wpadminbar').length ) {
5796        let admin_bar_h = $('#wpadminbar').outerHeight();
5797        if($('.mfn-header-tmpl.mfn-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5798        if($(window).width() < 767 && $('.mfn-header-tmpl.mfn-mobile-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-mobile-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5799
5800      }
5801
5802    },
5803    scroll: function() {
5804
5805      // relative header prevent skip with sticky
5806      if( $('.mfn-header-tmpl').hasClass('mfn-header-tmpl-default') && headerTemplate.hasSticky && !headerTemplate.isMobile ) {
5807        $('body').append('<style class="tmp-mfn-header-template">html body.mfn-header-scrolled{padding-top: '+headerTemplate.height+'px;}</style>');
5808      }
5809
5810      // console.log('header scroll / '+headerTemplate.offsetScroll);
5811
5812      $(window).scroll(function() {
5813        var scrolled = $(this).scrollTop();
5814        var scroll_offset = headerTemplate.offsetScroll;
5815        if( headerTemplate.hasSticky && !headerTemplate.isMobile ) scroll_offset = headerTemplate.height;
5816
5817        if(scrolled > scroll_offset) {
5818            $('body').addClass('mfn-header-scrolled');
5819
5820            if( ($('.mfn-header-tmpl').hasClass('mfn-header-tmpl-fixed') && !headerTemplate.isMobile) || ( $('.mfn-header-tmpl').hasClass('mfn-mobile-header-tmpl-fixed') && headerTemplate.isMobile) && $('.mfn-header-tmpl .hide-on-scroll:not(.closeable-hidden)').length ){
5821              if( headerTemplate.hasSticky && !headerTemplate.isMobile ) {
5822                $('.mfn-header-tmpl').css({'top': 0});
5823              }else{
5824                $('.mfn-header-tmpl').css({'top': '-'+headerTemplate.offsetScroll+'px'});
5825              }
5826            }
5827
5828          }else{
5829            $('body').removeClass('mfn-header-scrolled');
5830
5831            if( ($('.mfn-header-tmpl').hasClass('mfn-header-tmpl-fixed') && !headerTemplate.isMobile) || ( $('.mfn-header-tmpl').hasClass('mfn-mobile-header-tmpl-fixed') && headerTemplate.isMobile) && $('.mfn-header-tmpl .hide-on-scroll:not(.closeable-hidden)').length ){
5832              $('.mfn-header-tmpl').css({'top': '-'+scrolled+'px'});
5833              //$('.mfn-header-tmpl').css({'top': '0px'});
5834            }
5835
5836            if( $('#wpadminbar').length ) {
5837              let admin_bar_h = $('#wpadminbar').outerHeight();
5838              if($('.mfn-header-tmpl.mfn-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5839              if($(window).width() < 767 && $('.mfn-header-tmpl.mfn-mobile-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-mobile-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5840
5841            }
5842
5843          }
5844      });
5845    },
5846    getHeight: function() {
5847      headerTemplate.height = $('.mfn-header-tmpl').outerHeight();
5848      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
5849        $('#Wrapper').css({ 'padding-top' : headerTemplate.height });
5850      }else{
5851        $('#Wrapper').removeAttr('style');
5852      }
5853      $('.mfn-header-tmpl').removeAttr('style');
5854    },
5855
5856    readcookie: function(name){
5857      var nameEQ=name+"=";
5858      var ca=document.cookie.split(';');
5859      for(var i=0;i<ca.length;i++){
5860        var c=ca[i];
5861        while(c.charAt(0)==' ')c=c.substring(1,c.length);
5862        if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length)
5863      }
5864
5865      return null
5866    },
5867
5868  }
5869
5870
5871let mfnMarqueeText = {
5872  win_width: 1920,
5873
5874  init: function() {
5875
5876      if( !$('.mfn-marquee-text-wrapper').length ) return;
5877
5878      this.win_width = $(window).width();
5879
5880      setTimeout(function() {
5881        mfnMarqueeText.set();
5882      }, 100);
5883
5884    },
5885
5886    set: function() {
5887      $('.mfn-marquee-text-wrapper:not(.initialized)').each(function(i, el) {
5888
5889        if( !$(this).find('.mfn-marquee-text').length ) return;
5890        $(this).addClass('initialized');
5891        let track = $(this).find('.mfn-marquee-text');
5892        let width = track.outerWidth();
5893
5894        document.body.style.display = 'table';
5895        document.body.offsetHeight; // FIX: mobile safari force reflow
5896        document.body.style.display = '';
5897
5898        if( width == 0 ) return;
5899
5900        let divi = Math.round( (mfnMarqueeText.win_width / width) ) + 1;
5901        let iter = Math.round(Math.ceil(divi / 2) * 2);
5902
5903        if( iter < 2 ) return;
5904
5905        let track_html = track.html();
5906
5907        for (var j = 1;
5907 j <= iter; j++) {
5908            track.append(track_html);
5909          }
5910
5911        let count = track.find('.mfn-marquee-item').length;
5912
5913        if( count % 2 !== 0 ){
5914          track.append(track_html);
5915        }
5916
5917      });
5918
5919    }
5920
5921}
5922
5923mfnMarqueeText.init();
5924
5925$(document).on('mfn:ajax:refresh', mfnMarqueeText.init);
5926
5927
5928
5929  /**
5930   *
5931   * Read more
5932   *
5933   * */
5934
5935  let mfnReadMore = {
5936
5937    init: function() {
5938
5939      if( $('body').hasClass('mfn-ui') ) return false;
5940      if( !$('.mfn-read-more').length ) return false;
5941
5942      mfnReadMore.prepare();
5943      mfnReadMore.click();
5944
5945    },
5946
5947    prepare: function() {
5948
5949      if( $('body').hasClass('mfn-ui') ) return false;
5950
5951      $('.mfn-read-more').each(function() {
5952        let this_wrapper = $(this).closest('.column');
5953        let copy = this_wrapper.nextAll('.column').addClass('mfn-read-more-hidden');
5954
5955        if( copy.length ){
5956          $.each(copy, function(i, item) {
5957            this_wrapper.before(item);
5958          });
5959        }
5960
5961      });
5962    },
5963
5964    click: function() {
5965
5966      $(document).on('click', '.mfn-read-more', function(e) {
5967        e.preventDefault();
5968
5969        let icon = false;
5970
5971        let box = $(this);
5972
5973        let wrapper = box.closest('.mcb-wrap');
5974        let label1 = box.attr('data-title1');
5975        let label2 = box.attr('data-title2');
5976
5977        let icon1 = box.attr('data-icon1');
5978        let icon2 = box.attr('data-icon2');
5979
5980        let label = box.find(box.attr('data-label_path'));
5981
5982        icon = box.find(box.attr('data-icon_path'));
5983
5984        if(wrapper.hasClass('mfn-read-more-expanded')){
5985          wrapper.find('.mfn-read-more-hidden').removeClass('showed').slideUp(500);
5986          wrapper.removeClass('mfn-read-more-expanded');
5987          label.html(label1);
5988
5989          if( icon1 != '' && icon.length ) {
5990            icon.html('<i class="'+icon1+'"></i>');
5991          }else{
5992            icon.remove();
5993          }
5994
5995        }else{
5996          wrapper.find('.mfn-read-more-hidden').addClass('showed').slideDown(500);
5997          wrapper.addClass('mfn-read-more-expanded');
5998          label.html(label2);
5999
6000          if( icon2 != '' ) {
6001            if( icon.length ){
6002              icon.html('<i class="'+icon2+'"></i>');
6003            }else{
6004              if( box.find('.mfn-icon-box').length ){
6005                box.find('.mfn-icon-box').prepend('<span class="'+box.attr('data-icon_path').replace('.', '')+'"><i class="'+icon2+'"></i></span>');
6006              }else{
6007                box.prepend('<span class="'+box.attr('data-icon_path').replace('.', '')+'"><i class="'+icon2+'"></i></span>');
6008              }
6009            }
6010          }
6011
6012        }
6013
6014        // FIX | init slick slider
6015        $(window).trigger('resize');
6016
6017        // FIX | recalculate other things
6018        setTimeout(function() {
6019          $(window).trigger('resize');
6020        }, 600);
6021
6022      });
6023    }
6024
6025  }
6026
6027
6028  /**
6029   *
6030   * Popup template
6031   *
6032   * */
6033
6034  let mfnPopup = {
6035
6036    init: function() {
6037
6038      // mfnPopup.init()
6039
6040      if( $('body').hasClass('elementor-editor-active') ) return; // stop if elementor builder is active
6041
6042        $(document).on('click', '.open-mfn-popup', function(e) {
6043          e.preventDefault();
6044          let popup_id = $(this).attr('data-mfnpopup');
6045
6046          if( popup_id == 'popup_id_required' ){
6047            alert('Popup ID id required');
6048          }else if( !$(popup_id).length ){
6049            alert('We cannot find popup with inserted ID');
6050          }else{
6051            mfnPopup.showPopup($(popup_id));
6052          }
6053        });
6054
6055
6056      if( !$('body').hasClass('mfn-cookies-open') ) mfnPopup.open();
6057
6058      $(document).on('click', '.exit-mfn-popup', function(e) {
6059        e.preventDefault();
6060        let $popup = $(this).closest('.mfn-popup-tmpl');
6061        mfnPopup.hidePopup($popup);
6062      });
6063
6064    },
6065
6066    open: function() {
6067      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').length ) mfnPopup.showOnScroll();
6068      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').length ) mfnPopup.showOnDelay();
6069      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').length ) mfnPopup.showOnExit();
6070      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').length ) mfnPopup.showOnScrollToElement();
6071      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').length ) mfnPopup.showOnStart();
6072    },
6073
6074    hidePopup: function( $popup ) {
6075
6076      if( $popup.find('video').length ) $popup.find('video').get(0).pause();
6077
6078      if( $popup.find('iframe').length ) {
6079        var popup_iframe = $popup.find('iframe')[0];
6080        var ifr_src = $(popup_iframe).attr('src');
6081
6082        if( typeof ifr_src != 'undefined' ){
6083          if( ifr_src.includes('youtu') ) popup_iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); // yt
6084
6085          if( ifr_src.includes('vimeo') ) {
6086            $(popup_iframe).attr('src', ifr_src); // vimeo
6087            //popup_iframe.pause();
6088          }
6089        }
6090
6091      }
6092
6093      $popup.removeClass('mfn-popup-active');
6094      $('html').removeClass('mfn-popup-browser-scroll-disabled');
6095
6096      if( $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).length ){
6097        $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).remove();
6098      }
6099
6100      if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') || $popup.hasClass('mfn-popup-tmpl-display-one') ){
6101        let days = 365;
6102
6103        if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') ) days = parseInt($popup.attr('data-cookie'));
6104
6105        let cookie_name = 'mfn_popup_'+$popup.attr('data-id');
6106        mfnPopup.addCookie(days, cookie_name);
6107      }
6108
6109    },
6110
6111    showPopup: function( $popup ){
6112
6113      let cookie_name = 'mfn_popup_'+$popup.attr('data-id');
6114      if( mfnPopup.checkCookie(cookie_name) ) return;
6115
6116      if( typeof $popup.attr('data-blur') !== 'undefined' ){
6117        $('body').append('<style class="mfn-popup-tmpl-blur-'+$popup.attr('data-id')+'">#Wrapper{ filter: blur('+$popup.attr('data-blur')+'px) }</style>');
6118      }
6119
6120      if( !$popup.hasClass('mfn-popup-active') ) $popup.addClass('mfn-popup-active mfn-popup-showed');
6121
6122      if( $popup.hasClass('mfn-popup-tmpl-hide-automatically-delay') ) mfnPopup.hideAutomatically($popup);
6123      if( $popup.hasClass('mfn-popup-tmpl-close-button-show-delay') ) mfnPopup.showExitButton($popup);
6124
6125      if( !$('body').hasClass('mfn-ui') && $popup.hasClass('mfn-popup-close-on-overlay-click') ){
6126        $popup.bind('click',  mfnPopup.closeOverlayClick);
6127      }
6128
6129      if( !$popup.hasClass('mfn-popup-browser-scroll-enabled') ){
6130        $('html').addClass('mfn-popup-browser-scroll-disabled');
6131      }
6132
6133      bannerBox.set();
6134
6135      if( $popup.find('.slick-initialized').length ){
6136        $popup.find('.slick-initialized').slick('refresh');
6137      }
6138
6139      $(document).trigger('mfnPopupInit');
6140    },
6141
6142    closeOverlayClick: function(e) {
6143      var div = $(e.delegateTarget).find('.mfn-popup-tmpl-content-wrapper');
6144      if (!div.is(e.target) && div.has(e.target).length === 0){
6145          mfnPopup.hidePopup($(e.delegateTarget));
6146          $(e.delegateTarget).unbind('click', mfnPopup.closeOverlayClick);
6147      }
6148    },
6149
6150    hideAutomatically: function($popup) {
6151        if( $('body').hasClass('mfn-ui') ) return;
6152        let delay = parseInt( $popup.attr('data-hidedelay') );
6153        setTimeout(function() { mfnPopup.hidePopup($popup); }, delay);
6154    },
6155
6156    showExitButton: function($popup) {
6157      let delay = parseInt( $popup.attr('data-closebuttondelay') );
6158      setTimeout(function() { $popup.addClass('mfn-closebutton-active'); }, delay);
6159    },
6160
6161    showOnScroll: function() {
6162      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').each(function() {
6163        let $popup = $(this);
6164        let scroll_offset = parseInt( $popup.attr('data-display') );
6165
6166        $(window).on('scroll', function() {
6167          if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
6168        });
6169
6170      });
6171    },
6172
6173    showOnScrollToElement: function() {
6174      $('body').imagesLoaded(function() {
6175        $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').each(function() {
6176          let $popup = $(this);
6177          let scroll_offset = $($popup.attr('data-display')).length ? parseInt( $($popup.attr('data-display')).offset().top ) : 100;
6178
6179          $(window).on('scroll', function() {
6180            if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
6181          });
6182
6183        });
6184      });
6185    },
6186
6187    showOnDelay: function() {
6188      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').each(function() {
6189        let $popup = $(this);
6190        let delay = parseInt( $popup.attr('data-display') );
6191
6192        setTimeout(function() {
6193          mfnPopup.showPopup($popup)
6194        }, delay);
6195      });
6196    },
6197
6198    showOnExit: function() {
6199      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').each(function() {
6200        let $popup = $(this);
6201
6202        $(document).on('mouseleave', function() {
6203          mfnPopup.showPopup($popup)
6204        });
6205      });
6206    },
6207
6208    showOnStart: function() {
6209      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').each(function() {
6210        let $popup = $(this);
6211        mfnPopup.showPopup($popup)
6212      });
6213    },
6214
6215    addCookie(days, cookie_name){
6216
6217      let date=new Date();
6218      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
6219      let expires="; expires="+date.toGMTString();
6220      document.cookie=cookie_name+"=true"+expires+"; path=/";
6221
6222    },
6223
6224    checkCookie(cookie_name){
6225      var nameEQ = cookie_name+"=";
6226      var ca = document.cookie.split(';');
6227      for(var i=0;i<ca.length;i++){
6228        var c = ca[i];
6229        while(c.charAt(0)==' ') c = c.substring(1,c.length);
6230        if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length)
6231      }
6232      return null
6233    }
6234
6235  }
6236
6237  $(document).on('mfn:gdpr2:close', function() {
6238    mfnPopup.open();
6239  });
6240
6241  /**
6242   * Read more term desc
6243   */
6244
6245  var mfnReadMoreTermDesc = function($el) {
6246
6247    var $el = $el.closest('.mfn-desc-expandable');
6248
6249    var start = $el.css('max-height'),
6250      height;
6251
6252    $el.css('max-height','unset');
6253
6254    height = $el.outerHeight();
6255
6256    $el.css('max-height',start);
6257
6258    $el.animate({
6259      'maxHeight': height + 'px'
6260    },500);
6261
6262    $el.find('.read-more').animate({
6263      'opacity': 0
6264    },500,function(){
6265      $(this).hide();
6266    });
6267  };
6268
6269   $(document).on('click', '.mfn-desc-expandable .read-more .read-more-button', function(e) {
6270    e.preventDefault();
6271    mfnReadMoreTermDesc($(this));
6272  });
6273
6274
6275  var mfnSideMenu = {
6276
6277    id: '',
6278    wrapper: false,
6279    hash: false,
6280    submenu: false,
6281    backup: {},
6282
6283    init: function() {
6284      if( $('.mfn-menu-tabs-wrapper').length ) mfnSideMenu.menutabs();
6285
6286      if( $('.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-toggled').length ) mfnSideMenu.toggleSubmenu();
6287      if( $('.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-replace').length ) mfnSideMenu.replaceSubmenu();
6288
6289      if( $('a.mfn-open-sidebar').length ) {
6290        mfnSideMenu.click();
6291        mfnSideMenu.closeClick();
6292      }
6293
6294      $(document).on('click', '.mfn-sidemenu-menu li a', function(e) {
6295        var href = $(this).attr('href');
6296
6297        if( href == '#' && $(this).siblings('.outer-menu-sub').length ) {
6298          e.preventDefault();
6299          $(this).siblings('.outer-menu-sub').trigger('click');
6300        }else if( href.includes('#') ) {
6301
6302          var href_split = href.split('#');
6303          if( !$('#'+href_split[1]).length ) return;
6304
6305          e.preventDefault();
6306          $(this).closest('li').addClass('current-menu-item').siblings('li').removeClass('current-menu-item');
6307
6308          var offset = $('#'+href_split[1]).offset().top;
6309
6310          offset = offset - ( fixStickyHeaderH() + adminBarH() );
6311
6312          $('body, html').animate({scrollTop: offset}, 500);
6313
6314          mfnSideMenu.id = $(this).closest('.mfn-sidemenu-tmpl').attr('data-id');
6315          mfnSideMenu.hide();
6316        }
6317
6318      });
6319
6320    },
6321
6322    closeClick: function() {
6323      $(document).on('click', '.mfn-sidemenu-closebutton', function(e) {
6324        e.preventDefault();
6325
6326        mfnSideMenu.id = $(this).closest('.mfn-sidemenu-tmpl').attr('data-id');
6327        mfnSideMenu.hide();
6328
6329      });
6330    },
6331
6332    hide: function() {
6333      $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).removeClass('mfn-sidemenu-active');
6334
6335      $('html').addClass('mfn-closing-sidemenu-'+mfnSideMenu.id);
6336
6337      $('html').removeClass('mfn-sidemenu-'+mfnSideMenu.id+'-active');
6338      $('html').removeClass('mfn-sidemenu-move-content-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-align'));
6339      $('html').removeClass('mfn-sidemenu-bodyscroll-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-bodyscroll'));
6340      $('html').removeClass('mfn-sidemenu-entrance-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance'));
6341
6342      setTimeout(function() {
6343        $('html').removeClass('mfn-closing-sidemenu-'+mfnSideMenu.id);
6344        // $(window).trigger('resize');
6345        redrawAllRevolutionSliders();
6346      }, 310);
6347
6348      if( !$('body').hasClass('mfn-ui') && $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).hasClass('mfn-sidemenu-close-on-overlay-click') ) {
6349        $(document).unbind('click', mfnSideMenu.closeOverlayClick);
6350      }
6351
6352    },
6353
6354    click: function() {
6355      $(document).on('click', 'a.mfn-open-sidebar', function(e) {
6356        e.preventDefault();
6357
6358        mfnSideMenu.id = String($(this).attr('data-sidemenu'));
6359
6360        if( !$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).length ) return;
6361
6362        $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).addClass('mfn-sidemenu-active');
6363
6364        $('html').addClass('mfn-sidemenu-entrance-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance'));
6365        $('html').addClass('mfn-sidemenu-'+mfnSideMenu.id+'-active');
6366
6367        if( $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance') == 'move-content' ){
6368          $('html').addClass('mfn-sidemenu-move-content-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-align'));
6369        }
6370
6371        if( !$('body').hasClass('mfn-ui') && $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).hasClass('mfn-sidemenu-close-on-overlay-click') ) {
6372          $(document).bind('click',  mfnSideMenu.closeOverlayClick);
6373        }
6374
6375        setTimeout(function(){
6376          $('html').addClass('mfn-sidemenu-bodyscroll-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-bodyscroll'));
6377        },300);
6378
6379      });
6380    },
6381
6382    closeOverlayClick: function(e) {
6383      var div = $('.mfn-sidemenu-tmpl');
6384      if ( !div.is(e.target) && div.has(e.target).length === 0 && !$(e.target).closest('.mfn-menu-wrapper').length ){
6385          mfnSideMenu.hide();
6386      }
6387    },
6388
6389    menutabs: function() {
6390      $(document).on('click', '.mfn-menu-tabs-wrapper ul.mfn-menu-tabs-nav li a', function(e) {
6391        e.preventDefault();
6392
6393        if( $(this).parent('li').hasClass('active') ){
6394          return;
6395        }else{
6396          $(this).closest('.mfn-menu-tabs-wrapper').find('.active').removeClass('active');
6397        }
6398
6399        let id = $(this).attr('href');
6400        $(this).parent('li').addClass('active');
6401        $(this).closest('.mfn-menu-tabs-wrapper').find(id).addClass('active');
6402
6403      });
6404    },
6405
6406    toggleSubmenu: function() {
6407      $(document).on('click', '.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-toggled li.menu-item-has-children .outer-menu
6407-sub', function(e) {
6408        e.preventDefault();
6409        if( !$(this).closest('li').hasClass('current-menu-item') && !$(this).closest('li').hasClass('current-menu-ancestor') ){
6410          $(this).closest('li').addClass('current-menu-ancestor');
6411        }else if( $(this).closest('li').hasClass('current-menu-ancestor') ){
6412          $(this).closest('li').removeClass('current-menu-ancestor');
6413        }else{
6414          $(this).closest('li').toggleClass('current-menu-item');
6415        }
6416
6417        //$(this).closest('li').toggleClass('current-menu-ancestor');
6418        //if( $(this).closest('ul').closest('li').hasClass('current-menu-ancestor') ) $(this).closest('ul').closest('li').toggleClass('current-menu-ancestor');
6419      });
6420    },
6421
6422    replaceSubmenu: function() {
6423      $(document).on('click', '.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-replace li.menu-item-has-children .outer-menu-sub', function(e) {
6424        e.preventDefault();
6425
6426        mfnSideMenu.wrapper = $(this).closest('.mfn-menu-wrapper');
6427        mfnSideMenu.hash = mfnSideMenu.wrapper.attr('data-hash');
6428        mfnSideMenu.submenu = $(this).closest('li').find('ul.sub-menu').first().html();
6429
6430        if( typeof mfnSideMenu.backup[mfnSideMenu.hash] === 'undefined' ){
6431          mfnSideMenu.backup[mfnSideMenu.hash] = [];
6432        }
6433
6434        let newest = {};
6435        newest.label = $(this).closest('li').find('a.mfn-menu-link .menu-label').html();
6436        newest.ul = mfnSideMenu.wrapper.children('ul').html();
6437
6438        mfnSideMenu.backup[mfnSideMenu.hash].push(newest);
6439
6440        if( !mfnSideMenu.wrapper.hasClass('mfn-sidemenu-replaced') ) mfnSideMenu.wrapper.addClass('mfn-sidemenu-replaced');
6441
6442        setTimeout(mfnSideMenu.updateMenu, 10);
6443
6444        //mfnSideMenu.updateMenu();
6445
6446      });
6447
6448      mfnSideMenu.breadcrumbsClick();
6449    },
6450
6451    updateMenu: function() {
6452
6453      if(mfnSideMenu.wrapper.find('.mfn-sidemenu-back').length) mfnSideMenu.wrapper.find('.mfn-sidemenu-breadcrumbs').remove();
6454
6455      mfnSideMenu.wrapper
6456        .find('.mfn-sidemenu-menu').html(mfnSideMenu.submenu);
6457
6458      if( mfnSideMenu.backup[mfnSideMenu.hash].length > 0 ) {
6459        mfnSideMenu.wrapper.prepend('<div class="mfn-sidemenu-breadcrumbs"></div>');
6460        mfnSideMenu.backup[mfnSideMenu.hash].map(function(el, i) {
6461          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>');
6462        });
6463
6464      }
6465
6466    },
6467
6468    breadcrumbsClick: function() {
6469
6470      $(document).on('click', '.mfn-sidemenu-back', function(e) {
6471        e.preventDefault();
6472
6473        mfnSideMenu.wrapper = $(this).closest('.mfn-menu-wrapper');
6474        mfnSideMenu.hash = mfnSideMenu.wrapper.attr('data-hash');
6475
6476        let index = $(this).attr('data-index');
6477
6478        let choosed = mfnSideMenu.backup[mfnSideMenu.hash][index];
6479
6480        mfnSideMenu.submenu = choosed.ul;
6481
6482        mfnSideMenu.backup[mfnSideMenu.hash] = mfnSideMenu.backup[mfnSideMenu.hash].filter((item,i) => { return i < index });
6483
6484        //mfnSideMenu.updateMenu();
6485        setTimeout(mfnSideMenu.updateMenu, 10);
6486      });
6487    }
6488
6489  }
6490
6491  /**
6492   * Lazy Load images
6493   */
6494
6495  document.addEventListener('DOMContentLoaded', () => {
6496
6497    const images = Array.from(document.querySelectorAll('img.mfn-lazy'));
6498
6499    if ('IntersectionObserver' in window) {
6500      const imageObserver = new IntersectionObserver((entries, observer) => {
6501        entries.forEach(entry => {
6502          if (entry.isIntersecting) {
6503            const image = entry.target;
6504            image.src = image.dataset.src;
6505            imageObserver.unobserve(image);
6506            window.dispatchEvent(new Event('resize'));
6507          }
6508        });
6509      });
6510
6511      images.forEach(img => imageObserver.observe(img));
6512    }
6513
6514  });
6515
6516})(jQuery);
6517
6518// Safari resize fix
6519(function() {
6520  let lastZoom = 1;
6521
6522  function getZoom() {
6523    return window.outerWidth / window.innerWidth;
6524  }
6525
6526  function checkZoomReset() {
6527    const currentZoom = getZoom();
6528    if (Math.abs(currentZoom - 1) < 0.02 && lastZoom !== 1) {
6529      window.scrollTo({ left: 0, top: window.scrollY, behavior: 'instant' });
6530    }
6531    lastZoom = currentZoom;
6532  }
6533
6534  window.addEventListener('resize', checkZoomReset);
6535})();
6536
6537// Remove Gray Highlight When Tapping Links in Mobile Safari
6538document.addEventListener("touchstart", function(){}, true);

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.