PageSourceSearch

https://lupromax.co.id/wp-content/themes/betheme/js/scripts.js?ver=28.1.5

js lupromax.co.id collected 2026-10-06 23:50:14 UTC 169,125 bytes, 5,988 lines download raw bytes

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