PageSourceSearch

https://westore.ge/wp-content/themes/betheme/js/scripts.js?ver=28.5

js westore.ge collected 2026-10-02 01:02:22 UTC 189,847 bytes, 6,592 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     * Helper function to ensure the alt attribute value is safely handled
2173     */
2174
2175    function escapeHtml(text) {
2176
2177      if ( ! text ) return '';
2178
2179      const map = {
2180          '&': '&amp;',
2181          '<': '&lt;',
2182          '>': '&gt;',
2183          '"': '&quot;',
2184          "'": '&#039;'
2185      };
2186
2187      return text.replace(/[&<>"']/g, function(m) { return map[m]; });
2188    }
2189
2190    /**
2191     * Lightbox | Magnific Popup
2192     * with prettyPhoto backward compatibility
2193     */
2194
2195    function lightbox() {
2196
2197      var galleries = [];
2198
2199      // init
2200
2201      var init = function() {
2202
2203        if (lightboxAttr) {
2204          compatibility();
2205          setType();
2206          constructor();
2207        }
2208
2209      };
2210
2211      // backward compatibility for prettyPhoto
2212
2213      var compatibility = function() {
2214
2215        $('a[rel^="prettyphoto"], a.prettyphoto, a[rel^="prettyphoto"]').each(function() {
2216
2217          var el = $(this);
2218          var rel = el.attr('rel');
2219
2220          if (rel) {
2221            rel = rel.replace('prettyphoto', 'lightbox');
2222          } else {
2223            rel = 'lightbox';
2224          }
2225
2226          el.removeClass('prettyphoto').attr('rel', rel);
2227
2228        });
2229
2230      };
2231
2232      // check if item is a part of gallery
2233
2234      var isGallery = function(rel) {
2235
2236        if (!rel) {
2237          return false;
2238        }
2239
2240        var regExp = /\[(?:.*)\]/;
2241        var gallery = regExp.exec(rel);
2242
2243        if (gallery) {
2244          gallery = gallery[0];
2245          gallery = gallery.replace('[', '').replace(']', '');
2246          return gallery;
2247        }
2248
2249        return false;
2250      };
2251
2252      // set array of names of galleries
2253
2254      var setGallery = function(gallery) {
2255
2256        if (galleries.indexOf(gallery) == -1) {
2257          galleries.push(gallery);
2258          return true;
2259        }
2260
2261        return false;
2262      };
2263
2264      // get file type by link
2265
2266      var getType = function(src) {
2267
2268        if (src.match(/youtube\.com\/watch/i) || src.match(/youtube\.com\/embed/i) || src.match(/youtu\.be/i)) {
2269          return 'iframe';
2270
2271        } else if (src.match(/youtube-nocookie\.com/i)) {
2272          return 'iframe';
2273
2274        } else if (src.match(/vimeo\.com/i)) {
2275          return 'iframe';
2276
2277        } else if (src.match(/\biframe=true\b/i)) {
2278          return 'ajax';
2279
2280        } else if (src.match(/\bajax=true\b/i)) {
2281          return 'ajax';
2282
2283        } else if (src.match(/\.mp4/i)) {
2284          return 'mp4';
2285
2286        } else if (src.substr(0, 1) == '#') {
2287          return 'inline';
2288
2289        } else {
2290          return 'image';
2291
2292        }
2293      };
2294
2295      // set file type
2296
2297      var setType = function() {
2298
2299        $('a[rel^="lightbox"]').each(function() {
2300
2301          var el = $(this);
2302          var href = el.attr('href');
2303          var rel = el.attr('rel');
2304
2305          // FIX: WPBakery Page Builder duplicated lightbox
2306          if ( el.closest('.wpb_column').length ){
2307            // return true;
2308          }
2309
2310          if (href) {
2311
2312            // gallery
2313
2314            var gallery = isGallery(rel);
2315
2316            if (gallery) {
2317              el.attr('data-lightbox-type', 'gallery');
2318              setGallery(gallery);
2319              return true;
2320            }
2321
2322            el.attr('data-lightbox-type', getType(href));
2323
2324            // iframe paremeters
2325
2326            if (getType(href) == 'iframe') {
2327              el.attr('href', href.replace('&rel=0', ''));
2328            }
2329          }
2330
2331        });
2332
2333      };
2334
2335      // constructor
2336
2337      var constructor = function() {
2338
2339        // Dividing plugins into separate files fix
2340        if( !galleries.length
2341          && !$('a[rel^="lightbox"][data-lightbox-type="image"]').length
2342          && !$('a[rel^="lightbox"][data-lightbox-type="iframe"]').length
2343          && !$('a[rel^="lightbox"][data-lightbox-type="inline"]').length
2344          && !$('a[rel^="lightbox"][data-lightbox-type="mp4"]').length
2345          && !$('a[rel^="pdf-lightbox"]').length
2346        ) return;
2347
2348        var attr = {
2349          autoFocusLast: false,
2350          removalDelay: 160,
2351          image: {
2352            titleSrc: function(item) {
2353              var img = item.el.closest('.image_wrapper, li').find('img').first();
2354              if (lightboxAttr.title && img.length) {
2355                return escapeHtml( img.attr('alt') );
2356              } else {
2357                return false;
2358              }
2359            }
2360          }
2361        };
2362
2363        // image
2364
2365        $('a[rel^="lightbox"][data-lightbox-type="image"]').magnificPopup({
2366          autoFocusLast: attr.autoFocusLast,
2367          removalDelay: attr.removalDelay,
2368          type: 'image',
2369          image: attr.image
2370        });
2371
2372        // iframe | video
2373
2374        $('a[rel^="lightbox"][data-lightbox-type="iframe"]').magnificPopup({
2375          autoFocusLast: attr.autoFocusLast,
2376          removalDelay: attr.removalDelay,
2377          type: 'iframe',
2378          iframe: {
2379            patterns: {
2380              youtube: {
2381                index: 'youtube.com/',
2382                id: 'v=',
2383                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
2384              },
2385              youtu_be: {
2386                index: 'youtu.be/',
2387                id: '/',
2388                src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
2389              },
2390              nocookie: {
2391                index: 'youtube-nocookie.com/embed/',
2392                id: '/',
2393                src: '//www.youtube-nocookie.com/embed/%id%?autoplay=1&rel=0'
2394              }
2395            }
2396          }
2397        });
2398
2399        // iframe | mp4
2400
2401        $('a[rel^="lightbox"][data-lightbox-type="mp4"]').magnificPopup({
2402          autoFocusLast: attr.autoFocusLast,
2403          removalDelay: attr.removalDelay,
2404          type: 'iframe',
2405          iframe: {
2406            markup: '<div class="mfp-mp4 popup-content">'+
2407              '<video controls mute autoplay>'+
2408                '<source class="mfp-source" type="video/mp4">'+
2409              '</video>'+
2410              '<div class="mfp-close"></div>'+
2411            '</div>',
2412            patterns: {
2413              mp4: {
2414                src: '%id%',
2415              }
2416            },
2417            srcAction: 'source_src',
2418          }
2419        });
2420
2421        // pdf
2422
2423        $('a[rel^="pdf-lightbox"]').magnificPopup({
2424          autoFocusLast: attr.autoFocusLast,
2425          removalDelay: attr.removalDelay,
2426          type: 'iframe'
2427        });
2428
2429        // inline
2430
2431        $('a[rel^="lightbox"][data-lightbox-type="inline"]').magnificPopup({
2432          autoFocusLast: attr.autoFocusLast,
2433          type: 'inline',
2434          midClick: true,
2435          callbacks: {
2436            open: function() {
2437              $('.mfp-content').children().addClass('mfp-inline')
2438
2439              // lazy load video and autoplay
2440              // $('.mfp-content').find('source').each(function(){
2441              //   $(this).attr('src', $(this).attr('data-src') );
2442              //   $(this).parent('video').get(0).load();
2443              //   $(this).parent('video').get(0).play();
2444              // });
2445
2446            },
2447            beforeClose: function() {
2448              $('.mfp-content').children().removeClass('mfp-inline');
2449            }
2450          }
2451        });
2452
2453        // gallery
2454
2455        for (var i = 0, len = galleries.length; i < len; i++) {
2456
2457          var gallery = '[' + galleries[i] + ']';
2458          gallery = 'a[rel^="lightbox' + gallery + '"]:visible';
2459
2460          $(gallery).magnificPopup({
2461            autoFocusLast: attr.autoFocusLast,
2462            removalDelay: attr.removalDelay,
2463            type: 'image',
2464            image: attr.image,
2465            gallery: {
2466              enabled: true,
2467              tCounter: '%curr% / %total%' // markup of counter
2468            }
2469
2470          });
2471
2472        }
2473
2474        // FIX: elementor | disable in Elementor wrapper
2475
2476        $('.elementor-page a[rel^="lightbox"]:not(.popup-link):not(.rs-layer):not([data-lightbox-type="iframe"])').off('click');
2477
2478        // FIX: WPBakery | disable if WPBakery lighbox is active
2479
2480        setTimeout(function(){
2481
2482          var $doc = $('body');
2483          var $events = $._data($doc[0],"events");
2484
2485          if($events && $events.click){
2486            for(var i=$events.click.length-1; i>=0; i--){
2487              var handler = $events.click[i];
2488              if( handler && handler.selector && handler.selector.indexOf('lightbox') !== -1 ){
2489                $('.wpb_column a[rel^="lightbox"]:not(.popup-link)').off('click');
2490              }
2491            }
2492          }
2493
2494        },0);
2495
2496      };
2497
2498      // reload
2499
2500      var reload = function() {
2501
2502        $('a[rel^="lightbox"]').off('click');
2503        constructor();
2504
2505      };
2506
2507      // init
2508
2509      init();
2510
2511      // isotope:arrange
2512
2513      mfnIsotope.addEventListener('arrange', reload);
2514
2515      // ajaxComplete
2516
2517      $(document).ajaxComplete(function() {
2518        reload();
2519      });
2520
2521    }
2522
2523    lightbox();
2524
2525    $(document).on('mfnPopupInit', function() {
2526      lightbox();
2527    });
2528
2529    $(document).on('mfn:tabber:open', function() {
2530      lightbox();
2531    });
2532
2533    /**
2534     * Menu | mfnMenu
2535     */
2536
2537    function mainMenu() {
2538
2539      var mmMobileInitW = mobileInitW;
2540
2541      if ($('body').hasClass('header-simple') || $('#Header_creative.dropdown').length) {
2542        mmMobileInitW = 9999;
2543      }
2544
2545      $('#menu > ul.menu').mfnMenu({
2546        addLast: true,
2547        arrows: true,
2548        mobileInit: mmMobileInitW,
2549        responsive: mfn.responsive
2550      });
2551
2552      $('#secondary-menu > ul.secondary-menu').mfnMenu({
2553        mobileInit: mmMobileInitW,
2554        responsive: mfn.responsive
2555      });
2556
2557    }
2558
2559    mainMenu();
2560
2561    /**
2562     * Menu | NOT One Page | .scroll item
2563     * Works with .scroll class
2564     * Since 4.8 replaced with: Page Options > One Page | function: onePageMenu()
2565     */
2566
2567    function onePageScroll() {
2568      if (!$('body').hasClass('one-page')) {
2569        var menu = $('#menu');
2570
2571        if (menu.find('li.scroll').length > 1) {
2572          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');
2573
2574          // menu item click
2575          menu.on('click','a',function() {
2576            $(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');
2577            $(this).closest('li').addClass('current-menu-item');
2578          });
2579        }
2580      }
2581    }
2582    onePageScroll();
2583
2584    /**
2585     * Menu | One Page | Active on Scroll & Click
2586     */
2587
2588    function onePageMenu() {
2589      if ($('body').hasClass('one-page')) {
2590
2591        var menu = $('#menu');
2592        if( $('#mfn-header-template').length ) menu = $('#mfn-header-template .mfn-header-menu');
2593
2594        // add attr [data-hash] & [data-id]
2595
2596        $('a[href]', menu).each(function() {
2597
2598          var url = $(this).attr('href');
2599          if (url && url.split('#')[1]) {
2600
2601            // data-hash
2602            var hash = '#' + url.split('#')[1];
2603            if (hash && $(hash).length) {
2604              // check if element with specified ID exists
2605              $(this).attr('data-hash', hash);
2606              $(hash).attr('data-id', hash);
2607            }
2608
2609            // Visual Composer
2610            var vcHash = '#' + url.split('#')[1];
2611            var vcClass = '.vc_row.' + url.split('#')[1];
2612            if (vcClass && $(vcClass).length) {
2613              // check if element with specified Class exists
2614              $(this).attr('data-hash', vcHash);
2615              $(vcClass).attr('data-id', vcHash);
2616            }
2617
2618          }
2619
2620        });
2621
2622        // active
2623
2624        var hash;
2625        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';
2626        var activeClasses = 'current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor';
2627
2628        if ($(activeSelector, menu).length) {
2629
2630          // remove duplicated
2631          $(activeSelector, menu)
2632            .not(':first').removeClass(activeClasses);
2633
2634          // remove if 1st link to section & section is not visible
2635          hash = $(activeSelector, menu).find('a[data-hash]').attr('data-hash');
2636
2637          if (hash) {
2638            hash = '[data-id="' + hash + '"]';
2639
2640            if ($(hash).length && $(hash).visible(true)) {
2641              // do nothing
2642            } else {
2643              $(activeSelector, menu).removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor')
2644                .closest('li').removeClass('current-menu-item current-menu-parent current-menu-ancestor current-page-ancestor current_page_item current_page_parent current_page_ancestor');
2645            }
2646          } else {
2647            // do nothing
2648          }
2649
2650        } else {
2651
2652          // add to first if none is active
2653          var first = $('li:first-child', menu);
2654          var firstA = first.children('a');
2655
2656          if (firstA.attr('data-hash')) {
2657            hash = firstA.attr('data-hash');
2658            hash = '[data-id="' + hash + '"]';
2659
2660            if ($(hash).length && ($(hash).offset().top == adminBarH())) {
2661              first.addClass('current-menu-item');
2662            }
2663          }
2664
2665        }
2666
2667        // click
2668
2669        var menu_item = $('#menu a[data-hash]');
2670        if( $('#mfn-header-template').length ) menu_item = $('#mfn-header-template .mfn-header-menu a[data-hash]');
2671
2672        menu_item.on('click', function(e) {
2673          e.preventDefault(); // only with: body.one-page
2674
2675          if( $('html').hasClass('mfn-header-tmpl-burger-sidebar-opened') ){
2676            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2677          }
2678
2679          // active
2680
2681          menu.find('li').removeClass('current-menu-item');
2682          $(this)
2683            .closest('li').addClass('current-menu-item')
2684            .closest('.menu > li').addClass('current-menu-item');
2685
2686          var hash = $(this).attr('data-hash');
2687          hash = '[data-id="' + hash + '"]';
2688
2689          // mobile - sticky header - close menu
2690
2691          if ( window.innerWidth < 768 ) {
2692            $('.responsive-menu-toggle').removeClass('active');
2693            $('#Top_bar #menu').hide();
2694          }
2695
2696          // offset
2697
2698          var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
2699          var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
2700
2701          var offset = headerFixedAbH + tabsHeaderH + adminBarH();
2702
2703          // sticky height
2704
2705          var stickyH = fixStickyHeaderH();
2706
2707          // FIX | Header below | 1st section
2708          if ($('body').hasClass('header-below') && $('#Content').length) {
2709            if ($(hash).offset().top < ($('#Content').offset().top + 60)) {
2710              stickyH = -1;
2711            }
2712          }
2713
2714          // animate scroll
2715
2716          $('html, body').animate({
2717            scrollTop: $(hash).offset().top - offset - stickyH
2718          }, 500);
2719
2720          if($(this).closest('.column_header_burger').length ){
2721            //$(this).closest('.column_header_burger').find('.mfn-header-menu-toggle').trigger('click');
2722            $('body').trigger('click');
2723          }
2724
2725
2726        });
2727
2728      }
2729    }
2730    onePageMenu();
2731
2732    /**
2733     * Header | Creative
2734     */
2735
2736    var cHeader = 'body:not( .header-open ) #Header_creative',
2737      cHeaderEl = $(cHeader),
2738      cHeaderCurrnet;
2739
2740    function creativeHeader() {
2741
2742      $('.creative-menu-toggle').on('click', function(e) {
2743        e.preventDefault();
2744
2745        cHeaderEl.addClass('active');
2746        $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeOut(500);
2747        $('#Action_bar', cHeaderEl).fadeIn(500);
2748
2749      });
2750
2751    }
2752    creativeHeader();
2753
2754    $(document).on('mouseenter', cHeader, function() {
2755      cHeaderCurrnet = 1;
2756    });
2757
2758    $(document).on('mouseleave', cHeader, function() {
2759      cHeaderCurrnet = null;
2760      setTimeout(function() {
2761        if (!cHeaderCurrnet) {
2762
2763          cHeaderEl.removeClass('active');
2764          $('.creative-menu-toggle, .creative-social', cHeaderEl).fadeIn(500);
2765          $('#Action_bar', cHeaderEl).fadeOut(500);
2766
2767        }
2768      }, 1000);
2769    });
2770
2771    // Fix: Header Creative & Mobile Sticky | On Resize > 768 px
2772    function creativeHeaderFix() {
2773      if ( $('body').hasClass('header-creative') && window.innerWidth >= 768 ) {
2774        if ($('#Top_bar').hasClass('is-sticky')) {
2775          $('#Top_bar').removeClass('is-sticky');
2776        }
2777      }
2778    }
2779
2780    /**
2781     * Header | Menu Burger
2782     */
2783
2784    $(document).on("click", ".mfn-header-tmpl .mfn-header-menu-toggle", function(e) {
2785      e.preventDefault();
2786
2787      if( $(this).closest('.mcb-column').hasClass('mfn-header-tmpl-menu-active') ){
2788        $(document).unbind('click', hideSidebarTmplBurger);
2789        $(this).closest('.mcb-column').removeClass('mfn-header-tmpl-menu-active');
2790        removeBringToFront();
2791        if( $('.mfn-header-tmpl-classic-menu').length ) $('.mfn-header-tmpl-classic-menu').remove();
2792        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', false);
2793
2794        $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2795      }else{
2796        $(document).bind('click', hideSidebarTmplBurger);
2797        $(this).closest('.mcb-column').addClass('mfn-header-tmpl-menu-active');
2798        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2799        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2800        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2801        $(this).closest('.mcb-column-inner').find('.mfn-header-tmpl-menu-sidebar').attr('aria-expanded', true);
2802
2803        if( $(this).closest('.mcb-column-inner').find('.mfn-header-classic-mobile-menu').length ){
2804          var offset_top = $(this).closest('.section').offset().top + $(this).closest('.section').outerHeight() - $(window).scrollTop();
2805
2806          $('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>');
2807          //$(this).closest('.mcb-column-inner').find('.mfn-header-classic-mobile-menu').css({'top': offset_top, 'max-height': $(window).height() - offset_top});
2808        }
2809
2810        $('html').addClass('mfn-header-tmpl-burger-sidebar-opened');
2811
2812        var htmlW = $('html').width();
2813
2814        if( $('html').width() != htmlW ){
2815          $('html').addClass('scrollbar-hidden');
2816        }
2817      }
2818
2819    });
2820
2821    $(document).on("click", ".mfn-header-tmpl-menu-sidebar .mfn-header-menu .mfn-menu-li a", function (e) {
2822
2823      if( $(this).closest('#mfn-header-template').length ) return; // The header has its own functionality
2824
2825        const $a = $(this);
2826        const href = $a.attr("href") || "";
2827        const $html = $("html");
2828        const $header = $(".mfn-header-tmpl.mfn-header-main");
2829
2830        // Case: exactly "#"
2831        if (href === "#") {
2832          e.preventDefault();
2833          $a.closest("li").toggleClass("current-menu-item");
2834          return;
2835        }
2836
2837        let hash = "";
2838        const hashIndex = href.indexOf("#");
2839        if (hashIndex !== -1) hash = href.slice(hashIndex + 1);
2840
2841        if (!hash) return;
2842
2843        const $target = $("#" + CSS.escape(hash));
2844        if (!$target.length) return;
2845
2846        e.preventDefault();
2847
2848        const isFixedOrSticky =
2849          $header.hasClass("mfn-header-tmpl-fixed") || $header.hasClass("mfn-hasSticky");
2850        const headerH = isFixedOrSticky ? $header.outerHeight() : 0;
2851
2852        const $li = $a.closest("li");
2853        $li.closest("ul").find("li.current-menu-item").removeClass("current-menu-item");
2854        $li.addClass("current-menu-item");
2855
2856        const scrollOffset = $target.offset().top - headerH;
2857        $("html, body").stop(true).animate({ scrollTop: scrollOffset }, 500);
2858
2859        $(document).off("click", hideSidebarTmplBurger);
2860        $a.closest(".mcb-column").removeClass("mfn-header-tmpl-menu-active");
2861        removeBringToFront();
2862
2863        if ($html.hasClass("mfn-header-tmpl-burger-sidebar-opened")) {
2864          $html.removeClass("mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden");
2865        }
2866      }
2867    );
2868
2869
2870
2871    $(document).on("click", ".mfn-off-canvas-sidebar .widget_nav_menu ul.menu li a", function(e) {
2872      let href = $(this).attr('href');
2873
2874      if( $(href).length && href.startsWith("#") ) {
2875        e.preventDefault();
2876        let header_h = 0;
2877        if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-tmpl-fixed') || $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-hasSticky') ){
2878          header_h = $('.mfn-header-tmpl.mfn-header-main').outerHeight();
2879        }
2880        $(this).closest('ul').find('li.current-menu-item').removeClass('current-menu-item');
2881        $(this).closest('li').addClass('current-menu-item');
2882
2883        let scroll_offset = $(href).offset().top - header_h;
2884        $('body, html').animate({ scrollTop: scroll_offset }, 500);
2885        if( $('html').hasClass('mfn-ofcs-opened') ){
2886          $('html').removeClass('mfn-ofcs-opened');
2887        }
2888      }
2889    });
2890
2891
2892    function hideSidebarTmplBurger(e){
2893        var div = $('.mfn-header-tmpl-menu-sidebar');
2894
2895        if (!div.is(e.target) && div.has(e.target).length === 0){
2896            $('.mfn-header-tmpl-menu-active').removeClass('mfn-header-tmpl-menu-active');
2897
2898            div.attr('aria-expanded', 'false');
2899
2900            $(document).unbind('click', hideSidebarTmplBurger);
2901            removeBringToFront();
2902            if( $('.mfn-header-tmpl-classic-menu').length ) $('.mfn-header-tmpl-classic-menu').remove();
2903            $('html').removeClass('mfn-header-tmpl-burger-sidebar-opened scrollbar-hidden');
2904        }
2905    }
2906
2907    function removeBringToFront(){
2908      if( $('.mfn-bring-to-front').length ) {
2909        $('.mfn-bring-to-front').removeClass('mfn-bring-to-front');
2910      }
2911    }
2912
2913    /**
2914     * Header | Search
2915     */
2916
2917    $(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) {
2918      e.preventDefault();
2919
2920      if( $(this).closest('.mcb-column-inner').hasClass('mfn-searchbar-active') ){
2921        $(this).closest('.mcb-column-inner').removeClass('mfn-searchbar-active');
2922
2923        $('html').removeClass('mfn-popup-browser-scroll-disabled');
2924        $('body').removeClass('search-overlay-opened');
2925        removeBringToFront();
2926      }else{
2927        $(this).closest('.mcb-column-inner').addClass('mfn-searchbar-active');
2928        $(this).closest('.mcb-column').addClass('mfn-bring-to-front');
2929        $(this).closest('.mcb-wrap').addClass('mfn-bring-to-front');
2930        $(this).closest('.mcb-section').addClass('mfn-bring-to-front');
2931
2932        if( $(this).closest('.mcb-column-inner').find('input.field').length ){
2933          $(this).closest('.mcb-column-inner').find('input.field').focus();
2934        }
2935
2936        if( $('body').hasClass('search-scroll-disable') ){
2937          $('html').addClass('mfn-popup-browser-scroll-disabled');
2938        }
2939
2940        $('body').addClass('search-overlay-opened');
2941      }
2942
2943    });
2944
2945    $(".search_button:not(.has-input), #Top_bar .icon_close").on('click', function(e) {
2946      e.preventDefault();
2947
2948      if( $(this).closest('.mfn-header-tmpl').length ){
2949        // header template
2950        $(this).closest('.mcb-column').toggleClass('mfn-searchbar-active');
2951
2952      }else{
2953        const search = $('.search_wrapper')
2954        if( search.css('display') === 'none' ){
2955          search.fadeIn().find('.field').focus();
2956
2957          if( $('body').hasClass('search-scroll-disable') ){
2958            $('html').addClass('mfn-popup-browser-scroll-disabled');
2959          }
2960
2961          $('body').addClass('search-overlay-opened');
2962
2963          setTimeout(function(){ search.addClass('mfn-loaded') }, 300);
2964        } else{
2965          search.fadeOut().removeClass('mfn-loaded');
2966
2967          $('html').removeClass('mfn-popup-browser-scroll-disabled');
2968          $('body').removeClass('search-overlay-opened');
2969        }
2970      }
2971
2972    });
2973
2974    $(document).on('keydown', function(e){
2975      if (e.key === 'Escape' && $('.search_wrapper').is(':visible') && $('body').hasClass('search-overlay-opened')) {
2976        $('.search_wrapper .icon_close').trigger('click');
2977      }
2978    });
2979
2980    /**
2981     * WPML | Language switcher in the WP Menu
2982     */
2983
2984    function mfnWPML() {
2985      $('#menu .menu-item-language:not(.menu-item-language-current)').each(function() {
2986        var el = $(this).children('a');
2987
2988        if (!el.children('span:not(.icl_lang_sel_bracket)').length) {
2989          el.wrapInner('<span></span>');
2990        }
2991
2992      });
2993
2994      $('#menu span.icl_lang_sel_bracket').each(function() {
2995        var el = $(this);
2996        el.replaceWith(el.html());
2997      });
2998
2999    }
3000    mfnWPML();
3001
3002    /**
3003     * Breadcrumbs | Remove last item link
3004     */
3005
3006    function breadcrumbsRemoveLastLink() {
3007
3008      if( !$('.breadcrumbs.no-link').length ) return;
3009
3010      $('.breadcrumbs.no-link').each(function() {
3011        var el = $(this).find('li').last();
3012        var text = el.text();
3013        el.html(text);
3014      });
3015
3016    }
3017    breadcrumbsRemoveLastLink();
3018
3019    /**
3020     * Downcount
3021     */
3022
3023    $('.downcount:not(.mfn-initialized)').each(function() {
3024      var el = $(this);
3025      el.addClass('mfn-initialized');
3026      el.downCount({
3027        date: el.attr('data-date'),
3028        offset: el.attr('data-offset')
3029      });
3030    });
3031
3032    /**
3033     * Hover | on Touch | .tooltip, .hover_box
3034     */
3035
3036    $('.tooltip, .hover_box')
3037      .on('touchstart', function() {
3038        $(this).toggleClass('hover');
3039      })
3040      .on('touchend', function() {
3041        $(this).removeClass('hover');
3042      });
3043
3044    /**
3045     * Popup | Contact Form | Button
3046     */
3047
3048    $("#popup_contact .footer_button").on('click', function(e) {
3049      e.preventDefault();
3050      $(this).parent().toggleClass('focus');
3051    });
3052
3053    /**
3054     * Scroll | niceScroll for Header Creative
3055     */
3056
3057    if ( $('#Header_creative.scroll').length && window.innerWidth >= 1240 ) {
3058      $('#Header_creative.scroll').niceScroll({
3059        autohidemode: false,
3060        cursorborder: 0,
3061        cursorborderradius: 5,
3062        cursorcolor: '#222222',
3063        cursorwidth: 0,
3064        horizrailenabled: false,
3065        mousescrollstep: 40,
3066        scrollspeed: 60
3067      });
3068    }
3069
3070    /**
3071     * Sliding Top
3072     */
3073
3074    $('.sliding-top-control').on('click', function(e) {
3075      e.preventDefault();
3076      $('#Sliding-top .widgets_wrapper').slideToggle();
3077      $('#Sliding-top').toggleClass('active');
3078    });
3079
3080    /**
3081     * Alert
3082     */
3083
3084    $('body').on('click', '.alert .close', function(e) {
3085      e.preventDefault();
3086      $(this).closest('.alert').hide(300);
3087    });
3088
3089    /**
3090     * Navigation Arrows | Sticky
3091     */
3092
3093    $('.fixed-nav').appendTo('body');
3094
3095    /**
3096     * Feature List
3097     */
3098
3099    $('.feature_list').each(function() {
3100      var col = $(this).attr('data-col') ? $(this).attr('data-col') : 4;
3101      $(this).find('li:nth-child(' + col + 'n):not(:last-child)').after('<hr />');
3102    });
3103
3104    /**
3105     * IE Fixes
3106     */
3107
3108    function checkIE() {
3109      // IE 9
3110      var ua = window.navigator.userAgent;
3111      var msie = ua.indexOf("MSIE ");
3112      if (msie > 0 && parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) == 9) {
3113        $("body").addClass("ie");
3114      }
3115    }
3116    checkIE();
3117
3118    /**
3119     * Parallax
3120     */
3121
3122    var ua = navigator.userAgent,
3123      isMobileWebkit = /WebKit/.test(ua) && /Mobile/.test(ua);
3124
3125    if ( ! isMobileWebkit && window.innerWidth >= 768 ) {
3126
3127      if (mfn.parallax == 'stellar') {
3128
3129        // Stellar
3130        $.stellar({
3131          horizontalScrolling: false,
3132          responsive: true
3133        });
3134
3135      } else {
3136
3137        $(window).enllax();
3138
3139      }
3140
3141    } else {
3142
3143      $('div[data-enllax-ratio], div[data-stellar-ratio]').css('background-attachment', 'scroll');
3144
3145    }
3146
3147    /**
3148     * Infinite Load More | Query Pagination Ajax
3149     */
3150
3151    if( $('.mfn-query-pagination-infiniteload .next').length ){
3152      var mfnQueryPaginationWaypoint = new Waypoint({
3153        element: $('.mfn-query-pagination-infiniteload .next'),
3154        handler: function(direction) {
3155          $(this.element).trigger('click');
3156        },
3157        offset: '100%'
3158      })
3159    }
3160
3161    /**
3162     * Load More | Query Pagination Ajax
3163     */
3164
3165    if( $('.mfn-query-pagination-loadmore .next').length ){
3166      $(document).on('click', '.mfn-query-pagination-loadmore .next', function(e) {
3167        e.preventDefault();
3168
3169        if( $(this).hasClass('loading') ) return;
3170
3171        let button = $(this);
3172        let wrapper = '.'+button.closest('.mcb-section').attr('class').replaceAll('  ', '.').replaceAll(' ', '.');
3173        let href = button.attr('href');
3174
3175        button.addClass('loading');
3176
3177        $.get( href, function( data ) {
3178
3179          $(wrapper+' .section_wrapper').append( $(wrapper+' .section_wrapper', data).html() );
3180          if( $(wrapper+' .mfn-query-pagination', data).length ) $(wrapper+' .mfn-query-pagination').replaceWith($(wrapper+' .mfn-query-pagination', data));
3181
3182          if( $(wrapper+' .isotope').length ){
3183            $(wrapper+' .isotope').imagesLoaded().progress(function() {
3184              $(wrapper+' .isotope').isotope('reloadItems');
3185            });
3186          }
3187
3188          lightbox();
3189
3190          if( $(wrapper).find('.mfn-query-loop-masonry').length ){
3191            queryLoopMasonry();
3192          }
3193
3194
3195          if( $(wrapper+' .mfn-query-pagination').hasClass('mfn-query-pagination-infiniteload') ){
3196            mfnQueryPaginationWaypoint.destroy();
3197
3198
3199
3200            $(wrapper).imagesLoaded(function() {
3201
3202              $(window).trigger('resize');
3203
3204              if( $('.mfn-query-pagination-infiniteload .next').length ){
3205                mfnQueryPaginationWaypoint = new Waypoint({
3206                  element: $('.mfn-query-pagination-infiniteload .next'),
3207                  handler: function(direction) {
3208                    $(this.element).trigger('click');
3209                  },
3210                  offset: '100%'
3211                })
3212
3213              }
3214
3215            });
3216          }
3217
3218        });
3219
3220      });
3221    }
3222
3223    /**
3224     * Load More | Ajax
3225     */
3226
3227    $(document).on('click', '.pager_load_more', function(e) {
3228      e.preventDefault();
3229
3230      var el = $(this);
3231      var pager = el.closest('.pager_lm');
3232
3233      var href = el.attr('href');
3234
3235      // index | for many items on the page
3236      var index = $('.content_wrapper .lm_wrapper').index( el.closest('.mcb-column-inner').find('.lm_wrapper') );
3237
3238      el.fadeOut(50);
3239      pager.addClass('loading');
3240
3241      $.get( href, function( data ) {
3242
3243        // content
3244
3245        // var content = $('.content_wrapper .lm_wrapper', data).html();
3246        // var $content = $(content);
3247
3248		    var content = $('.content_wrapper .lm_wrapper', data).eq(index).html();
3249        var $content;
3250
3251        if (content.indexOf('<') === -1) {
3252          $content = $('<div>').text(content);
3253        } else {
3254          $content = $(content);
3255        }
3256
3257        href = $('.content_wrapper .lm_wrapper:eq(' + index + ')', data).next().find('.pager_load_more').attr('href');
3258
3259        if ($('.content_wrapper .lm_wrapper:eq(' + index + ')').hasClass('isotope')) {
3260
3261          // isotope
3262
3263          const location = '.content_wrapper .lm_wrapper:eq(' + index + ')';
3264          $(location).append( $content );
3265
3266          mfnIsotope.queryIsotopeAPI(location, 'appended', $content);
3267          mfnIsotope.addIsotopeLocation({ name: 'Load More - Ajax', location });
3268
3269          if( $(location).find('.isotope-item').length ){
3270            $(location).imagesLoaded().progress(function() {
3271              $(location).isotope('reloadItems');
3272            });
3273          }
3274
3275        } else if ($('.content_wrapper .lm_wrapper:eq(' + index + ')').hasClass('mfn-woo-products')) {
3276
3277          // different .pager_load_more DOM location
3278          if (typeof href === 'undefined'){
3279            href = $('.content_wrapper .lm_wrapper:eq(' + index + ') .pager_load_more', data).attr('href');
3280          }
3281
3282          $('.content_wrapper .lm_wrapper:eq(' + index + ') ul.products').append( $content.html() );
3283
3284          var $listing = $('.content_wrapper .lm_wrapper:eq(' + index + ') ul.products.isotope');
3285
3286          if( $listing.length ){
3287            $listing.imagesLoaded().progress(function() {
3288              $listing.isotope('reloadItems');
3289            });
3290          }
3291
3292        } else {
3293          // default
3294          $content.hide().appendTo('.content_wrapper .lm_wrapper:eq(' + index + ')').fadeIn(1000);
3295        }
3296
3297        // next page link
3298
3299        pager.removeClass('loading');
3300        if (href) {
3301          el.fadeIn();
3302          el.attr('href', href);
3303        }
3304
3305        // refresh some staff
3306
3307        lightbox();
3308
3309        // isotope fix: second resize
3310
3311        if( $('.lm_wrapper.isotope').length ){
3312          $('.lm_wrapper.isotope').imagesLoaded().progress(function() {
3313            mfnIsotope.queryIsotopeAPI( '.lm_wrapper.isotope' );
3314          });
3315        }
3316
3317      });
3318
3319    });
3320
3321    /**
3322     * Filters | Blog & Portfolio
3323     */
3324
3325    $('.filters_buttons .open').on('click', function(e) {
3326      e.preventDefault();
3327      var type = $(this).closest('li').attr('class');
3328
3329      $('.filters_wrapper').show(200);
3330      $('.filters_wrapper ul.' + type).show(200);
3331      $('.filters_wrapper ul:not(.' + type + ')').hide();
3332    });
3333
3334    $('.filters_wrapper .close a').on('click', function(e) {
3335      e.preventDefault();
3336      $('.filters_wrapper').hide(200);
3337    });
3338
3339    /**
3340     * Portfolio List | Next v / Prev ^ buttons
3341     */
3342
3343    $('.portfolio_next_js').on('click', function(e) {
3344      e.preventDefault();
3345
3346      var item = $(this).closest('.portfolio-item').next();
3347
3348      if (item.length) {
3349        $('html, body').animate({
3350          scrollTop: item.offset().top - fixStickyHeaderH()
3351        }, 500);
3352      }
3353    });
3354
3355    $('.portfolio_prev_js').on('click', function(e) {
3356      e.preventDefault();
3357
3358      var item = $(this).closest('.portfolio-item').prev();
3359
3360      if (item.length) {
3361        $('html, body').animate({
3362          scrollTop: item.offset().top - fixStickyHeaderH()
3363        }, 500);
3364      }
3365    });
3366
3367    /**
3368     * Link | Smooth Scroll | .scroll
3369     */
3370
3371    $('body').on('click', '.scroll > a, a.scroll, .mcb-column.scroll a', function(e) {
3372
3373      // prevent default if link directs to the current page
3374
3375      // var urlL = location.href.replace(/\/#.*|#.*/, '');
3376      // var urlT = this.href.replace(/\/#.*|#.*/, ''); // remove also trailing slash
3377
3378      var urlL = location.href.replace(/#.*/, '');
3379      var urlT = this.href.replace(/#.*/, '');
3380
3381      if (urlL == urlT) {
3382        e.preventDefault();
3383      }
3384
3385      var hash = this.hash;
3386
3387      // offset
3388
3389      var headerFixedAbH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
3390      var tabsHeaderH = $(hash).siblings('.ui-tabs-nav').innerHeight() || 0;
3391
3392      var offset = headerFixedAbH + tabsHeaderH + adminBarH();
3393
3394      // table of contents
3395
3396      if( $(this).parents('.table_of_content').length ){
3397        offset += 30;
3398      }
3399
3400      // animate scroll
3401
3402      if (hash && $(hash).length) {
3403
3404        // do scroll
3405
3406        $('html, body').animate({
3407          scrollTop: $(hash).offset().top - offset - fixStickyHeaderH()
3408        }, 500);
3409      }
3410    });
3411
3412    /**
3413     * Tabs
3414     */
3415
3416    $('.jq-tabs').tabs();
3417
3418    /**
3419     * Fake tabs
3420     */
3421
3422    $('.fake-tabs > ul').on('click', 'a', function(e) {
3423      e.preventDefault();
3424
3425      var $li = $(this).closest('li');
3426
3427      var tab = $li.data('tab');
3428
3429      if( $li.hasClass('active') ){
3430        return;
3431      }
3432
3433      $li.addClass('active')
3434        .siblings().removeClass('active');
3435
3436      $('.tab-'+ tab ).addClass('active').attr('tabindex', 0)
3437        .siblings('.tab').removeClass('active').attr('tabindex', -1);
3438
3439      $(window).trigger('resize');
3440    });
3441
3442    /**
3443     * Toggle
3444     */
3445
3446    $('body').on('click', '.mfn-toggle .toggle-bar', function() {
3447
3448      var $parent = $(this).parent(),
3449        $toggle = $(this).closest('.mfn-toggle');
3450      var speed = 100;
3451
3452      if ( $parent.hasClass('active') ) {
3453
3454        if( $toggle.is('.mfn-toggle-open-all') ){
3455          return;
3456        }
3457
3458        $parent.removeClass('active')
3459          .children('.toggle-content').slideUp(speed);
3460
3461      } else {
3462
3463        $parent.addClass('active')
3464          .children('.toggle-content').slideDown(speed);
3465
3466        if( ! $toggle.is('.mfn-toggle-open-more') ){
3467          $parent.siblings().removeClass('active')
3468            .children('.toggle-content').slideUp(speed);
3469        }
3470
3471      }
3472
3473      setTimeout(function() {
3474        $(window).trigger('resize');
3475      }, speed);
3476
3477    });
3478
3479    /**
3480     * Accordion & FAQ
3481     */
3482
3483    $('.mfn-acc').each(function() {
3484      var el = $(this);
3485
3486      if (el.hasClass('openAll') || el.find('.wpb_toggle_title_active').length) {
3487
3488        // show all
3489        el.find('.question')
3490          .addClass('active')
3491          .children(".answer")
3492          .show();
3493
3494      } else {
3495
3496        // show one
3497        var activeTab = el.attr('data-active-tab');
3498        if (el.hasClass('open1st')) activeTab = 1;
3499
3500        if (activeTab) {
3501          el.find('.question').eq(activeTab - 1)
3502            .addClass('active')
3503            .children(".answer")
3504            .show();
3505        }
3506
3507      }
3508    });
3509
3510    $('.mfn-acc .question > .title').on('click', function() {
3511
3512      if ($(this).parent().hasClass('active')) {
3513
3514        $(this).parent().removeClass('active').children(".answer").slideToggle(100);
3515
3516      } else {
3517
3518        if (!$(this).closest('.mfn-acc').hasClass('toggle')) {
3519          $(this).parents(".mfn-acc").children().each(function() {
3520            if ($(this).hasClass('active')) {
3521              $(this).removeClass('active').children(".answer").slideToggle(100);
3522            }
3523          });
3524        }
3525        $(this).parent().addClass('active');
3526        $(this).next(".answer").slideToggle(100);
3527
3528      }
3529
3530      setTimeout(function() {
3531        $(window).trigger('resize');
3532      }, 50);
3533
3534    });
3535
3536    // Visual Composer | Accordion | Sidebar height
3537    $('.wpb_wrapper .vc_tta-panel-title').on('click', 'a', function() {
3538
3539      setTimeout(function() {
3540        $(window).trigger('resize');
3541      }, 50);
3542
3543    });
3544
3545    /**
3546     * Helper
3547     */
3548
3549    $('.helper .link.toggle').on('click', function(e) {
3550
3551      e.preventDefault();
3552
3553      var el = $(this);
3554      var id = el.attr('data-rel');
3555      var parent = el.closest('.helper');
3556
3557      if (el.hasClass('active')) {
3558
3559        el.removeClass('active');
3560        parent.find('.helper_content > .item-' + id).slideUp(200);
3561
3562        setTimeout(function() {
3563          parent.find('.helper_content > .item-' + id).removeClass('active');
3564        }, 200);
3565
3566      } else {
3567
3568        parent.find('.links > .link.active').removeClass('active');
3569        parent.find('.helper_content > .item.active').slideUp(200);
3570
3571        el.addClass('active');
3572        parent.find('.helper_content > .item-' + id).addClass('active').hide().slideDown(200);
3573
3574      }
3575
3576      setTimeout(function() {
3577        $(window).trigger('resize');
3578      }, 50);
3579
3580    });
3581
3582    /**
3583     * Love
3584     */
3585
3586    $(document).on('click', '.mfn-love', function(e) {
3587      e.preventDefault();
3588      var el = $(this);
3589
3590      if (el.hasClass('loved')) {
3591        return false;
3592      }
3593      el.addClass('loved');
3594
3595      var post = {
3596        action: 'mfn_love',
3597        post_id: el.attr('data-id')
3598      };
3599
3600      $.post(mfn.ajax, post, function(data) {
3601        el.find('.label').html(data);
3602      });
3603
3604      return false;
3605    });
3606
3607    /**
3608     * Go to top
3609     */
3610
3611    $('#back_to_top').on('click', function() {
3612      $('body,html').animate({
3613        scrollTop: 0
3614      }, 500);
3615      return false;
3616    });
3617
3618    /**
3619     * Section | Next v / Prev ^ navigation arrows
3620     */
3621
3622    $('.section .section-nav').on('click', function() {
3623
3624      var el = $(this);
3625      var section = el.closest('.section');
3626
3627      var offset = fixStickyHeaderH() + adminBarH();
3628
3629      if (el.hasClass('prev')) {
3630
3631        // Previous Section
3632        if (section.prev().length) {
3633          $('html, body').animate({
3634            scrollTop: section.prev().offset().top - offset
3635          }, 500);
3636        }
3637
3638      } else {
3639
3640        // Next Section
3641        if (section.next().length) {
3642          $('html, body').animate({
3643            scrollTop: section.next().offset().top - offset
3644          }, 500);
3645        }
3646
3647      }
3648    });
3649
3650    /**
3651     * Intro | Scroll v arrow
3652     */
3653
3654    $('#Intro .intro-next').on('click', function() {
3655      var intro = $(this).closest('#Intro');
3656
3657      if (intro.next().length) {
3658        $('html, body').animate({
3659          scrollTop: intro.next().offset().top - fixStickyHeaderH() - adminBarH()
3660        }, 500);
3661      }
3662    });
3663
3664    /**
3665     * Widget | Muffin Menu | Hover on click
3666     */
3667
3668    $('.widget_mfn_menu ul.submenus-click, .widget_mfn_menu ul.submenus-click-mobile').each(function() {
3669
3670      var el = $(this);
3671
3672      if( el.is('.submenus-click-mobile') && $(window).width() > 767 ){
3673        return;
3674      }
3675
3676      $('a', el).on('click', function(e) {
3677        var li = $(this).closest('li');
3678
3679        if (li.hasClass('hover') || !li.hasClass('menu-item-has-children')) {
3680          // link click
3681        } else {
3682          e.preventDefault();
3683          li.siblings('li').removeClass('hover')
3684            .find('li').removeClass('hover');
3685          $(this).closest('li').addClass('hover');
3686        }
3687
3688      });
3689
3690    });
3691
3692    /**
3693     * WooCommerce | Add to cart
3694     */
3695
3696    function addToCart() {
3697
3698      $('body').on('click', '.add_to_cart_button', function() {
3699        $(this)
3700          .closest('.product')
3701          .addClass('adding-to-cart')
3702          .removeClass('added-to-cart');
3703      });
3704
3705      $('body').on('added_to_cart', function() {
3706        $('.adding-to-cart')
3707          .removeClass('adding-to-cart')
3708          .addClass('added-to-cart');
3709      });
3710    }
3711    addToCart();
3712
3713    /**
3714     * WooCommerce | Rating click
3715     */
3716
3717    $('.woocommerce-product-rating').on('click', function(){
3718
3719      var el;
3720
3721      if( $('.product_tabs_wrapper.fake-tabs').length ){
3722
3723        el = $('.product_tabs_wrapper.fake-tabs');
3724        $('li[data-tab="reviews"] a', el).trigger('click');
3725
3726      } else if( $('.woocommerce-content .jq-tabs').length ){
3727
3728        el = $('.woocommerce-content .jq-tabs');
3729        $('.ui-tabs-nav a[href="#tab-reviews"]', el).trigger('click');
3730
3731      } else {
3732
3733        el = $('.woocommerce-content .accordion');
3734        $('#reviews').closest('.question:not(.active)').children('.title').trigger('click');
3735
3736      }
3737
3738      // offset
3739
3740      var actionBarH = $('.header-fixed.ab-show #Action_bar').innerHeight() || 0;
3741      var offset = actionBarH + adminBarH();
3742
3743      // animate scroll
3744
3745      $('html, body').animate({
3746        scrollTop: el.offset().top - offset - fixStickyHeaderH()
3747      }, 500);
3748
3749    });
3750
3751    /**
3752     * WooCommerce | Quantity change
3753     */
3754
3755    $('body').on('click', '.quantity-change', function(e){
3756
3757      e.preventDefault();
3758
3759      var $el = $(this),
3760        $input = $(this).siblings('input');
3761
3762      var step = parseFloat($input.attr('step')) || 1,
3763        minAttr = $input.attr('min'),
3764        min = typeof minAttr !== typeof undefined && minAttr !== false ? parseFloat(minAttr) : 1,
3765        max = parseFloat($input.attr('max')) || 9999,
3766        current = $input.val() ? parseFloat($input.val()) : min,
3767        val = 0;
3768
3769      if( $el.hasClass('plus') ){
3770        val = current + step;
3771        if( val > max ){
3772          val = current;
3773        }
3774      } else {
3775        val = current - step;
3776        if( val < min ){
3777          val = current;
3778        }
3779      }
3780
3781      val = Math.round(val * 10) / 10;
3782
3783      $input.val(val).trigger('change');
3784
3785    });
3786
3787    /**
3788     * Ajax | Complete
3789     */
3790
3791    $(document).ajaxComplete(function() {
3792
3793      setTimeout(function() {
3794        $(window).trigger('resize');
3795        mfnSidebar();
3796      }, 100);
3797
3798    });
3799
3800    /**
3801     * $(window).on('debouncedresize')
3802     * Specify a function to execute on window resize
3803     */
3804
3805    $(window).on('debouncedresize', function() {
3806
3807      // isotope
3808      mfnIsotope.runIsotopes( false );
3809
3810      // sliding footer height
3811
3812      mfnFooter();
3813
3814      // header width
3815
3816      headerWidth();
3817
3818      // sidebar height
3819
3820      mfnSidebar();
3821
3822      // intro header
3823
3824      mfnIntroH();
3825
3826      // mobile sticky for header creative
3827
3828      creativeHeaderFix();
3829
3830    });
3831
3832    /**
3833     * Bind()
3834     */
3835
3836    // consent
3837
3838    $('.mfn-cookies').on('click','.cookies-tab-nav a', function(e){
3839      e.preventDefault();
3840      consent.tabs($(this), false);
3841    });
3842
3843    $('.mfn-cookies').on('click','#consent_customize', function(e){
3844      e.preventDefault();
3845      consent.tabs(false, 'details');
3846    });
3847
3848    $('.mfn-cookies').on('click','#consent_allow', function(e){
3849      e.preventDefault();
3850      consent.all();
3851    });
3852
3853    $('.mfn-cookies').on('click','#consent_selected', function(e){
3854      e.preventDefault();
3855      consent.selected();
3856    });
3857
3858    $('.mfn-cookies').on('click','#consent_deny', function(e){
3859      e.preventDefault();
3860      consent.deny();
3861    });
3862
3863    $('.mfn-cookies-reopen').on('click', function(e){
3864      consent.reopen();
3865    });
3866
3867    /**
3868     * document.ready
3869     * Initialize document ready functions
3870     */
3871
3872    mfnSliderBlog();
3873    mfnSliderClients();
3874    mfnSliderOffer();
3875    mfnSliderOfferThumb();
3876    mfnSliderShop();
3877
3878    sliderPortfolio();
3879    sliderTestimonials();
3880
3881    // sliding footer height
3882
3883    mfnFooter();
3884
3885    // header width
3886
3887    headerWidth();
3888
3889    // sidebar height
3890
3891    mfnSidebar();
3892
3893    // intro header
3894
3895    mfnIntroH();
3896
3897    // hash navigation
3898
3899    hashNav();
3900
3901    // GDPR container display
3902
3903    gdpr(); // gdpr 1.0
3904    consent.open(); // gdpr 2.0
3905
3906    // table of contents
3907
3908    tableContentAttachId();
3909
3910    // top bar top position
3911
3912    topBarTopPosition();
3913
3914    if( !$('body').hasClass('mfn-ui') ) mfnPopup.init();
3915
3916  });
3917
3918  /**
3919   * $(window).on('scroll')
3920   * The scroll event is sent to an element when the user scrolls to a different place in the element.
3921   */
3922
3923  $(window).on('scroll', function() {
3924
3925    // sticky header
3926
3927    mfnSticky();
3928    mfnMobileSticky();
3929
3930    // sticky back to top
3931
3932    backToTopSticky();
3933
3934    // one page scroll active
3935
3936    onePageActive();
3937
3938  });
3939
3940  /**
3941   * $(window).on('load')
3942   * window.load
3943   */
3944
3945  $(window).on('load', function() {
3946
3947    preloader();
3948
3949    queryLoopMasonry();
3950
3951    // align divs heights
3952
3953    alignHeights();
3954
3955    /**
3956     * Elementor plugin
3957     * Disable built-in one page
3958     */
3959
3960    function elementorDisableOnePage(){
3961
3962      if( ! $('body').hasClass('one-page') ){
3963        return false;
3964      }
3965
3966      setTimeout(function(){
3967        var doc=$(document),
3968          $events=$("a[href*='#']").length ? $._data(doc[0],"events") : null;
3969        if($events && $events.click){
3970          for(var i=$events.click.length-1; i>=0; i--){
3971            var handler=$events.click[i];
3972            if(handler && handler.namespace != "mPS2id" && handler.selector === 'a[href*="#"]' ) doc.off("click",handler.handler);
3973          }
3974        }
3975      }, 300);
3976
3977    }
3978
3979    elementorDisableOnePage();
3980
3981    /**
3982     * Live search item
3983     * z-index for live search item parents
3984     */
3985
3986    function liveSearchItemZindex(){
3987
3988      $('.column_livesearch').each(function(){
3989        $(this).closest('.mcb-wrap').addClass('has-live-search-element')
3990          .closest('.mcb-section').addClass('has-live-search-element');
3991      });
3992
3993    }
3994
3995    liveSearchItemZindex();
3996
3997    /**
3998     * Retina Logo
3999     */
4000
4001    function retinaLogo() {
4002
4003      // ! retina display
4004
4005      if( window.devicePixelRatio <= 1 ){
4006        return false;
4007      }
4008
4009      var el, src, height,
4010        parent = $('#Top_bar #logo'),
4011        parentH = parent.data('height');
4012
4013      var maxH = {
4014        sticky: {
4015          init: 35,
4016          noPadding: 60,
4017          overflow: 110
4018        },
4019        mobile: {
4020          mini: 50,
4021          miniNoPadding: 60
4022        },
4023        mobileSticky: {
4024          init: 50,
4025          noPadding: 60,
4026          overflow: 80
4027        }
4028      };
4029
4030      $('#Top_bar #logo img').each(function(index) {
4031
4032        el = $(this);
4033        src = el.data('retina');
4034        height = el.height() || 0;
4035
4036        // main
4037
4038        if (el.hasClass('logo-main')) {
4039
4040          if ($('body').hasClass('logo-overflow')) {
4041
4042            // do nothing
4043
4044          } else if (height > parentH) {
4045
4046            height = parentH;
4047
4048          }
4049
4050        }
4051
4052        // sticky
4053
4054        if (el.hasClass('logo-sticky')) {
4055
4056          if ($('body').hasClass('logo-overflow')) {
4057
4058            if (height > maxH.sticky.overflow) {
4059              height = maxH.sticky.overflow;
4060            }
4061
4062          } else if ($('body').hasClass('logo-no-sticky-padding')) {
4063
4064            if (height > maxH.sticky.noPadding) {
4065              height = maxH.sticky.noPadding;
4066            }
4067
4068          } else if (height > maxH.sticky.init) {
4069
4070            height = maxH.sticky.init;
4071
4072          }
4073
4074        }
4075
4076        // mobile
4077
4078        if (el.hasClass('logo-mobile')) {
4079
4080          if ($('body').hasClass('mobile-header-mini')) {
4081
4082            if (parent.data('padding') > 0) {
4083
4084              if (height > maxH.mobile.mini) {
4085                height = maxH.mobile.mini;
4086              }
4087
4088            } else {
4089
4090              if (height > maxH.mobile.miniNoPadding) {
4091                height = maxH.mobile.miniNoPadding;
4092              }
4093
4094            }
4095
4096          }
4097
4098        }
4099
4100        // mobile-sticky
4101
4102        if (el.hasClass('logo-mobile-sticky')) {
4103
4104          if ($('body').hasClass('logo-no-sticky-padding')) {
4105
4106            if (height > maxH.mobileSticky.noPadding) {
4107              height = maxH.mobileSticky.noPadding;
4108            }
4109
4110          } else if (height > maxH.mobileSticky.init) {
4111            height = maxH.mobileSticky.init;
4112          }
4113
4114        }
4115
4116        // SET
4117
4118        if (src) {
4119          el.parent().addClass('retina');
4120          el.attr('src', src).css('max-height', height + 'px');
4121        }
4122
4123      });
4124
4125    }
4126
4127    setTimeout(function() {
4128      retinaLogo();
4129    }, 0); // jQuery 3.5 window.load
4130
4131    /**
4132     * Before After | TwentyTwenty
4133     */
4134
4135    $('#Wrapper .before_after.twentytwenty-container:not(.mfn-initialized)').each(function(){
4136
4137      var el = $(this);
4138
4139      el.addClass('mfn-initialized');
4140      el.imagesLoaded().done(function(instance, image){
4141
4142        queueMicrotask(() => el.twentytwenty());
4143
4144      });
4145
4146    });
4147
4148    // Visual Composer prettyPhoto | off
4149
4150    if ( lightboxAttr ) {
4151      $('a[data-rel^="prettyPhoto"]:not(.popup-link), a[rel^="lightbox"]:not(.popup-link)').each(function() {
4152        $(this).off('click.prettyphoto');
4153      });
4154    }
4155
4156    /**
4157     * Reload some functions on window.load
4158     */
4159
4160    // sticky header
4161
4162    mfnStickyH();
4163    mfnSticky();
4164    mfnMobileSticky();
4165
4166    // intro header
4167
4168    mfnIntroH();
4169
4170    // FIX | jQuery 3.5 window.load
4171
4172    setTimeout(function() {
4173
4174      // triger resize to recalculate some plugins stuff
4175      $(window).trigger('resize');
4176
4177      // sidebar height
4178
4179      mfnSidebar();
4180
4181      // sliders
4182
4183      sliderSlider();
4184
4185    }, 0);
4186
4187  });
4188
4189  /**
4190   * $(document).on('mouseup')
4191   * Specify a function to execute when the DOM is fully loaded.
4192   * Close some modals when click outside
4193   */
4194
4195  $(document).on('mouseup',function(e) {
4196
4197    // Widget | Muffin menu | Hover on click
4198
4199    if ($('.widget_mfn_menu ul.submenus-click').length && ($('.widget_mfn_menu ul.submenus-click').has(e.target).length === 0) ) {
4200      $('.widget_mfn_menu ul.submenus-click li').removeClass('hover');
4201    }
4202
4203    // Mobile menu | Classic
4204
4205    if ($('.menu_wrapper').length && ( $('.menu_wrapper').has(e.target).length === 0 )) {
4206      if( $('.responsive-menu-toggle').hasClass('active') ){
4207        $('.responsive-menu-toggle').trigger('click');
4208      }
4209    }
4210
4211    // Popup contact form
4212
4213    if ($('#popup_contact').length && ( $('#popup_contact').has(e.target).length === 0 )) {
4214      if( $('#popup_contact').hasClass('focus') ){
4215        $('#popup_contact .footer_button').trigger('click');
4216      }
4217    }
4218
4219    // Off canvas sidebar
4220
4221    if($('html').hasClass('mfn-ofcs-opened') && !$('.mfn-off-canvas-sidebar').is(e.target) && $('.mfn-off-canvas-sidebar').has(e.target).length === 0){
4222      $('html').removeClass('mfn-ofcs-opened');
4223    }
4224
4225  });
4226
4227  /**
4228   * Sliders configuration
4229   */
4230
4231  // Slick Slider | Auto responsive
4232
4233  function slickAutoResponsive(slider, max, size, round = false) {
4234
4235    if (!max){
4236      max = 5;
4237    }
4238    if (!size){
4239      size = 380;
4240    }
4241
4242    var width = slider.width() || 0;
4243    var count;
4244
4245    if ( round ) {
4246      count = Math.floor(width / size);
4247    } else {
4248      count = Math.ceil(width / size);
4249    }
4250
4251    if (count < 1) count = 1;
4252    if (count > max) count = max;
4253
4254    return count;
4255  }
4256
4257  // Slider | Offer Thumb
4258
4259  function mfnSliderOfferThumb() {
4260
4261    var pager = function(el, i) {
4262      var img = $(el.$slides[i]).find('.thumbnail:first').html();
4263      return '<a>' + img + '</a>';
4264    };
4265
4266    $('.offer_thumb_ul').each(function() {
4267
4268      var slider = $(this);
4269
4270      slider.slick({
4271        cssEase: 'ease-out',
4272        arrows: false,
4273        dots: true,
4274        infinite: true,
4275        touchThreshold: 10,
4276        speed: 300,
4277
4278        adaptiveHeight: true,
4279        appendDots: slider.siblings('.slider_pagination'),
4280        customPaging: pager,
4281
4282        rtl: rtl ? true : false,
4283        autoplay: mfn.slider.offer ? true : false,
4284        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
4285
4286        slidesToShow: 1,
4287        slidesToScroll: 1
4288      });
4289
4290      // ON | debouncedresize
4291
4292      $(window).on('debouncedresize', function() {
4293        // set slider min-height to thumbnails height
4294        var height = slider.siblings('.slider_pagination').height();
4295        slider.closest('.offer_thumb ').css('min-height',height);
4296      });
4297
4298    });
4299  }
4300
4301  // Slider | Offer
4302
4303  function mfnSliderOffer() {
4304    $('.offer_ul').each(function() {
4305
4306      var slider = $(this);
4307
4308      slider.slick({
4309        cssEase: 'ease-out',
4310        dots: false,
4311        infinite: true,
4312        touchThreshold: 10,
4313        speed: 300,
4314
4315        prevArrow: '<a class="slider_prev" href="#" aria-label="previous slide"><span class="button_icon"><i class="icon-up-open-big"></i></span></a>',
4316        nextArrow: '<a class="slider_next" href="#" aria-label="next slide"><span class="button_icon"><i class="icon-down-open-big"></i></span></a>',
4317
4318        adaptiveHeight: true,
4319        //customPaging 	: pager,
4320
4321        rtl: rtl ? true : false,
4322        autoplay: mfn.slider.offer ? true : false,
4323        autoplaySpeed: mfn.slider.offer ? mfn.slider.offer : 5000,
4324
4325        slidesToShow: 1,
4326        slidesToScroll: 1
4327      });
4328
4329      // Pagination | Show (css)
4330
4331      slider.siblings('.slider_pagination').addClass('show');
4332
4333      // Pager | Set slide number after change
4334
4335      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
4336        slider.siblings('.slider_pagination').find('.current').text(currentSlide + 1);
4337      });
4338
4339    });
4340  }
4341
4342  // Slider | Shop
4343
4344  function mfnSliderShop() {
4345
4346    var pager = function(el, i) {
4347      return '<a>' + i + '</a>';
4348    };
4349
4350    $('.shop_slider_ul').each(function() {
4351
4352      var slider = $(this);
4353      var slidesToShow = 4;
4354
4355      var count = slider.closest('.shop_slider').data('count');
4356      if (slidesToShow > count) {
4357        slidesToShow = count;
4358        if (slidesToShow < 1) {
4359          slidesToShow = 1;
4360        }
4361      }
4362
4363      slider.slick({
4364        cssEase: 'ease-out',
4365        dots: true,
4366        infinite: true,
4367        touchThreshold: 10,
4368        speed: 300,
4369
4370        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4371        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4372        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
4373
4374        appendDots: slider.siblings('.slider_pager'),
4375        customPaging: pager,
4376
4377        rtl: rtl ? true : false,
4378        autoplay: mfn.slider.shop ? true : false,
4379        autoplaySpeed: mfn.slider.shop ? mfn.slider.shop : 5000,
4380
4381        slidesToShow: slickAutoResponsive(slider, slidesToShow),
4382        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
4383      });
4384
4385      // ON | debouncedresize
4386
4387      $(window).on('debouncedresize', function() {
4388        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
4389        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
4390      });
4391
4392    });
4393  }
4394
4395  // Slider | Blog
4396
4397  function mfnSliderBlog() {
4398
4399    var pager = function(el, i) {
4400      return '<a>' + i + '</a>';
4401    };
4402
4403    $('.blog_slider_ul').each(function() {
4404
4405      var slider = $(this);
4406      var slidesToShow = 4;
4407
4408      var count = slider.closest('.blog_slider').data('count');
4409      var singlePostMode = slider.closest('.blog_slider').hasClass('single_post_mode');
4410
4411      if (slidesToShow > count) {
4412        slidesToShow = count;
4413        if (slidesToShow < 1) {
4414          slidesToShow = 1;
4415        }
4416      }
4417
4418      if (singlePostMode) {
4419        slidesToShow = 1;
4420      }
4421
4422      slider.slick({
4423        cssEase: 'ease-out',
4424        dots: true,
4425        infinite: true,
4426        touchThreshold: 10,
4427        speed: 300,
4428
4429        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4430        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4431        appendArrows: slider.siblings('.blog_slider_header').children('.slider_navigation'),
4432
4433        appendDots: slider.siblings('.slider_pager'),
4434        customPaging: pager,
4435
4436        rtl: rtl ? true : false,
4437        autoplay: mfn.slider.blog ? true : false,
4438        autoplaySpeed: mfn.slider.blog ? mfn.slider.blog : 5000,
4439
4440        slidesToShow: slickAutoResponsive(slider, slidesToShow),
4441        slidesToScroll: slickAutoResponsive(slider, slidesToShow)
4442      });
4443
4444      // On | debouncedresize
4445
4446      $(window).on('debouncedresize', function() {
4447        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, slidesToShow), false);
4448        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, slidesToShow), true);
4449      });
4450
4451    });
4452  }
4453
4454  // Slider | Clients
4455
4456  function mfnSliderClients() {
4457    $('.clients_slider_ul').each(function() {
4458
4459      var slider = $(this);
4460
4461      var clientsPerSlide = slider.closest('.clients_slider').attr('data-client-per-slide') ? parseInt(slider.closest('.clients_slider').attr('data-client-per-slide')) : 4;
4462      var navigationPosition = slider.closest('.clients_slider').attr('data-navigation-position') || false;
4463      var appendArrows = ( navigationPosition == 'content' ) ? slider : slider.siblings('.blog_slider_header').children('.slider_navigation');
4464      var size = 400;
4465
4466      var calc = () => slickAutoResponsive(slider, clientsPerSlide, size - (clientsPerSlide * 40), true);
4467      var calcScroll = calc;
4468      var slidesToScroll = slider.closest('.clients_slider').attr('data-sli
4468des-to-scroll') ? parseInt(slider.closest('.clients_slider').attr('data-slides-to-scroll')) : calc();
4469
4470      if( 1 === slidesToScroll ){
4471        calcScroll = () => slickAutoResponsive(slider, 1, size - (clientsPerSlide * 40), true);
4472      }
4473
4474      slider.slick({
4475        cssEase: 'ease-out',
4476        dots: false,
4477        infinite: true,
4478        touchThreshold: 10,
4479        speed: 300,
4480
4481        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4482        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4483        appendArrows: appendArrows,
4484
4485        rtl: rtl ? true : false,
4486        autoplay: mfn.slider.clients ? true : false,
4487        autoplaySpeed: mfn.slider.clients ? mfn.slider.clients : 5000,
4488
4489        slidesToShow: calc(),
4490        slidesToScroll: calcScroll()
4491      });
4492
4493      // ON | debouncedresize
4494
4495      $(window).on('debouncedresize', function() {
4496        slider.slick('slickSetOption', 'slidesToShow', calc(), false);
4497        slider.slick('slickSetOption', 'slidesToScroll', calcScroll(), true);
4498      });
4499
4500    });
4501  }
4502
4503  // Slider | Portfolio
4504
4505  function sliderPortfolio() {
4506
4507    $('.portfolio_slider_ul').each(function() {
4508
4509      var slider = $(this);
4510      var size = 380;
4511      var scroll = 5;
4512
4513      if (slider.closest('.portfolio_slider').data('size')) {
4514        size = slider.closest('.portfolio_slider').data('size');
4515      }
4516
4517      if (slider.closest('.portfolio_slider').data('size')) {
4518        scroll = slider.closest('.portfolio_slider').data('scroll');
4519      }
4520
4521      slider.slick({
4522        cssEase: 'ease-out',
4523        dots: false,
4524        infinite: true,
4525        touchThreshold: 10,
4526        speed: 300,
4527
4528        prevArrow: '<a class="slider_nav slider_prev themebg" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4529        nextArrow: '<a class="slider_nav slider_next themebg" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4530
4531        rtl: rtl ? true : false,
4532        autoplay: mfn.slider.portfolio ? true : false,
4533        autoplaySpeed: mfn.slider.portfolio ? mfn.slider.portfolio : 5000,
4534
4535        slidesToShow: slickAutoResponsive(slider, 5, size),
4536        slidesToScroll: slickAutoResponsive(slider, scroll, size)
4537      });
4538
4539      // ON | debouncedresize
4540      $(window).on('debouncedresize', function() {
4541        slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider, 5, size), false);
4542        slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider, scroll, size), true);
4543      });
4544
4545    });
4546  }
4547
4548  // header promo bar | Slider
4549
4550  function promoBarSlider() {
4551    $('.promo_bar_slider').each(function() {
4552      var $slider = $(this);
4553
4554      if ($slider.hasClass('mfn-initialized')) return;
4555      $slider.addClass('mfn-initialized');
4556
4557      var speedAttr = $slider.attr('data-speed');
4558      var speed = parseInt(speedAttr, 10);
4559      if (isNaN(speed) || speed <= 0) speed = 5;
4560      speed *= 1000;
4561
4562      var $slides = $slider.find('.pbs_one');
4563      if (!$slides.length) return;
4564
4565      $slides.removeClass('pbs-active pbs-active-ends');
4566      $slides.first().addClass('pbs-active');
4567
4568      var transitionDuration = 300;
4569
4570      function changeSlide() {
4571        var $current = $slider.find('.pbs_one.pbs-active');
4572        var $next = $current.next('.pbs_one');
4573
4574        if (!$next.length) $next = $slides.first();
4575
4576        $current.addClass('pbs-active-ends');
4577
4578        setTimeout(function() {
4579          $current.removeClass('pbs-active pbs-active-ends');
4580          $next.addClass('pbs-active');
4581        }, transitionDuration);
4582      }
4583
4584      if ($slides.length > 1) {
4585        setInterval(changeSlide, speed);
4586      }
4587    });
4588  }
4589
4590
4591
4592  // section slider
4593
4594  function queryLoopSlider() {
4595    $('body:not(.mfn-ui) .mfn-looped-items-slider').each(function(i) {
4596
4597      const swipers = [];
4598
4599      var $slider = $(this);
4600
4601      let swiperClass = 'mfn-ql-slider-'+i;
4602
4603      $slider.addClass(swiperClass);
4604
4605      var swiperParams = {
4606        spaceBetween: parseInt($slider.attr('data-space_mobile')),
4607        slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-mobile')),
4608      };
4609
4610      if( typeof $slider.attr('data-dots') !== 'undefined' && $slider.attr('data-dots') == '1' ) {
4611        $slider.parent().append('<div class="swiper-pagination mfn-swiper-pagination-'+i+'"></div>');
4612        swiperParams['pagination'] = {
4613          el: ".mfn-swiper-pagination-"+i,
4614          clickable: true,
4615        };
4616
4617        if( $slider.attr('data-dots-count') == 'dynamic' ) {
4618          swiperParams['pagination']['dynamicBullets'] = true;
4619        }
4620      }
4621
4622      if( $slider.closest('.mfn-looped-items').hasClass('mfn-ql-slider-wrapper-offset') && $slider.attr('data-infinity') == '1' ) {
4623        swiperParams['loop'] = true;
4624        swiperParams['centeredSlides'] = true;
4625        $slider.parent().css({ 'max-width': '100%'});
4626      }else if( $slider.attr('data-infinity') == '1' ) {
4627        swiperParams['loop'] = true;
4628      }
4629
4630      /*if( $slider.attr('data-pausehover') == '1' ) {
4631
4632      }*/
4633
4634      swiperParams['speed'] = parseFloat($slider.attr('data-speed'));
4635
4636      if( $slider.attr('data-arrows') == '1' ){
4637        $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>');
4638        swiperParams['navigation'] = {
4639          nextEl: ".mfn-swiper-button-next-"+i,
4640          prevEl: ".mfn-swiper-button-prev-"+i,
4641        };
4642      }
4643
4644      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-autoplay') !== 'undefined' && parseFloat($slider.attr('data-autoplay')) > 0 ) {
4645        swiperParams['autoplay'] = {
4646          delay: $slider.hasClass('mfn-slider-linear') ? 0.1 : parseFloat($slider.attr('data-autoplay')),
4647          disableOnInteraction: true,
4648        };
4649
4650        if( $slider.attr('data-pausehover') == '1' ){
4651          // swiperParams['autoplay']['disableOnInteraction'] = true;
4652          swiperParams['autoplay']['pauseOnMouseEnter'] = true;
4653        }else{
4654          // swiperParams['autoplay']['disableOnInteraction'] = false;
4655          swiperParams['autoplay']['pauseOnMouseEnter'] = false;
4656        }
4657      }
4658
4659      if( !$('body').hasClass('mfn-ui') && typeof $slider.attr('data-mousewheel') !== 'undefined' && $slider.attr('data-mousewheel') > 0 ) {
4660        swiperParams['mousewheel'] = true;
4661      }
4662
4663      if( $('body').hasClass('mfn-ui') ) {
4664        swiperParams['allowTouchMove'] = true;
4665      }
4666
4667      // popup fix
4668      if( $slider.closest('.mfn-popup-tmpl').length ){
4669        swiperParams['observer'] = true;
4670        swiperParams['observeParents'] = true;
4671      }
4672
4673      swiperParams['breakpoints'] = {
4674        768: {
4675          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4676          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-tablet'))
4677        },
4678        960: {
4679          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4680          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns-laptop'))
4681        },
4682        1441: {
4683          spaceBetween: $slider.attr('data-animationtype') == 'cube' ? 0 : parseInt($slider.attr('data-space_desktop')),
4684          slidesPerView: $slider.hasClass('mfn-slider-linear') ? 'auto' : parseInt($slider.attr('data-columns'))
4685        }
4686      };
4687
4688      if( $slider.attr('data-animationtype') != 'slide' ) {
4689        swiperParams['effect'] = $slider.attr('data-animationtype');
4690        swiperParams['grabCursor'] = true;
4691
4692         if( $slider.attr('data-animationtype') == 'fade' ) {
4693          swiperParams['fadeEffect'] = { crossFade: true };
4694          swiperParams['centeredSlides'] = true;
4695         }
4696
4697      }
4698
4699      if( $slider.attr('data-autoheight') == '1' ) {
4700        swiperParams['autoHeight'] = true;
4701      }
4702
4703      swipers[i] = new Swiper('.'+swiperClass, swiperParams);
4704
4705      swipers[i].on('slideChange', function () {
4706        $(window).trigger('scroll');
4707      });
4708
4709      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') ) {
4710        let sw_arr_wi = $slider.closest('.mfn-looped-items-slider-wrapper').find('.mfn-swiper-arrow').outerWidth()+'px';
4711        $('body').append('<style>.mfn-ql-slider-'+i+'{ --mfn-swiper-arrow-width: '+sw_arr_wi+' }</style>')
4712        $(window).trigger('resize');
4713      }
4714
4715    });
4716  }
4717
4718  // Slider | Slider
4719
4720  function sliderSlider() {
4721
4722    var pager = function(el, i) {
4723      return '<a>' + i + '</a>';
4724    };
4725
4726    $('.content_slider_ul').each(function() {
4727
4728      var slider = $(this);
4729      var count = 1;
4730      var centerMode = false;
4731
4732      if (slider.closest('.content_slider').hasClass('carousel')) {
4733        count = slickAutoResponsive(slider);
4734
4735        $(window).on('debouncedresize', function() {
4736          slider.slick('slickSetOption', 'slidesToShow', slickAutoResponsive(slider), false);
4737          slider.slick('slickSetOption', 'slidesToScroll', slickAutoResponsive(slider), true);
4738        });
4739      }
4740
4741      if (slider.closest('.content_slider').hasClass('center')) {
4742        centerMode = true;
4743      }
4744
4745      slider.slick({
4746        cssEase: 'cubic-bezier(.4,0,.2,1)',
4747        dots: true,
4748        infinite: true,
4749        touchThreshold: 10,
4750        speed: 300,
4751
4752        centerMode: centerMode,
4753        centerPadding: '20%',
4754
4755        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4756        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4757
4758        adaptiveHeight: true,
4759        appendDots: slider.siblings('.slider_pager'),
4760        customPaging: pager,
4761
4762        rtl: rtl ? true : false,
4763        autoplay: mfn.slider.slider ? true : false,
4764        autoplaySpeed: mfn.slider.slider ? mfn.slider.slider : 5000,
4765
4766        slidesToShow: count,
4767        slidesToScroll: count
4768      });
4769
4770      // Lightbox | disable on dragstart
4771
4772      var clickEvent = false;
4773
4774      slider.on('dragstart', '.slick-slide a[rel="lightbox"]', function(event) {
4775        if (lightboxAttr) {
4776          var events = $._data(this,'events');
4777          if( events && Object.prototype.hasOwnProperty.call(events, 'click') ) {
4778            clickEvent = events.click[0];
4779            $(this).addClass('off-click').off('click');
4780          }
4781        }
4782      });
4783
4784      // Lightbox | enable after change
4785
4786      slider.on('afterChange', function(event, slick, currentSlide, nextSlide) {
4787        if (lightboxAttr) {
4788          $('a.off-click[rel="lightbox"]', slider).removeClass('off-click').on('click', clickEvent);
4789        }
4790      });
4791
4792    });
4793  }
4794
4795  // Slider | Testimonials
4796
4797  function sliderTestimonials() {
4798
4799    var pager = function(el, i) {
4800      var img = $(el.$slides[i]).find('.single-photo-img').html();
4801      return '<a>' + img + '</a>';
4802    };
4803
4804    $('.testimonials_slider_ul').each(function() {
4805
4806      var slider = $(this);
4807
4808      slider.slick({
4809        cssEase: 'ease-out',
4810        dots: true,
4811        infinite: true,
4812        touchThreshold: 10,
4813        speed: 300,
4814
4815        prevArrow: '<a class="button the-icon slider_prev" href="#" aria-label="previous slide"><i class="icon-left-open-big"></i></a>',
4816        nextArrow: '<a class="button the-icon slider_next" href="#" aria-label="next slide"><i class="icon-right-open-big"></i></a>',
4817
4818        adaptiveHeight: true,
4819        appendDots: slider.siblings('.slider_pager'),
4820        customPaging: pager,
4821
4822        rtl: rtl ? true : false,
4823        autoplay: mfn.slider.testimonials ? true : false,
4824        autoplaySpeed: mfn.slider.testimonials ? mfn.slider.testimonials : 5000,
4825
4826        slidesToShow: 1,
4827        slidesToScroll: 1
4828      });
4829
4830    });
4831  }
4832
4833  /**
4834   *
4835   * Tabber
4836   *
4837   * */
4838
4839  let mfnTabber = {
4840    init: function() {
4841
4842      $(document).on('mouseover', '.mfn-tabber-open-on-hover .mfn-tabber-nav li a', function(e) {
4843
4844        if( !$(this).parent('li').hasClass('active') ) {
4845
4846          let tab = $(this).attr('data-tab');
4847
4848          $(this).parent('li').siblings('li').removeClass('active');
4849          $(this).closest('.mfn-section-tabber').find('.mfn-tabber-content.active').removeClass('active');
4850
4851          $(this).parent('li').addClass('active');
4852          $(this).closest('.mfn-section-tabber').find(tab).addClass('active');
4853
4854          $(document).trigger('mfn:tabber:open');
4855          $(window).trigger('resize');
4856
4857        }
4858
4859      }).on('click', '.mfn-tabber-nav li a', function(e) {
4860
4861        if( !$(this).parent('li').hasClass('active') ) {
4862          e.preventDefault();
4863          let tab = $(this).attr('data-tab');
4864
4865          $(this).parent('li').siblings('li').removeClass('active');
4866          $(this).closest('.mfn-section-tabber').find('.mfn-tabber-content.active').removeClass('active');
4867
4868          $(this).parent('li').addClass('active');
4869          $(this).closest('.mfn-section-tabber').find(tab).addClass('active');
4870
4871          $(document).trigger('mfn:tabber:open');
4872          $(window).trigger('resize');
4873
4874        }else if( $(this).attr('href') == '#' || $('body').hasClass('mfn-ui') ) {
4875          e.preventDefault();
4876        }
4877
4878      });
4879
4880      if( $('body').hasClass('mfn-ui') ){
4881        setTimeout(mfnTabber.sliding_bg, 800); // must have
4882      }else{
4883        setTimeout(mfnTabber.sliding_bg, 300); // must have
4884      }
4885
4886    },
4887
4888    sliding_bg: function() {
4889
4890      if( !$('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding').length ) return;
4891
4892      $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding').each(function() {
4893        let wrapper = $(this);
4894        let li = wrapper.find('li.active');
4895        let helper = wrapper.find('.mfn-tabber-nav-slide-helper');
4896
4897        let offset_left = li.position().left;
4898        let offset_top = li.position().top;
4899
4900        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4901
4902      });
4903
4904      $('.mfn-tabber-open-on-click .mfn-tabber-nav.mfn-tabber-nav-hover-sliding li').on('click', function() {
4905        let li = $(this);
4906        let helper = li.closest('ul').find('.mfn-tabber-nav-slide-helper');
4907
4908        let offset_left = li.position().left;
4909        let offset_top = li.position().top;
4910
4911        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4912      });
4913
4914      $('.mfn-tabber-open-on-hover .mfn-tabber-nav.mfn-tabber-nav-hover-sliding li').on('mouseover', function() {
4915        let li = $(this);
4916        let helper = li.closest('ul').find('.mfn-tabber-nav-slide-helper');
4917
4918        let offset_left = li.position().left;
4919        let offset_top = li.position().top;
4920
4921        helper.css({ top: offset_top, left: offset_left, width: li.outerWidth(), height: li.outerHeight() });
4922      });
4923
4924      if( $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding li.active').length ){
4925
4926        $('.mfn-tabber-nav.mfn-tabber-nav-hover-sliding li.active')
4927
4928      }
4929
4930    }
4931
4932  }
4933
4934  /**
4935   *
4936   * Filters
4937   *
4938   * */
4939
4940  let mfnAdvancedFilters = {
4941    form: false,
4942    init: function() {
4943      if( !$('.mfn-advanced-filters').length ) return;
4944
4945      this.prepare();
4946
4947      $(document).on('click', '.mfn-advanced-filters .mfn-advanced-filters-expand', function(e) {
4948        e.preventDefault();
4949
4950        if( $(this).hasClass('mfn-expanded') ){
4951          $(this).removeClass('mfn-expanded');
4952          $(this).text($(this).attr('data-more'));
4953          $(this).closest('.mfn-form-row-wrapper').find('li.mfn-opt-expandable').addClass('mfn-opt-hidden').removeClass('mfn-opt-expandable');
4954        }else{
4955          $(this).addClass('mfn-expanded');
4956          $(this).text($(this).attr('data-less'));
4957          $(this).closest('.mfn-form-row-wrapper').find('li.mfn-opt-hidden').removeClass('mfn-opt-hidden').addClass('mfn-opt-expandable');
4958        }
4959      });
4960
4961      $(document).on('click', '.mfn-advanced-filters-accordion .mfn-advanced-filters-group-label', function(e) {
4962        e.preventDefault();
4963        let row = $(this).closest('.mfn-form-row');
4964        if( row.hasClass('open') ){
4965          row.removeClass('open');
4966          $(this).siblings('.mfn-form-row-wrapper').slideUp(300);
4967        }else{
4968          row.addClass('open');
4969          $(this).siblings('.mfn-form-row-wrapper').slideDown(300);
4970        }
4971
4972      })
4973
4974      if( $('.mfn-advanced-filters .mfn-advanced-filters-rate') ){
4975        $(document).on('click', '.mfn-advanced-filters .mfn-advanced-filters-rate li', function() {
4976          $(this).toggleClass('active');
4977
4978          let helper_arr = [];
4979
4980          $(this).closest('.mfn-advanced-filters-rate').find('li.active').each(function(el) {
4981            helper_arr.push($(this).attr('data-rate'));
4982          });
4983
4984          $(this).closest('.mfn-advanced-filters-rate').find('.mfn-advanced-rate-input').val(helper_arr.join(',')).trigger('change');
4985
4986        });
4987      }
4988
4989      $(document).on('change', 'form.mfn-active-filters input', function(e) {
4990        mfnAdvancedFilters.ajax($(this).closest('form'));
4991      });
4992
4993      $(document).on('change', 'form.mfn-advanced-filters-auto-submit input, form.mfn-advanced-filters-auto-submit select', function(e) {
4994        mfnAdvancedFilters.ajax($(this).closest('form'));
4995      }).on('submit', 'form.mfn-advanced-filters-auto-submit', function(e) {
4996        e.preventDefault();
4997        mfnAdvancedFilters.ajax($(this));
4998      });
4999
5000      $(document).on('submit', 'form.mfn-advanced-filters-ajax-submit', function(e) {
5001        e.preventDefault();
5002        mfnAdvancedFilters.ajax($(this));
5003      });
5004
5005      $(document).on('click', '.mfn-active-filters .mfn-reset-filters', function(e) {
5006        e.preventDefault();
5007        $(this).closest('form').empty();
5008        mfnAdvancedFilters.ajax($(this).closest('form'));
5009      });
5010
5011    },
5012
5013    prepare: function() {
5014
5015      if( $('.mfn-active-filters .mfn-active-filters-find-title').length ) {
5016        $('.mfn-active-filters .mfn-active-filters-find-title:not(.initialized)').each(function(i, el) {
5017
5018          $(el).addClass('initialized');
5019
5020          let selector = '[name="'+$(el).find('input').attr('name')+'"]';
5021          let searched_input = $('.mfn-advanced-filters '+selector);
5022          if( $(el).find('input').val().length ) {
5023
5024            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() : '';
5025
5026            if( typeof searched_input.attr('placeholder') != 'undefined' && searched_input.closest('.mfn-floating-placeholder').length ) {
5027              if( label.length ) $(el).append(label+' ');
5028              $(el).append(searched_input.attr('placeholder')+': '+$(el).find('input').val());
5029            }else if( searched_input.hasClass('mfn-advanced-rate-input') && label.length ) {
5030              if( label.length ) $(el).append(label+': ');
5031              $(el).append($(el).find('input').val());
5032            }else{
5033              $(el).append(searched_input.closest('.mfn-form-row').find('.mfn-advanced-filters-group-label h4').first().text()+': '+$(el).find('input').val());
5034            }
5035
5036          }else{
5037            $(el).remove();
5038          }
5039        });
5040      }
5041
5042      $('.mfn-advanced-filters:not(.initialized)').each(function(i, el) {
5043        mfnAdvancedFilters.form = $(el);
5044        mfnAdvancedFilters.form.addClass('initialized');
5045
5046        if( mfnAdvancedFilters.form.find('.mfn-advanced-filters-slider').length ){
5047          mfnAdvancedFilters.slider();
5048        }
5049
5050        if( mfnAdvancedFilters.form.find('.mfn-advanced-filters-range-slider').length ){
5051          mfnAdvancedFilters.slider_range();
5052        }
5053      });
5054    },
5055
5056    ajax: ($form) => {
5057
5058      var url    = $form.attr('action') || location.origin + location.pathname;
5059      var method = ($form.attr('method') || 'GET').toUpperCase();
5060      var data   = $form.serialize();
5061
5062      if( $form.closest('.mfn-sidemenu-tmpl.mfn-sidemenu-active').length ) {
5063        $form.closest('.mfn-sidemenu-tmpl.mfn-sidemenu-active').find('.mfn-sidemenu-closebutton').trigger('click');
5064      }
5065
5066      // UX: spinner/wyłączenie pól (opcjonalnie)
5067      var $content = $('#Content');
5068      $content.addClass('is-loading'); // zrób w CSS np. półprzezroczystość
5069      $form.find('input,select,button').prop('disabled', true);
5070      $form.find('button.mfn-btn').addClass('loading disabled');
5071
5072      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();
5073      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();
5074      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();
5075
5076      $.ajax({
5077        url: url,
5078        type: method,
5079        data: data,
5080        dataType: 'html'
5081      }).done(function(html){
5082        var $html  = $('<div>').append($.parseHTML(html));
5083        var $newContent = $html.find('#Content');
5084
5085        if ($newContent.length) {
5086          $content.replaceWith($newContent);
5087
5088          if( $('.mfn-sidemenu-tmpl').length ) {
5089            $('.mfn-sidemenu-tmpl').each(function() {
5090              let id = $(this).attr('id');
5091              $(this).replaceWith($html.find('#'+id));
5092            });
5093          }
5094
5095          if (method === 'GET') {
5096            var newUrl = url + (url.indexOf('?')>-1 ? '&' : '?') + data;
5097            window.history.replaceState({}, '', newUrl);
5098          }
5099        } else {
5100          window.location.href = method==='GET' ? (url + (url.indexOf('?')>-1?'&':'?') + data) : url;
5101        }
5102      }).fail(function(){
5103        window.location.href = method==='GET' ? (url + (url.indexOf('?')>-1?'&':'?') + data) : url;
5104      }).always(function(){
5105        $form.find('input,select,button').prop('disabled', false);
5106        $('#Content').removeClass('is-loading');
5107        $form.find('button.mfn-btn').removeClass('loading disabled');
5108
5109        $(document).trigger('mfn:ajax:refresh');
5110      });
5111    },
5112
5113    slider: function() {
5114      mfnAdvancedFilters.form.find('.mfn-advanced-filters-slider').each(function(i, slider) {
5115
5116        let input = $(this).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input');
5117
5118        let min = input.attr('min').length ? input.attr('min') : '0';
5119        let max = input.attr('max').length ? input.attr('max') : '500';
5120
5121        let val = input.val().length ? input.val() : '';
5122
5123        $(this).slider({
5124          step: 1,
5125          min: parseFloat(min),
5126          max: parseFloat(max),
5127          range: "min",
5128          value: val,
5129          create: function () {
5130            $(this).find(".ui-slider-handle").append('<span class="mfn-ui-tip"></span>');
5131            $(this).find(".mfn-ui-tip").text($(this).slider("value"));
5132          },
5133          slide: function( event, ui ) {
5134            input.val(ui.value);
5135            if( !input.parent('.mfn-input-wrapper').hasClass('mfn-not-empty') ) input.parent('.mfn-input-wrapper').addClass('mfn-not-empty');
5136            $(this).find(".mfn-ui-tip").text(ui.value);
5137          },
5138          stop: function() {
5139            input.trigger('change');
5140          }
5141        });
5142
5143      });
5144    },
5145
5146    slider_range: function() {
5147      mfnAdvancedFilters.form.find('.mfn-advanced-filters-range-slider').each(function(i, slider) {
5148
5149        let input_min = $(this).closest('.mfn-advanced-filters-slider-wrapper').find('input.mfn-ui-slider-input-min');
5150        let input_max = $(this).closest('.mfn-advanced-filters-slider-wrapper').find('input.mfn-ui-slider-input-max');
5151
5152        let min = typeof input_min.attr('min') != 'undefined' ? input_min.attr('min') : '0';
5153        let max = typeof input_max.attr('max') != 'undefined' ? input_max.attr('max') : '500';
5154
5155        let val_min = input_min.val().length ? input_min.val() : min;
5156        let val_max = input_max.val().length ? input_max.val() : max;
5157
5158        $(this).slider({
5159          range: true,
5160          step: 1,
5161          min: parseFloat(min),
5162          max: parseFloat(max),
5163          values: [ parseFloat(val_min), parseFloat(val_max) ],
5164          create: function (event, ui) {
5165            $(this).find(".ui-slider-handle").append('<span class="mfn-ui-tip"></span>');
5166            $(this).find(".mfn-ui-tip").first().text(val_min);
5167            $(this).find(".mfn-ui-tip").last().text(val_max);
5168          },
5169          slide: function( event, ui ) {
5170            $(ui.handle).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input-min').val(ui.values[ 0 ]);
5171            $(ui.handle).closest('.mfn-form-row-wrapper').find('input.mfn-ui-slider-input-max').val(ui.values[ 1 ]);
5172
5173            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');
5174
5175            $(ui.handle).find(".mfn-ui-tip").text(ui.value);
5176          },
5177          stop: function() {
5178            input_min.trigger('change');
5179          }
5180        });
5181
5182      });
5183    }
5184  }
5185
5186  /**
5187   * GDPR
5188   */
5189
5190  // GDPR | Close notice on click | BIND
5191
5192  $(document).on('click', '.mfn-gdpr-button', function(){
5193    var closeAnimation = $('.mfn-gdpr-button').attr('data-animation');
5194    var barAligment = $('#mfn-gdpr').attr('data-aligment');
5195
5196    switch(true){
5197      case 'none' === closeAnimation:
5198        $('#mfn-gdpr').css('display', 'none');
5199        break;
5200      case 'fade' === closeAnimation:
5201        $('#mfn-gdpr').fadeOut(300);
5202        break;
5203      case 'slide' === closeAnimation && 'top' === barAligment:
5204        $('#mfn-gdpr').slideUp(300);
5205        break;
5206      default:
5207        $('#mfn-gdpr').slideToggle(300);
5208        break;
5209    }
5210
5211    // wait for animation end, then remove clasa and set cookies
5212    setTimeout(function(){
5213      $('#mfn-gdpr').removeClass('show');
5214      gdpr_set_cookie();
5215    }, 300);
5216  });
5217
5218  // GDPR | Set the cookie
5219
5220  function gdpr_set_cookie(){
5221    if(navigator.cookieEnabled) {
5222      var cookieDays = $('.mfn-gdpr-button').attr('data-cookiedays') || 365;
5223      var cookieDate = new Date();
5224      var cookieText = '';
5225
5226      cookieDate.setTime(cookieDate.getTime() + (cookieDays * 24 * 60 * 60 * 1000));
5227      cookieText += "mfn-gdpr=1";
5228      cookieText += "; expires=" + cookieDate.toUTCString() + ';';
5229      cookieText += "; path=" + mfn.home_url + '/';
5230
5231      document.cookie = cookieText;
5232    }
5233  }
5234
5235  // GDPR | Display, if cookie not accepted
5236
5237  function gdpr(){
5238    if (document.cookie !== "") {
5239      var cookies = document.cookie.split(/; */);
5240
5241      for (var cookie of cookies) {
5242        var [ cookieName ] = cookie.split("=");
5243
5244        if (cookieName === 'mfn-gdpr') {
5245          return; // cookie exists
5246        }
5247      }
5248    }
5249
5250    $('#mfn-gdpr').addClass('show'); //cookie does NOT exist
5251  }
5252
5253  /*
5254   * Infinite scroll functionality
5255   */
5256
5257  function infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection){
5258
5259    // for proper check, if we need to fetch posts again.
5260    var screenHeight = document.body.clientHeight;
5261
5262    if ( infiniteLoadContainer.attr('data-attr') === $(infiniteLoadButton).attr('href') ) {
5263      return; // it means, that maximum length of pages is crossed
5264    } else if (scrollDirection === 'down') {
5265
5266      // attach link for check, and click the load more button!
5267      infiniteLoadContainer.attr('data-attr', $(infiniteLoadButton).attr('href'));
5268      infiniteLoadButton.click();
5269
5270      // prevention, when height did not change enought, load again
5271      setTimeout(function(){
5272        var heightAfterLoadDifference = (document.body.clientHeight - screenHeight);
5273
5274        if( heightAfterLoadDifference < 249 ) {
5275          infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, scrollDirection);
5276        }
5277      }, 500);
5278
5279    }
5280  }
5281
5282/*  function infiniteScrollPortfolio(){
5283    var infiniteLoadContainer = $('.mfn-infinite-load-button');
5284    var infiniteLoadButton = $('.mfn-infinite-load-button a');
5285
5286    $(infiniteLoadContainer).waypoint({
5287      handler: function(direction) {
5288        infiniteScrollFunction(infiniteLoadContainer, infiniteLoadButton, direction);
5289      },
5290      offset: function(){
5291        //after each load, calc the offset of element to know when posts should be loaded
5292        var offsetPosition = - ( ($(this)[0].element.scrollHeight) - (window.innerHeight / 1.2) );
5293        return offsetPosition;
5294      }
5295    });
5296
5297
5298  } */
5299
5300  /*
5301   * Table of Contents | toc
5302   */
5303
5304  $('body').on('click', ".table_of_content .toggle", function(e){
5305
5306    e.preventDefault();
5307
5308    if( $('.table_of_content').hasClass('hide') ){
5309
5310      $('.table_of_content').removeClass('hide');
5311
5312      $('.table_of_content_wrapper').slideDown( {
5313        duration: 400,
5314        always: function(){
5315          $('.table_of_content').removeClass('hide_on_start');
5316        }
5317      });
5318
5319    } else {
5320
5321      $('.table_of_content_wrapper').slideUp( {
5322        duration: 400
5323      });
5324
5325      $('.table_of_content').addClass('hide');
5326
5327    }
5328
5329  });
5330
5331  function tableContentAttachId(){
5332    const container = $('.table_of_content');
5333    let tags;
5334    let anchorNumber = 0;
5335    let anchorDom = $('.table_of_content_wrapper').find('a');
5336
5337
5338    if(tags = container.attr('data-tags')){
5339      tags = tags.split(/[ ,]+/).join(','); //remove spaces, add commas
5340
5341      // muffin builder, gutenberg, elementor
5342      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)');
5343
5344      if( $('#Content .mfn-single-post-tmpl-builder .column_post_content').length ){
5345        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)');
5346      }else if( $('#Content .mfn-single-portfolio-tmpl-builder .column_post_content').length ){
5347        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)');
5348      }
5349
5350
5351      $(columns).each( ( index, element ) => {
5352        let headingsNoticed = $(element).find(tags); //look for headings
5353
5354        $(headingsNoticed).each( ( index, element ) => {
5355
5356          if( $(element).attr('id') ) { //replace toc_X with user assigned ID
5357
5358            const idSet = '#'+$(element).attr('id');
5359            $(anchorDom[anchorNumber]).attr('href', idSet );
5360
5361          }else{
5362
5363            let id = $(anchorDom[anchorNumber]).attr('href');
5364            if(typeof id !== 'undefined') $(element).attr('id', id.substr(1) );
5365
5366          }
5367
5368          anchorNumber++;
5369        })
5370
5371      })
5372
5373    }
5374  }
5375
5376  /**
5377   * Off-canvas sidebar
5378   */
5379
5380  var offCanvasSidebar = {
5381    init: function() {
5382      $(document).on('click', '.mfn-off-canvas-switcher', function(e) {
5383        e.preventDefault();
5384        if( $('html').hasClass('mfn-ofcs-opened') ){
5385          $('html').removeClass('mfn-ofcs-opened');
5386        }else{
5387          $('html').addClass('mfn-ofcs-opened');
5388        }
5389      });
5390    },
5391    mobile: function() {
5392      if( $('.sidebar .widget-area').length && $('body').hasClass('ofcs-mobile') ){
5393
5394        if( !$('.mfn-off-canvas-sidebar').length ){
5395          $('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>');
5396        }
5397
5398        if( $('body').hasClass('woocommerce-shop') && !$('.mfn-woo-filters-wrapper .mfn-off-canvas-switcher').length ){
5399          $('.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>
5399.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>');
5400        }
5401
5402        var $ofcs = $('.mfn-off-canvas-sidebar .mfn-off-canvas-content-wrapper .mfn-off-canvas-content');
5403        $ofcs.empty();
5404
5405        $('.sidebar .widget-area').each(function() {
5406          //var $sdbr = $(this).clone(true);
5407          $ofcs.append( $(this) );
5408          //$(this).hide();
5409        });
5410
5411        offCanvasSidebar.init();
5412
5413      }
5414    }
5415  }
5416
5417  function alignHeights(){
5418    var i = 0;
5419    if( !$('.mfn-align-heights').length ) return;
5420    $('.mfn-align-heights').each(function() {
5421      var max=0;
5422      var newclass = 'mfn-align-cont-'+i;
5423      $(this).addClass(newclass);
5424      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: auto;} </style>").appendTo("body");
5425      $("."+newclass+" .mfn-align-me").each(function() {
5426        if($(this).outerHeight() > max){max = $(this).outerHeight();}
5427      });
5428      $("<style type='text/css'> ."+newclass+" .mfn-align-me{ height: "+max+"px;} </style>").appendTo("body");
5429      i++;
5430    });
5431  }
5432
5433  $(window).on('debouncedresize', alignHeights);
5434
5435  var headerMegamenu = {
5436    init: function() {
5437
5438      if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children').length ){
5439        $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children > a').on('click', function(e) {
5440          let href = $(this).attr('href');
5441          if( !$(this).parent('li').hasClass('mfn-li-childrens-show') ){
5442            e.preventDefault();
5443            e.stopPropagation();
5444            $(this).siblings('ul').slideDown(300);
5445            $(this).parent('li').addClass('mfn-li-childrens-show');
5446          }else if( href == '' || href == '#' ){
5447            e.preventDefault();
5448            e.stopPropagation();
5449            $(this).siblings('ul').slideUp(300);
5450            $(this).parent('li').removeClass('mfn-li-childrens-show');
5451          }
5452        });
5453      }
5454
5455      /**
5456       * Submenu in mega menu
5457       * */
5458
5459      if( $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li').length ){
5460        $('.column_megamenu_menu ul.mfn-mm-menu-horizontal.mfn-mm-submenu-on-click li > a').on('click', function(e) {
5461          if( $(this).closest('li').hasClass('menu-item-has-children') && !$(this).closest('li').hasClass('mfn-li-hover') ){
5462            e.preventDefault();
5463            e.stopPropagation();
5464            $(this).closest('li').addClass('mfn-li-hover');
5465          }
5466        });
5467      }
5468
5469      if( $('ul.mfn-menu-submenu-on-hover li.mfn-menu-item-has-megamenu, li.mfn-theme-options-menu.mfn-menu-item-has-megamenu').length ){
5470        $('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() {
5471          if( $(this).find('.mfn-megamenu-full-width').length || $(this).find('.mfn-megamenu-grid').length ){
5472            headerMegamenu.setLeft($(this));
5473          }
5474        });
5475      }
5476
5477      if( $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu').length ){
5478
5479        $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu > a.mfn-menu-link').on('click', function(e) {
5480          let href = $(this).attr('href');
5481
5482          if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ){
5483            headerMegamenu.setLeft($(this).closest('li'));
5484          }
5485
5486          if( href == '' || href == '#' ){
5487            e.preventDefault();
5488            e.stopPropagation();
5489            if( $(this).closest('li').hasClass('mfn-li-hover') ) {
5490              $(this).closest('li').removeClass('mfn-li-hover');
5491              $(document).unbind('click', headerTemplate.bindUnclick);
5492              $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5493            }else{
5494              $('ul.mfn-menu-submenu-on-click li.mfn-menu-item-has-megamenu.mfn-li-hover').removeClass('mfn-li-hover');
5495              $(this).closest('li').addClass('mfn-li-hover');
5496              $(document).bind('click', headerTemplate.bindUnclick);
5497              headerTemplate.animContentAddClass();
5498            }
5499          }else if( !$(this).closest('li').hasClass('mfn-li-hover') ) {
5500            e.preventDefault();
5501            e.stopPropagation();
5502            if( !$(this).closest('li.mfn-li-hover').length ) {
5503              $('.mfn-header-tmpl ul li.mfn-li-hover').removeClass('mfn-li-hover');
5504            }else if($(this).closest('li.mfn-li-hover').find('li.mfn-li-hover').length){
5505              $(this).closest('li.mfn-li-hover').find('li.mfn-li-hover').removeClass('mfn-li-hover');
5506            }
5507            if( !$(this).closest('.mfn-megamenu-menu').length && !$(this).closest('li.mfn-li-hover').length ) {
5508              if( $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').length ){
5509                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show ul').slideUp();
5510                $('.mfn-megamenu-menu.mfn-mm-submenu-toggled li.menu-item-has-children.mfn-li-childrens-show').removeClass('mfn-li-childrens-show');
5511              }
5512            }
5513            headerTemplate.animContentAddClass();
5514            $(this).parent('li').addClass('mfn-li-hover');
5515            $(document).bind('click', headerTemplate.bindUnclick);
5516          }
5517
5518          headerMegamenu.afterShow();
5519
5520        });
5521
5522      }
5523
5524    },
5525
5526    afterShow: function() {
5527      bannerBox.init();
5528      $(window).trigger('resize');
5529    },
5530
5531    setLeft: function($li) {
5532      var $mm = $li.find('.mfn-menu-item-megamenu');
5533      var left = $li.offset().left;
5534      $mm.css('width', $(window).width()+'px');
5535      $mm.css('left', '-'+left+'px');
5536      $mm.addClass('mfn-mm-grid-set');
5537    }
5538  }
5539
5540  var footerTemplate = {
5541    init: function() {
5542      if( !$('.mfn-footer-tmpl').length ) return;
5543      if( $('body').hasClass('mfn-footer-stick') ){
5544        footerTemplate.isSticky();
5545      }
5546      if( $('body').hasClass('mfn-footer-sliding') || $('body').hasClass('mfn-footer-fixed') ){
5547        setTimeout(footerTemplate.isSliding(), 300);
5548      }
5549      return;
5550    },
5551    isSticky: function() {
5552      if( !$('.mfn-footer-tmpl').length ) return;
5553      var offsetTop = $('.mfn-footer-tmpl').offset().top + $('.mfn-footer-tmpl').outerHeight();
5554      if( offsetTop < $(window).height() ){
5555        $('.mfn-footer-tmpl').addClass('is-sticky');
5556      }else{
5557        $('.mfn-footer-tmpl').removeClass('is-sticky');
5558      }
5559    },
5560    isSliding: function() {
5561      var footer = $('.mfn-footer-tmpl').outerHeight();
5562      $('#Content').css('margin-bottom', footer);
5563    }
5564  }
5565
5566  var bannerBox = {
5567    init: function(){
5568      // bannerBox.init()
5569      setTimeout( bannerBox.set, 300 );
5570    },
5571
5572    set: function() {
5573
5574      if( $('body').hasClass('mfn-ui') ) return;
5575
5576      if( !$('.column_banner_box .hidden-desc').length ) return;
5577
5578      if( $(".mfn-banner-box .last-visible-el").length ) {
5579          $(".mfn-banner-box .last-visible-el").removeClass('last-visible-el');
5580          $('.hidden-wrapper .hidden-desc').removeAttr('style');
5581      }
5582
5583      $( ".mfn-banner-box").each(function() {
5584
5585          if( $(this).find('.hidden-desc').length ) {
5586            if( $(this).find('.hidden-desc').prev().length ) $(this).find('.hidden-desc').prev().addClass("last-visible-el");
5587
5588            var hd_h = $(this).find('.hidden-wrapper').outerHeight();
5589            $(this).find('.hidden-desc').css( { '--mfn-banner-box-height': hd_h + 'px' } );
5590          }
5591
5592      });
5593
5594    }
5595
5596  };
5597
5598
5599  var mfn_hotspot = {
5600    init: function() {
5601
5602      if( $(window).width() >= 960 ){
5603        mfn_hotspot.hover();
5604      }else{
5605        mfn_hotspot.click();
5606      }
5607
5608    },
5609
5610    hover: function(e) {
5611      $('.mfn-image-hotspot .hotspot-point').on('mouseenter', function() {
5612        $(this).addClass('is-active');
5613      }).on('mouseleave', function() {
5614        $(this).removeClass('is-active');
5615      });
5616
5617      $('.mfn-image-hotspot').on('mouseleave', function() {
5618        $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5619      });
5620
5621    },
5622
5623    click: function() {
5624      $('.mfn-image-hotspot .hotspot-point').on('click', function() {
5625        if( $('.mfn-image-hotspot .hotspot-point.is-active').length ) $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5626        $(this).addClass('is-active');
5627        $(document).bind('click', mfn_hotspot.bindUnclick);
5628      })
5629    },
5630
5631    bindUnclick: function(e) {
5632      if (!$('.mfn-image-hotspot .hotspot-point').is(e.target) && $('.mfn-image-hotspot .hotspot-point').has(e.target).length === 0) {
5633        if( $('.mfn-image-hotspot .hotspot-point.is-active').length ) $('.mfn-image-hotspot .hotspot-point.is-active').removeClass('is-active');
5634        $(document).unbind('click', mfn_hotspot.bindUnclick);
5635      }
5636    }
5637  };
5638
5639
5640  var headerTemplate = {
5641    hasSticky: false,
5642    isMobile: false,
5643    offsetScroll: 60,
5644    hasBodyOffset: false,
5645    height: 0,
5646    type: 'default',
5647    animContentOnHover: function() {
5648
5649      if( $('.mfn-header-tmpl.mfn-header-main .mfn-header-menu.mfn-header-mainmenu').hasClass('mfn-menu-submenu-on-hover') ){
5650        $('.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() {
5651          headerTemplate.animContentAddClass();
5652        }).on('mouseenter', function() {
5653          $(window).trigger('resize');
5654        });
5655      }
5656
5657      $('.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() {
5658        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5659      });
5660
5661    },
5662    animContentAddClass: function() {
5663      if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-blur') ) {
5664        $('body').addClass('mfn-content-blur');
5665      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-gray') ) {
5666        $('body').addClass('mfn-content-gray');
5667      }else if( $('.mfn-header-tmpl.mfn-header-main').hasClass('mfn-header-content-overlay') ) {
5668        $('body').addClass('mfn-content-overlay');
5669      }
5670    },
5671    openOnClick: function() {
5672
5673      // common
5674      $(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) {
5675        let href = $(this).attr('href');
5676
5677        if( $(this).closest('li').find('.mfn-megamenu-full-width').length || $(this).closest('li').find('.mfn-megamenu-grid').length ) {
5678          headerMegamenu.setLeft($(this).closest('li'));
5679        }
5680
5681        if( href == '' || href == '#' ){
5682          e.preventDefault();
5683          e.stopPropagation();
5684          if( $(this).closest('li').hasClass('mfn-li-hover') ) {
5685            $(this).closest('li').removeClass('mfn-li-hover');
5686            $(document).unbind('click', headerTemplate.bindUnclick);
5687            $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5688          }else{
5689            $(this).closest('li').siblings('li').removeClass('mfn-li-hover');
5690            $(this).closest('li').addClass('mfn-li-hover');
5691            $(document).bind('click', headerTemplate.bindUnclick);
5692            headerTemplate.animContentAddClass();
5693          }
5694        }else if( !$(this).closest('li').hasClass('mfn-li-hover') ){
5695          e.preventDefault();
5696          e.stopPropagation();
5697          $(this).closest('li').siblings('li').removeClass('mfn-li-hover');
5698          headerTemplate.animContentAddClass();
5699          $(this).parent('li').addClass('mfn-li-hover');
5700          $(document).bind('click', headerTemplate.bindUnclick);
5701        }
5702
5703
5704        $(window).trigger('resize')
5705      });
5706
5707    },
5708    bindUnclick: function(e) {
5709      var $li = $('.mfn-header-tmpl ul li.mfn-li-hover');
5710      if (!$li.is(e.target) && !$li.find(e.target).length ) {
5711        $li.removeClass('mfn-li-hover');
5712        $('body').removeClass('mfn-content-gray mfn-content-blur mfn-content-overlay');
5713        $(document).unbind('click', headerTemplate.bindUnclick);
5714      }
5715    },
5716    closeable: function() {
5717      // common
5718
5719      if( $('body').hasClass('mfn-ui') ) return;
5720
5721      $('.mfn-header-tmpl .close-closeable-section').on('click', function() {
5722        var $section = $(this).closest('.mcb-section');
5723        $section.addClass('closeable-hidden').slideUp(300, function() {
5724          headerTemplate.resetOffset();
5725          headerTemplate.offset();
5726        });
5727
5728        if( typeof $section.attr('data-close-days') !== 'undefined' && $section.attr('data-close-days') != '0' ){
5729          var days = $section.attr('data-close-days');
5730          var uid = $section.attr('data-uid');
5731          var date=new Date();
5732          date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
5733          var expires="; expires="+date.toGMTString();
5734          document.cookie="mfn_closed_section_"+uid+"=1"+expires+"; path=/"
5735        }
5736
5737      });
5738    },
5739    resetOffset: function() {
5740      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
5741        $('#Wrapper').css({ 'padding-top': $('.mfn-header-tmpl').outerHeight() });
5742      }
5743    },
5744
5745    detectHover: function() {
5746      $('.mfn-header-tmpl .mfn-menu-submenu-on-hover .mfn-menu-item-has-megamenu.mfn-menu-li').on('mouseenter', function() {
5747        headerMegamenu.afterShow();
5748      });
5749
5750    },
5751
5752    offset: function() {
5753      if( headerTemplate.hasSticky && !headerTemplate.isMobile ) return;
5754      headerTemplate.offsetScroll = 0;
5755      var _screen = 'default';
5756      if( headerTemplate.isMobile ) _screen = 'header-mobile';
5757      $('.mfn-header-tmpl .mfn-'+_screen+'-section.hide-on-scroll:not(.closeable-hidden)').each(function() {
5758          headerTemplate.offsetScroll += $(this).outerHeight();
5759      });
5760    },
5761    init: function() {
5762      headerTemplate.hasBodyOffset = false;
5763
5764      if( !$('body').hasClass('mfn-ui') && $('.mfn-header-tmpl').find('.section.closeable-active').length ) {
5765        $('.mfn-header-tmpl').find('.section.closeable-active').each(function() {
5766          if( headerTemplate.readcookie( 'mfn_closed_section_'+$(this).attr('data-uid') ) || headerTemplate.readcookie( 'mfn_closed_section' ) == $(this).attr('data-uid') ) {
5767            $(this).remove();
5768          }else{
5769            $(this).removeClass('mfn-temporary-hidden');
5770          }
5771        });
5772      }
5773
5774      if( $(window).width() < 767 && $('.mfn-header-tmpl').hasClass('mfn-hasMobile') ){
5775        headerTemplate.isMobile = true;
5776        headerTemplate.type = $('.mfn-header-tmpl').attr('data-mobile-type');
5777        if( $('.mfn-header-tmpl').hasClass('mfn-mobile-header-body-offset') ) {
5778          headerTemplate.hasBodyOffset = true;
5779        }else{
5780          headerTemplate.hasBodyOffset = false;
5781        }
5782      }else{
5783        headerTemplate.isMobile = false;
5784        headerTemplate.type = $('.mfn-header-tmpl').attr('data-type');
5785        if( $('.mfn-header-tmpl').hasClass('mfn-header-body-offset') ) {
5786          headerTemplate.hasBodyOffset = true;
5787        }else{
5788          headerTemplate.hasBodyOffset = false;
5789        }
5790      }
5791
5792      // init submenu show on click
5793      if( $('.mfn-header-tmpl .mfn-menu-submenu-on-click:not(.initialized)').length ) {
5794        $('.mfn-header-tmpl .mfn-menu-submenu-on-click').addClass('initialized');
5795        headerTemplate.openOnClick();
5796      }
5797
5798      if( $('.mfn-header-tmpl .mfn-menu-submenu-on-hover .mfn-menu-item-has-megamenu.mfn-menu-li').length ) {
5799        headerTemplate.detectHover();
5800      }
5801
5802      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') ){
5803        headerTemplate.animContentOnHover();
5804      }
5805
5806      if( $('.mfn-header-tmpl').hasClass('mfn-hasSticky') ) {
5807        headerTemplate.hasSticky = true;
5808      }else{
5809        headerTemplate.hasSticky = false;
5810      }
5811
5812      if( $('body style.tmp-mfn-header-template').length ) $('body style.tmp-mfn-header-template').remove();
5813
5814      if( $('.mfn-header-tmpl .close-closeable-section').length ) headerTemplate.closeable();
5815
5816      if( $('body').hasClass('mfn-header-scrolled') && !$('.mfn-builder-active').length ) $('body').removeClass('mfn-header-scrolled');
5817
5818      headerTemplate.getHeight();
5819      headerTemplate.offset();
5820
5821      headerTemplate.scroll();
5822
5823      if( $(window).scrollTop() > 10 ){
5824        $(window).trigger('scroll');
5825      }
5826
5827      if( $('#wpadminbar').length ) {
5828        let admin_bar_h = $('#wpadminbar').outerHeight();
5829        if($('.mfn-header-tmpl.mfn-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5830        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});
5831
5832      }
5833
5834    },
5835    scroll: function() {
5836
5837      // relative header prevent skip with sticky
5838      if( $('.mfn-header-tmpl').hasClass('mfn-header-tmpl-default') && headerTemplate.hasSticky && !headerTemplate.isMobile ) {
5839        $('body').append('<style class="tmp-mfn-header-template">html body.mfn-header-scrolled{padding-top: '+headerTemplate.height+'px;}</style>');
5840      }
5841
5842      // console.log('header scroll / '+headerTemplate.offsetScroll);
5843
5844      $(window).scroll(function() {
5845        var scrolled = $(this).scrollTop();
5846        var scroll_offset = headerTemplate.offsetScroll;
5847        if( headerTemplate.hasSticky && !headerTemplate.isMobile ) scroll_offset = headerTemplate.height;
5848
5849        if(scrolled > scroll_offset) {
5850            $('body').addClass('mfn-header-scrolled');
5851
5852            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 ){
5853              if( headerTemplate.hasSticky && !headerTemplate.isMobile ) {
5854                $('.mfn-header-tmpl').css({'top': 0});
5855              }else{
5856                $('.mfn-header-tmpl').css({'top': '-'+headerTemplate.offsetScroll+'px'});
5857              }
5858            }
5859
5860          }else{
5861            $('body').removeClass('mfn-header-scrolled');
5862
5863            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 ){
5864              $('.mfn-header-tmpl').css({'top': '-'+scrolled+'px'});
5865              //$('.mfn-header-tmpl').css({'top': '0px'});
5866            }
5867
5868            if( $('#wpadminbar').length ) {
5869              let admin_bar_h = $('#wpadminbar').outerHeight();
5870              if($('.mfn-header-tmpl.mfn-header-tmpl-fixed').length) $('.mfn-header-tmpl.mfn-header-tmpl-fixed').css({'margin-top': admin_bar_h});
5871              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});
5872
5873            }
5874
5875          }
5876      });
5877    },
5878    getHeight: function() {
5879      headerTemplate.height = $('.mfn-header-tmpl').outerHeight();
5880      if( headerTemplate.type != 'default' && headerTemplate.hasBodyOffset ){
5881        $('#Wrapper').css({ 'padding-top' : headerTemplate.height });
5882      }else{
5883        $('#Wrapper').removeAttr('style');
5884      }
5885      $('.mfn-header-tmpl').removeAttr('style');
5886    },
5887
5888    readcookie: function(name){
5889      var nameEQ=name+"=";
5890      var ca=document.cookie.split(';');
5891      for(var i=0;i<ca.length;i++){
5892        var c=ca[i];
5893        while(c.charAt(0)==' ')c=c.substring(1,c.length);
5894        if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length)
5895      }
5896
5897      return null
5898    },
5899
5900  }
5901
5902
5903let mfnMarqueeText = {
5904  win_width: 1920,
5905
5906  init: function() {
5907
5908      if( !$('.mfn-marquee-text-wrapper').length ) return;
5909
5910      this.win_width = $(window).width();
5911
5912      setTimeout(function() {
5913        mfnMarqueeText.set();
5914      }, 100);
5915
5916    },
5917
5918    set: function() {
5919      $('.mfn-marquee-text-wrapper:not(.initialized)').each(function(i, el) {
5920
5921        if( !$(this).find('.mfn-marquee-text').length ) return;
5922        $(this).addClass('initialized');
5923        let track = $(this).find('.mfn-marquee-text');
5924        let width = track.outerWidth();
5925
5926        document.body.style.display = 'table';
5927        document.body.offsetHeight; // FIX: mobile safari force reflow
5928        document.body.style.display = '';
5929
5930        if( width == 0 ) return;
5931
5932        let divi = Math.round( (mfnMarqueeText.win_width / width) ) + 1;
5933        let iter = Math.round(Math.ceil(divi / 2) * 2);
5934
5935        if( iter < 2 ) return;
5936
5937        let track_html = track.html();
5938
5939        for (var j = 1;
5939 j <= iter; j++) {
5940            track.append(track_html);
5941          }
5942
5943        let count = track.find('.mfn-marquee-item').length;
5944
5945        if( count % 2 !== 0 ){
5946          track.append(track_html);
5947        }
5948
5949      });
5950
5951    }
5952
5953}
5954
5955mfnMarqueeText.init();
5956
5957$(document).on('mfn:ajax:refresh', mfnMarqueeText.init);
5958
5959
5960
5961  /**
5962   *
5963   * Read more
5964   *
5965   * */
5966
5967  let mfnReadMore = {
5968
5969    init: function() {
5970
5971      if ($('body').hasClass('mfn-ui')) return false;
5972      if (!$('.mfn-read-more').length) return false;
5973
5974      mfnReadMore.prepare();
5975      mfnReadMore.click();
5976    },
5977
5978    prepare: function() {
5979
5980      if ($('body').hasClass('mfn-ui')) return false;
5981
5982      $('.mfn-read-more').each(function() {
5983        let this_wrapper = $(this).closest('.column');
5984        let copy = this_wrapper.nextAll('.column').addClass('mfn-read-more-hidden');
5985
5986        if (copy.length) {
5987          $.each(copy, function(i, item) {
5988            this_wrapper.before(item);
5989          });
5990        }
5991      });
5992    },
5993
5994    open: function($wrapper) {
5995      $wrapper.find('.mfn-read-more-hidden').each(function() {
5996        let $el = $(this);
5997
5998        $el
5999          .stop(true, true)
6000          .addClass('showed')
6001          .hide()
6002          .slideDown(500, function() {
6003            $(this).css('display', 'flex');
6004          });
6005      });
6006    },
6007
6008    close: function($wrapper) {
6009      $wrapper.find('.mfn-read-more-hidden').each(function() {
6010        let $el = $(this);
6011
6012        $el
6013          .stop(true, true)
6014          .css('display', 'flex')
6015          .slideUp(500, function() {
6016            $(this)
6017              .removeClass('showed')
6018              .css('display', '');
6019          });
6020      });
6021    },
6022
6023    click: function() {
6024
6025      $(document).on('click', '.mfn-read-more', function(e) {
6026        e.preventDefault();
6027
6028        let box = $(this);
6029        let wrapper = box.closest('.mcb-wrap');
6030
6031        let label1 = box.attr('data-title1');
6032        let label2 = box.attr('data-title2');
6033
6034        let icon1 = box.attr('data-icon1');
6035        let icon2 = box.attr('data-icon2');
6036
6037        let label = box.find(box.attr('data-label_path'));
6038        let icon = box.find(box.attr('data-icon_path'));
6039
6040        if (wrapper.hasClass('mfn-read-more-expanded')) {
6041
6042          mfnReadMore.close(wrapper);
6043          wrapper.removeClass('mfn-read-more-expanded');
6044          label.html(label1);
6045
6046          if (icon1 != '' && icon.length) {
6047            icon.html('<i class="' + icon1 + '"></i>');
6048          } else {
6049            icon.remove();
6050          }
6051
6052        } else {
6053
6054          mfnReadMore.open(wrapper);
6055          wrapper.addClass('mfn-read-more-expanded');
6056          label.html(label2);
6057
6058          if (icon2 != '') {
6059            if (icon.length) {
6060              icon.html('<i class="' + icon2 + '"></i>');
6061            } else {
6062              if (box.find('.mfn-icon-box').length) {
6063                box.find('.mfn-icon-box').prepend('<span class="' + box.attr('data-icon_path').replace('.', '') + '"><i class="' + icon2 + '"></i></span>');
6064              } else {
6065                box.prepend('<span class="' + box.attr('data-icon_path').replace('.', '') + '"><i class="' + icon2 + '"></i></span>');
6066              }
6067            }
6068          }
6069        }
6070
6071        $(window).trigger('resize');
6072
6073        setTimeout(function() {
6074          $(window).trigger('resize');
6075        }, 600);
6076      });
6077    }
6078
6079  };
6080
6081
6082  /**
6083   *
6084   * Popup template
6085   *
6086   * */
6087
6088  let mfnPopup = {
6089
6090    init: function() {
6091
6092      // mfnPopup.init()
6093
6094      if( $('body').hasClass('elementor-editor-active') ) return; // stop if elementor builder is active
6095
6096        $(document).on('click', '.open-mfn-popup', function(e) {
6097          e.preventDefault();
6098          let popup_id = $(this).attr('data-mfnpopup');
6099
6100          if( popup_id == 'popup_id_required' ){
6101            alert('Popup ID id required');
6102          }else if( !$(popup_id).length ){
6103            alert('We cannot find popup with inserted ID');
6104          }else{
6105            mfnPopup.showPopup($(popup_id));
6106          }
6107        });
6108
6109
6110      if( !$('body').hasClass('mfn-cookies-open') ) mfnPopup.open();
6111
6112      $(document).on('click', '.exit-mfn-popup', function(e) {
6113        e.preventDefault();
6114        let $popup = $(this).closest('.mfn-popup-tmpl');
6115        mfnPopup.hidePopup($popup);
6116      });
6117
6118    },
6119
6120    open: function() {
6121      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').length ) mfnPopup.showOnScroll();
6122      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').length ) mfnPopup.showOnDelay();
6123      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').length ) mfnPopup.showOnExit();
6124      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').length ) mfnPopup.showOnScrollToElement();
6125      if( $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').length ) mfnPopup.showOnStart();
6126    },
6127
6128    hidePopup: function( $popup ) {
6129
6130      if( $popup.find('video').length ) $popup.find('video').get(0).pause();
6131
6132      if( $popup.find('iframe').length ) {
6133        var popup_iframe = $popup.find('iframe')[0];
6134        var ifr_src = $(popup_iframe).attr('src');
6135
6136        if( typeof ifr_src != 'undefined' ){
6137          if( ifr_src.includes('youtu') ) popup_iframe.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); // yt
6138
6139          if( ifr_src.includes('vimeo') ) {
6140            $(popup_iframe).attr('src', ifr_src); // vimeo
6141            //popup_iframe.pause();
6142          }
6143        }
6144
6145      }
6146
6147      $popup.removeClass('mfn-popup-active');
6148      $('html').removeClass('mfn-popup-browser-scroll-disabled');
6149
6150      if( $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).length ){
6151        $('style.mfn-popup-tmpl-blur-'+$popup.attr('data-id')).remove();
6152      }
6153
6154      if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') || $popup.hasClass('mfn-popup-tmpl-display-one') ){
6155        let days = 365;
6156
6157        if( $popup.hasClass('mfn-popup-tmpl-display-cookie-based') ) days = parseInt($popup.attr('data-cookie'));
6158
6159        let cookie_name = 'mfn_popup_'+$popup.attr('data-id');
6160        mfnPopup.addCookie(days, cookie_name);
6161      }
6162
6163    },
6164
6165    showPopup: function( $popup ){
6166
6167      let cookie_name = 'mfn_popup_'+$popup.attr('data-id');
6168      if( mfnPopup.checkCookie(cookie_name) ) return;
6169
6170      if( typeof $popup.attr('data-blur') !== 'undefined' ){
6171        $('body').append('<style class="mfn-popup-tmpl-blur-'+$popup.attr('data-id')+'">#Wrapper{ filter: blur('+$popup.attr('data-blur')+'px) }</style>');
6172      }
6173
6174      if( !$popup.hasClass('mfn-popup-active') ) $popup.addClass('mfn-popup-active mfn-popup-showed');
6175
6176      if( $popup.hasClass('mfn-popup-tmpl-hide-automatically-delay') ) mfnPopup.hideAutomatically($popup);
6177      if( $popup.hasClass('mfn-popup-tmpl-close-button-show-delay') ) mfnPopup.showExitButton($popup);
6178
6179      if( !$('body').hasClass('mfn-ui') && $popup.hasClass('mfn-popup-close-on-overlay-click') ){
6180        $popup.bind('click',  mfnPopup.closeOverlayClick);
6181      }
6182
6183      if( !$popup.hasClass('mfn-popup-browser-scroll-enabled') ){
6184        $('html').addClass('mfn-popup-browser-scroll-disabled');
6185      }
6186
6187      bannerBox.set();
6188
6189      if( $popup.find('.slick-initialized').length ){
6190        $popup.find('.slick-initialized').slick('refresh');
6191      }
6192
6193      $(document).trigger('mfnPopupInit');
6194    },
6195
6196    closeOverlayClick: function(e) {
6197      var div = $(e.delegateTarget).find('.mfn-popup-tmpl-content-wrapper');
6198      if (!div.is(e.target) && div.has(e.target).length === 0){
6199          mfnPopup.hidePopup($(e.delegateTarget));
6200          $(e.delegateTarget).unbind('click', mfnPopup.closeOverlayClick);
6201      }
6202    },
6203
6204    hideAutomatically: function($popup) {
6205        if( $('body').hasClass('mfn-ui') ) return;
6206        let delay = parseInt( $popup.attr('data-hidedelay') );
6207        setTimeout(function() { mfnPopup.hidePopup($popup); }, delay);
6208    },
6209
6210    showExitButton: function($popup) {
6211      let delay = parseInt( $popup.attr('data-closebuttondelay') );
6212      setTimeout(function() { $popup.addClass('mfn-closebutton-active'); }, delay);
6213    },
6214
6215    showOnScroll: function() {
6216      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-scroll').each(function() {
6217        let $popup = $(this);
6218        let scroll_offset = parseInt( $popup.attr('data-display') );
6219
6220        $(window).on('scroll', function() {
6221          if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
6222        });
6223
6224      });
6225    },
6226
6227    showOnScrollToElement: function() {
6228      $('body').imagesLoaded(function() {
6229        $('.mfn-popup-tmpl.mfn-popup-tmpl-display-scroll-to-element').each(function() {
6230          let $popup = $(this);
6231          let scroll_offset = $($popup.attr('data-display')).length ? parseInt( $($popup.attr('data-display')).offset().top ) : 100;
6232
6233          $(window).on('scroll', function() {
6234            if( $(window).scrollTop() > scroll_offset && !$popup.hasClass('mfn-popup-showed') ) mfnPopup.showPopup($popup);
6235          });
6236
6237        });
6238      });
6239    },
6240
6241    showOnDelay: function() {
6242      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-start-delay').each(function() {
6243        let $popup = $(this);
6244        let delay = parseInt( $popup.attr('data-display') );
6245
6246        setTimeout(function() {
6247          mfnPopup.showPopup($popup)
6248        }, delay);
6249      });
6250    },
6251
6252    showOnExit: function() {
6253      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-exit').each(function() {
6254        let $popup = $(this);
6255
6256        $(document).on('mouseleave', function() {
6257          mfnPopup.showPopup($popup)
6258        });
6259      });
6260    },
6261
6262    showOnStart: function() {
6263      $('.mfn-popup-tmpl.mfn-popup-tmpl-display-on-start').each(function() {
6264        let $popup = $(this);
6265        mfnPopup.showPopup($popup)
6266      });
6267    },
6268
6269    addCookie(days, cookie_name){
6270
6271      let date=new Date();
6272      date.setTime(date.getTime()+(parseInt(days)*24*60*60*1000));
6273      let expires="; expires="+date.toGMTString();
6274      document.cookie=cookie_name+"=true"+expires+"; path=/";
6275
6276    },
6277
6278    checkCookie(cookie_name){
6279      var nameEQ = cookie_name+"=";
6280      var ca = document.cookie.split(';');
6281      for(var i=0;i<ca.length;i++){
6282        var c = ca[i];
6283        while(c.charAt(0)==' ') c = c.substring(1,c.length);
6284        if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length)
6285      }
6286      return null
6287    }
6288
6289  }
6290
6291  $(document).on('mfn:gdpr2:close', function() {
6292    mfnPopup.open();
6293  });
6294
6295  /**
6296   * Read more term desc
6297   */
6298
6299  var mfnReadMoreTermDesc = function($el) {
6300
6301    var $el = $el.closest('.mfn-desc-expandable');
6302
6303    var start = $el.css('max-height'),
6304      height;
6305
6306    $el.css('max-height','unset');
6307
6308    height = $el.outerHeight();
6309
6310    $el.css('max-height',start);
6311
6312    $el.animate({
6313      'maxHeight': height + 'px'
6314    },500);
6315
6316    $el.find('.read-more').animate({
6317      'opacity': 0
6318    },500,function(){
6319      $(this).hide();
6320    });
6321  };
6322
6323   $(document).on('click', '.mfn-desc-expandable .read-more .read-more-button', function(e) {
6324    e.preventDefault();
6325    mfnReadMoreTermDesc($(this));
6326  });
6327
6328
6329  var mfnSideMenu = {
6330
6331    id: '',
6332    wrapper: false,
6333    hash: false,
6334    submenu: false,
6335    backup: {},
6336
6337    init: function() {
6338      if( $('.mfn-menu-tabs-wrapper').length ) mfnSideMenu.menutabs();
6339
6340      if( $('.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-toggled').length ) mfnSideMenu.toggleSubmenu();
6341      if( $('.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-replace').length ) mfnSideMenu.replaceSubmenu();
6342
6343      if( $('a.mfn-open-sidebar').length ) {
6344        mfnSideMenu.click();
6345        mfnSideMenu.closeClick();
6346      }
6347
6348      $(document).on('click', '.mfn-sidemenu-menu li a', function(e) {
6349        var href = $(this).attr('href');
6350
6351        if( href == '#' && $(this).siblings('.outer-menu-sub').length ) {
6352          e.preventDefault();
6353          $(this).siblings('.outer-menu-sub').trigger('click');
6354        }else if( href.includes('#') ) {
6355
6356          var href_split = href.split('#');
6357          if( !$('#'+href_split[1]).length ) return;
6358
6359          e.preventDefault();
6360          $(this).closest('li').addClass('current-menu-item').siblings('li').removeClass('current-menu-item');
6361
6362          var offset = $('#'+href_split[1]).offset().top;
6363
6364          offset = offset - ( fixStickyHeaderH() + adminBarH() );
6365
6366          $('body, html').animate({scrollTop: offset}, 500);
6367
6368          mfnSideMenu.id = $(this).closest('.mfn-sidemenu-tmpl').attr('data-id');
6369          mfnSideMenu.hide();
6370        }
6371
6372      });
6373
6374    },
6375
6376    closeClick: function() {
6377      $(document).on('click', '.mfn-sidemenu-closebutton', function(e) {
6378        e.preventDefault();
6379
6380        mfnSideMenu.id = $(this).closest('.mfn-sidemenu-tmpl').attr('data-id');
6381        mfnSideMenu.hide();
6382
6383      });
6384    },
6385
6386    hide: function() {
6387      $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).removeClass('mfn-sidemenu-active');
6388
6389      $('html').addClass('mfn-closing-sidemenu-'+mfnSideMenu.id);
6390
6391      $('html').removeClass('mfn-sidemenu-'+mfnSideMenu.id+'-active');
6392      $('html').removeClass('mfn-sidemenu-move-content-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-align'));
6393      $('html').removeClass('mfn-sidemenu-bodyscroll-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-bodyscroll'));
6394      $('html').removeClass('mfn-sidemenu-entrance-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance'));
6395
6396      setTimeout(function() {
6397        $('html').removeClass('mfn-closing-sidemenu-'+mfnSideMenu.id);
6398        // $(window).trigger('resize');
6399        redrawAllRevolutionSliders();
6400      }, 310);
6401
6402      if( !$('body').hasClass('mfn-ui') && $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).hasClass('mfn-sidemenu-close-on-overlay-click') ) {
6403        $(document).unbind('click', mfnSideMenu.closeOverlayClick);
6404      }
6405
6406    },
6407
6408    click: function() {
6409      $(document).on('click', 'a.mfn-open-sidebar', function(e) {
6410        e.preventDefault();
6411
6412        mfnSideMenu.id = String($(this).attr('data-sidemenu'));
6413
6414        if( !$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).length ) return;
6415
6416        $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).addClass('mfn-sidemenu-active');
6417
6418        $('html').addClass('mfn-sidemenu-entrance-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance'));
6419        $('html').addClass('mfn-sidemenu-'+mfnSideMenu.id+'-active');
6420
6421        if( $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-entrance') == 'move-content' ){
6422          $('html').addClass('mfn-sidemenu-move-content-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-align'));
6423        }
6424
6425        if( !$('body').hasClass('mfn-ui') && $('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).hasClass('mfn-sidemenu-close-on-overlay-click') ) {
6426          $(document).bind('click',  mfnSideMenu.closeOverlayClick);
6427        }
6428
6429        setTimeout(function(){
6430          $('html').addClass('mfn-sidemenu-bodyscroll-'+$('#mfn-sidemenu-tmpl-'+mfnSideMenu.id).attr('data-bodyscroll'));
6431        },300);
6432
6433      });
6434    },
6435
6436    closeOverlayClick: function(e) {
6437      var div = $('.mfn-sidemenu-tmpl');
6438      if ( !div.is(e.target) && div.has(e.target).length === 0 && !$(e.target).closest('.mfn-menu-wrapper').length ){
6439          mfnSideMenu.hide();
6440      }
6441    },
6442
6443    menutabs: function() {
6444      $(document).on('click', '.mfn-menu-tabs-wrapper ul.mfn-menu-tabs-nav li a', function(e) {
6445        e.preventDefault();
6446
6447        if( $(this).parent('li').hasClass('active') ){
6448          return;
6449        }else{
6450          $(this).closest('.mfn-menu-tabs-wrapper').find('.active').removeClass('active');
6451        }
6452
6453        let id = $(this).attr('href');
6454        $(this).parent('li').addClass('active');
6455        $(this).closest('.mfn-menu-tabs-wrapper').find(id).addClass('active');
6456
6457      });
6458    },
6459
6460    toggleSubmenu: function() {
6461      $(document).on('click', '.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-toggled li.menu-item-has-children .outer-menu
6461-sub', function(e) {
6462        e.preventDefault();
6463        if( !$(this).closest('li').hasClass('current-menu-item') && !$(this).closest('li').hasClass('current-menu-ancestor') ){
6464          $(this).closest('li').addClass('current-menu-ancestor');
6465        }else if( $(this).closest('li').hasClass('current-menu-ancestor') ){
6466          $(this).closest('li').removeClass('current-menu-ancestor');
6467        }else{
6468          $(this).closest('li').toggleClass('current-menu-item');
6469        }
6470
6471        //$(this).closest('li').toggleClass('current-menu-ancestor');
6472        //if( $(this).closest('ul').closest('li').hasClass('current-menu-ancestor') ) $(this).closest('ul').closest('li').toggleClass('current-menu-ancestor');
6473      });
6474    },
6475
6476    replaceSubmenu: function() {
6477      $(document).on('click', '.mfn-sidemenu-menu.mfn-menu-submenu-on.mfn-menu-submenu-replace li.menu-item-has-children .outer-menu-sub', function(e) {
6478        e.preventDefault();
6479
6480        mfnSideMenu.wrapper = $(this).closest('.mfn-menu-wrapper');
6481        mfnSideMenu.hash = mfnSideMenu.wrapper.attr('data-hash');
6482        mfnSideMenu.submenu = $(this).closest('li').find('ul.sub-menu').first().html();
6483
6484        if( typeof mfnSideMenu.backup[mfnSideMenu.hash] === 'undefined' ){
6485          mfnSideMenu.backup[mfnSideMenu.hash] = [];
6486        }
6487
6488        let newest = {};
6489        newest.label = $(this).closest('li').find('a.mfn-menu-link .menu-label').html();
6490        newest.ul = mfnSideMenu.wrapper.children('ul').html();
6491
6492        mfnSideMenu.backup[mfnSideMenu.hash].push(newest);
6493
6494        if( !mfnSideMenu.wrapper.hasClass('mfn-sidemenu-replaced') ) mfnSideMenu.wrapper.addClass('mfn-sidemenu-replaced');
6495
6496        setTimeout(mfnSideMenu.updateMenu, 10);
6497
6498        //mfnSideMenu.updateMenu();
6499
6500      });
6501
6502      mfnSideMenu.breadcrumbsClick();
6503    },
6504
6505    updateMenu: function() {
6506
6507      if(mfnSideMenu.wrapper.find('.mfn-sidemenu-back').length) mfnSideMenu.wrapper.find('.mfn-sidemenu-breadcrumbs').remove();
6508
6509      mfnSideMenu.wrapper
6510        .find('.mfn-sidemenu-menu').html(mfnSideMenu.submenu);
6511
6512      if( mfnSideMenu.backup[mfnSideMenu.hash].length > 0 ) {
6513        mfnSideMenu.wrapper.prepend('<div class="mfn-sidemenu-breadcrumbs"></div>');
6514        mfnSideMenu.backup[mfnSideMenu.hash].map(function(el, i) {
6515          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>');
6516        });
6517
6518      }
6519
6520    },
6521
6522    breadcrumbsClick: function() {
6523
6524      $(document).on('click', '.mfn-sidemenu-back', function(e) {
6525        e.preventDefault();
6526
6527        mfnSideMenu.wrapper = $(this).closest('.mfn-menu-wrapper');
6528        mfnSideMenu.hash = mfnSideMenu.wrapper.attr('data-hash');
6529
6530        let index = $(this).attr('data-index');
6531
6532        let choosed = mfnSideMenu.backup[mfnSideMenu.hash][index];
6533
6534        mfnSideMenu.submenu = choosed.ul;
6535
6536        mfnSideMenu.backup[mfnSideMenu.hash] = mfnSideMenu.backup[mfnSideMenu.hash].filter((item,i) => { return i < index });
6537
6538        //mfnSideMenu.updateMenu();
6539        setTimeout(mfnSideMenu.updateMenu, 10);
6540      });
6541    }
6542
6543  }
6544
6545  /**
6546   * Lazy Load images
6547   */
6548
6549  document.addEventListener('DOMContentLoaded', () => {
6550
6551    const images = Array.from(document.querySelectorAll('img.mfn-lazy'));
6552
6553    if ('IntersectionObserver' in window) {
6554      const imageObserver = new IntersectionObserver((entries, observer) => {
6555        entries.forEach(entry => {
6556          if (entry.isIntersecting) {
6557            const image = entry.target;
6558            image.src = image.dataset.src;
6559            imageObserver.unobserve(image);
6560            window.dispatchEvent(new Event('resize'));
6561          }
6562        });
6563      });
6564
6565      images.forEach(img => imageObserver.observe(img));
6566    }
6567
6568  });
6569
6570})(jQuery);
6571
6572// Safari resize fix
6573(function() {
6574  let lastZoom = 1;
6575
6576  function getZoom() {
6577    return window.outerWidth / window.innerWidth;
6578  }
6579
6580  function checkZoomReset() {
6581    const currentZoom = getZoom();
6582    if (Math.abs(currentZoom - 1) < 0.02 && lastZoom !== 1) {
6583      window.scrollTo({ left: 0, top: window.scrollY, behavior: 'instant' });
6584    }
6585    lastZoom = currentZoom;
6586  }
6587
6588  window.addEventListener('resize', checkZoomReset);
6589})();
6590
6591// Remove Gray Highlight When Tapping Links in Mobile Safari
6592document.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.