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