PageSourceSearch

https://raydeo.com/wp-content/themes/betheme/js/scripts.js

js raydeo.com collected 2026-10-07 14:09:30 UTC 188,765 bytes, 6,545 lines download raw bytes

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