PageSourceSearch

https://www.edicionsembora.es/wp-content/themes/base/js/scripts.js?ver=27.0.7

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

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.