PageSourceSearch

https://www.mankan.me/wp-content/themes/betheme/js/scripts.js?ver=27.6.3

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