PageSourceSearch

https://www.ouest-industries.com/wp-content/themes/betheme/js/scripts.js?ver=27.5.11

js ouest-industries.com collected 2026-10-07 15:46:35 UTC 156,992 bytes, 5,528 lines download raw bytes

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