PageSourceSearch

https://www.foreignaffairs.gov.fj/wp-content/themes/betheme/js/scripts.js?ver=27.3.8

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