PageSourceSearch

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

js renatozero.com collected 2026-10-02 12:30:16 UTC 170,790 bytes, 5,853 lines download raw bytes

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