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