PageSourceSearch

https://remotecontrolgates.co.uk/wp-content/themes/betheme/js/scripts.js?ver=29.0

js remotecontrolgates.co.uk collected 2026-10-04 01:41:56 UTC 191,433 bytes, 6,656 lines download raw bytes

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