1var MiproTheme; 2 3(function($) { 4 "use strict"; 5 6 MiproTheme = { 7 init: function() { 8 9 this.ShowSearch(); 10 11 this.preloadJs(); 12 13 this.ProgressBar(); 14 15 this.SliderShortcode(); 16 17 this.SliderBrandShortcode(); 18 19 this.MegaMenuSetting(); 20 21 this.MobileNavigation(); 22 23 this.PopupNewletter(); 24 25 this.HeaderSticky(); 26 27 this.ShopSidebar(); 28 29 this.ShopFilters(); 30 31 this.BannerPrlxShortcode(); 32 33 this.Backtotop(); 34 35 this.BackgroundPrlx(); 36 37 this.SizeChartProductImg(); 38 39 this.VideoLightbox(); 40 41 this.CounterUpShortcode(); 42 43 this.AjaxSearch(); 44 45 this.HoverGalleryProduct(); 46 47 this.AccordionProductTab(); 48 49 this.QuickviewAction(); 50 51 this.HideMessagePopup(); 52 53 this.WishlistAction(); 54 55 this.RecentPostWg(); 56 57 this.ProductWgSlider(); 58 59 this.CountdownTimer(); 60 61 this.BlogGallerySlider(); 62 63 this.BlogMasonryShortcode(); 64 65 this.BootrapTooltip(); 66 67 this.WooQuantity(); 68 69 this.ProductImageSetting(); 70 71 this.ProductDefaultSlider(); 72 73 this.OrderByWoo(); 74 75 this.RelatedPostSlider(); 76 77 this.loginSidebar(); 78 79 this.CartSidebar(); 80 81 this.GalleryImagesShortcode(); 82 83 this.ProductShortcode(); 84 85 this.CatMasonryShot(); 86 87 this.MessageAddtoCart(); 88 89 this.StickyProduct(); 90 91 this.LazyLoading(); 92 93 this.ColorSwatches(); 94 95 this.CookieNotice(); 96 97 this.ProductVideo360(); 98 99 this.infiniteProduct(); 100 101 this.GridListShop(); 102 103 this.AjaxShop(); 104 105 this.VariationsProduct(); 106 }, 107 108 ShowSearch:function(){ 109 $('.kft-header-search .toggle-search').on('click',function(){ 110 $(this).parent().find('.search-form-wrapper').toggle(); 111 return false; 112 }) 113 }, 114 115 ProgressBar: function() { 116 117 $(window).on( 'scroll', function() { 118 var scrollTop = $(window).scrollTop(); 119 var docHeight = $(document).height(); 120 var winHeight = $(window).height(); 121 var scrollPercent = (scrollTop) / (docHeight - winHeight); 122 var scrollPercentRounded = Math.round(scrollPercent*100); 123 124 $( ".progress-bar-page" ).css( "width", scrollPercentRounded + "%" ); 125 126 }); 127 }, 128 129 SliderShortcode: function() { 130 $('.kft-banners-slider,.kft-product-categories-shortcode.layout-slider,.kft-blogs-shortcode.slider,.kft-testimonials-shortcode.layout-slider').each(function() { 131 var element = $(this); 132 var margin = element.data('margin'); 133 var columns = element.data('columns'); 134 var nav = element.data('nav') === 1; 135 var dots = element.data('dots') === 1; 136 var autoplay = element.data('autoplay') === 1; 137 var slider = element.data('slider') === 1; 138 var desksmini = element.data('desksmini'); 139 var tabletmini = element.data('tabletmini'); 140 var tablet = element.data('tablet'); 141 var mobile = element.data('mobile'); 142 var mobilesmini = element.data('mobilesmini'); 143 144 if (slider) { 145 var _slider_data = { 146 loop: false, 147 nav: nav, 148 dots: dots, 149 slideBy: 1, 150 navText: false, 151 rtl: $('body').hasClass('rtl'), 152 margin: margin, 153 autoplay: autoplay, 154 autoplayHoverPause: true, 155 autoplayTimeout: 5000, 156 responsive: { 157 0: { 158 items: mobilesmini 159 }, 160 480: { 161 items: mobile 162 }, 163 640: { 164 items: tabletmini 165 }, 166 768: { 167 items: tablet 168 }, 169 991: { 170 items: desksmini 171 }, 172 1199: { 173 items: columns 174 } 175 }, 176 onInitialized: function() { 177 element.find('.meta-slider').addClass('loaded').removeClass('loading'); 178 } 179 }; 180 element.find('.meta-slider > div').addClass('owl-carousel').owlCarousel(_slider_data); 181 } 182 }); 183 }, 184SliderBrandShortcode: function() { 185 $('.kft-brand-slider-shortcode').each(function() { 186 var element = $(this); 187 var margin = element.data('margin'); 188 var columns = element.data('columns'); 189 var nav = element.data('nav') === 1; 190 var dots = element.data('dots') === 1; 191 var autoplay = element.data('autoplay') === 1; 192 var slider = element.data('slider') === 1;
193 var desksmini = element.data('desksmini'); 194 var tabletmini = element.data('tabletmini'); 195 var tablet = element.data('tablet'); 196 var mobile = element.data('mobile'); 197 var mobilesmini = element.data('mobilesmini'); 198 199 if (slider) { 200 var _slider_data = { 201 loop: true, 202 nav: nav, 203 dots: dots, 204 slideBy: 1, 205 center:true, 206 navText: false, 207 rtl: $('body').hasClass('rtl'), 208 margin: margin, 209 autoplay: autoplay, 210 autoplayHoverPause: true, 211 autoplayTimeout: 5000, 212 responsive: { 213 0: { 214 items: mobilesmini 215 }, 216 480: { 217 items: mobile 218 }, 219 640: { 220 items: tabletmini 221 }, 222 768: { 223 items: tablet 224 }, 225 991: { 226 items: desksmini 227 }, 228 1199: { 229 items: columns 230 } 231 }, 232 onInitialized: function() { 233 element.find('.meta-slider').addClass('loaded').removeClass('loading'); 234 } 235 }; 236 element.find('.meta-slider > div').addClass('owl-carousel').owlCarousel(_slider_data); 237 } 238 }); 239 }, 240 241 ProductShortcode: function() { 242 $('.kft-product-shortcode').each(function() { 243 var element = $(this); 244 var atts = element.data('atts'); 245 246 if (atts.is_slider) { 247 var nav = parseInt(atts.nav) === 1; 248 var dots = parseInt(atts.dots) === 1; 249 var autoplay = parseInt(atts.autoplay) === 1; 250 var margin = parseInt(atts.margin); 251 var desksmini = parseInt(atts.desksmini); 252 var tabletmini = parseInt(atts.tabletmini); 253 var tablet = parseInt(atts.tablet); 254 var mobile = parseInt(atts.mobile); 255 var mobilesmini = parseInt(atts.mobilesmini); 256 var columns = parseInt(atts.columns); 257 var slider_data = { 258 loop: false, 259 nav: nav, 260 navText: false, 261 dots: dots, 262 slideBy: 1, 263 rtl: $('body').hasClass('rtl'), 264 margin: margin, 265 autoplay: autoplay, 266 autoplayTimeout: 5000, 267 autoHeight: true, 268 responsive: { 269 0: { 270 items: mobilesmini 271 }, 272 480: { 273 items: mobile 274 }, 275 640: { 276 items: tabletmini 277 }, 278 768: { 279 items: tablet 280 }, 281 991: { 282 items: desksmini 283 }, 284 1199: { 285 items: columns 286 } 287 }, 288 onInitialized: function() { 289 element.find('.meta-slider').addClass('loaded').removeClass('loading'); 290 } 291 }; 292 element.find('.meta-slider > .products').addClass('owl-carousel').owlCarousel(slider_data); 293 } 294 295 var is_masonry = false; 296 if (atts.is_masonry && typeof $.fn.isotope === 'function' && typeof($.fn.imagesLoaded) === 'function') { 297 is_masonry = true; 298 } 299 300 if (is_masonry) { 301 var $container = element.find('.meta-slider > .products'); 302 $container.imagesLoaded(function() { 303 $container.isotope(); 304 }); 305 } 306 307 if (atts.show_load_more) { 308 element.on('click', 'a.load-more', function() { 309 var button = $(this); 310 if (button.hasClass('loading')) { 311 return false; 312 } 313 314 button.addClass('loading'); 315 var paged = button.attr('data-paged'), 316 appendProducts = element.find('.meta-slider > .products'); 317 318 $.ajax({
319 type: 'POST', 320 timeout: 30000, 321 url: mipro_settings.ajax_uri, 322 data: { action: 'kft_products_load_items', paged: paged, atts: atts }, 323 error: function(xhr, err) { 324 325 }, 326 success: function(response) { 327 button.removeClass('loading'); 328 button.attr('data-paged', ++paged); 329 330 if (response != 0 && response != '') { 331 if (element.hasClass('is-masonry') && typeof $.fn.isotope === 'function' && typeof $.fn.imagesLoaded === 'function') { 332 appendProducts.isotope('insert', $(response)); 333 appendProducts.imagesLoaded().progress(function() { 334 appendProducts.isotope('layout'); 335 }); 336 } else { 337 appendProducts.append(response); 338 } 339 } else { 340 button.parent().remove(); 341 } 342 MiproTheme.BootrapTooltip(); 343 MiproTheme.CountdownTimer(); 344 MiproTheme.LazyLoading(); 345 } 346 }); 347 348 return false; 349 }); 350 } 351 }); 352 }, 353 354 BlogMasonryShortcode: function() { 355 $('.kft-blogs-shortcode.masonry').each(function() { 356 var element = $(this); 357 if (typeof $.fn.isotope === 'function' && typeof $.fn.imagesLoaded === 'function') { 358 var blogMasonry = element.find('.blogs'); 359 blogMasonry.imagesLoaded(function() { 360 blogMasonry.isotope(); 361 }); 362 } 363 }); 364 365 $('.kft-blogs-shortcode.has-load-more').each(function() { 366 var element = $(this); 367 var atts = element.data('atts'); 368 element.on('click', 'a.load-more', function() { 369 var button = $(this); 370 if (button.hasClass('loading')) { 371 return false; 372 } 373 374 button.addClass('loading'); 375 var paged = button.attr('data-paged'), 376 appendBlogs = element.find('.blogs'); 377 378 $.ajax({
379 type: 'POST', 380 timeout: 30000, 381 url: mipro_settings.ajax_uri, 382 data: { action: 'kft_blogs_load_items', paged: paged, atts: atts }, 383 error: function(xhr, err) { 384 385 }, 386 success: function(response) { 387 button.removeClass('loading'); 388 button.attr('data-paged', ++paged); 389 if (response != 0 && response != '') { 390 if (element.hasClass('masonry') && typeof $.fn.isotope === 'function' && typeof $.fn.imagesLoaded === 'function') { 391 appendBlogs.isotope('insert', $(response)); 392 appendBlogs.imagesLoaded().progress(function() { 393 appendBlogs.isotope('layout'); 394 }); 395 } else { 396 appendBlogs.append(response); 397 398 var columns = parseInt(atts.columns); 399 element.find('.blogs .item').removeClass('first last'); 400 element.find('.blogs .item').each(function(index, ele) { 401 if (index % columns === 0) { 402 $(ele).addClass('first'); 403 } 404 if (index % columns === columns - 1) { 405 $(ele).addClass('last'); 406 } 407 }); 408 } 409 } else { 410 button.parent().remove(); 411 } 412 MiproTheme.BlogGallerySlider(); 413 MiproTheme.LazyLoading(); 414 } 415 }); 416 417 return false; 418 }); 419 }); 420 }, 421 422 BootrapTooltip: function() { 423 if ($(window).width() <= 1024) { 424 return; 425 } 426 427 var wrapper = $('.kft-tooltip, .social-sharing li a, .product-images-wrapper .product-zoom-button a, .product-images-wrapper .product-360-btn a'); 428 wrapper.tooltip({ 429 animation: false, 430 container: 'body', 431 trigger: 'hover', 432 placement: 'top', 433 title: function() { 434 return $(this).text(); 435 } 436 }); 437 438 var productBtn = $('.woocommerce .images div.kft-add-to-cart, .kft-product-buttons .compare, .kft-product-buttons .yith-wcwl-add-to-wishlist a, .kft-product-buttons .quickview'); 439 productBtn.tooltip({ 440 animation: false, 441 container: 'body', 442 trigger: 'hover', 443 placement: 'left', 444 title: function() { 445 if ($(this).find('.added_to_cart').length > 0) { 446 return $(this).find('.add_to_cart_button').text(); 447 } 448 return $(this).text(); 449 } 450 }); 451 452 productBtn.on( 'click' ,function() { 453 $( this ).tooltip( 'hide' ); 454 455 }); 456 457 $('.mipro-social-button .social-sharing li a').tooltip('destroy'); 458 }, 459 460 WooQuantity: function() { 461 $(document).on('click', '.plus, .minus', function() { 462 463 var $qty = $(this).closest('.quantity').find('.qty'), 464 currentVal = parseFloat($qty.val()), 465 max = parseFloat($qty.attr('max')), 466 min = parseFloat($qty.attr('min')), 467 step = $qty.attr('step'); 468 469 if (!currentVal || currentVal === '' || currentVal === 'NaN') { 470 currentVal = 0; 471 } 472 if (max === '' || max === 'NaN') { 473 max = ''; 474 } 475 if (min === '' || min === 'NaN') { 476 min = 0; 477 } 478 if (step === 'any' || step === '' || step === undefined || parseFloat(step) === 'NaN') { 479 step = 1; 480 } 481 482 if ($(this).is('.plus')) { 483 484 if (max && (max == currentVal || currentVal > max)) { 485 $qty.val(max); 486 } else { 487 $qty.val(currentVal + parseFloat(step)); 488 } 489 490 } else { 491 492 if (min && (min == currentVal || currentVal < min)) { 493 $qty.val(min); 494 } else if (currentVal > 0) { 495 $qty.val(currentVal - parseFloat(step)); 496 } 497 498 } 499 500 $qty.trigger('change'); 501 502 }); 503 }, 504 505 ProductImageSetting: function() { 506 if ($('.single-product').length > 0) { 507 $('.product-thumbnails').on('click', '.thumbnail-image a', function(e) { 508 e.preventDefault(); 509 }); 510 511 $('.product-images-wrapper > .images').each(function() { 512 var element = $(this); 513 element.addClass('owl-carousel').owlCarousel({ 514 loop: false, 515 nav: true, 516 navText: false, 517 dots: false, 518 navSpeed: 1000, 519 slideBy: 1, 520 rtl: $('body').hasClass('rtl'), 521 margin: 0, 522 autoplayTimeout: 5000, 523 responsiveRefreshRate: 400, 524 responsive: { 525 0: { 526 items: 1 527 } 528 }, 529 onInitialized: function() { 530 element.addClass('loaded').removeClass('loading'); 531 } 532 }); 533 }); 534 if ($('.product-images-wrapper > .images').hasClass('has-product-lightbox') && typeof PhotoSwipe != 'undefined') { 535 ProductLightbox(); 536 537 $('.product-images-wrapper').on('click', '.product-zoom-button', function(t) { 538 $('.product-images-wrapper > .images').find('.owl-item.active a').trigger('click'); 539 t.preventDefault(); 540 }); 541 } else { 542 $('.product-images-wrapper > .images').on('click', '.woocommerce-product-gallery__image a', function(e) { 543 e.preventDefault(); 544 }); 545 }
546 ProductThumbnailBottom(); 547 ProductThumbnailLeft(); 548 549 if ($(".has-product-zoom").length) { 550 if ($(window).width() > 1024) { 551 var prodZoom = $('.product-images-wrapper > .images.has-product-zoom .woocommerce-product-gallery__image').easyZoom({ 552 loadingNotice: '', 553 errorNotice: '', 554 preventClicks: false, 555 }); 556 var updateZoom = prodZoom.filter('.product-images-wrapper > .images.has-product-zoom .first').data('easyZoom'); 557 558 $('.variations').on('change', 'select', function() { 559 updateZoom.teardown(); 560 updateZoom._init(); 561 }); 562 } 563 } 564 565 $('form.variations_form').on('show_variation', function(e, variation, purchasable) { 566 $('.product-images-wrapper > .images').trigger('to.owl.carousel', 0); 567 568 var image_src = variation.image.src; 569 if (!image_src) { 570 return; 571 } 572 var $thumb = $('.thumbnails .thumbnail-image.first img'); 573 if (typeof $.fn.wc_set_variation_attr === 'function') { 574 $thumb.wc_set_variation_attr('src', image_src); 575 } 576 }); 577 578 $('form.variations_form').on('click', '.reset_variations', function() { 579 580 var $thumb = $('.thumbnails .thumbnail-image.first img'); 581 if (typeof $.fn.wc_reset_variation_attr === 'function') { 582 $thumb.wc_reset_variation_attr('src'); 583 } 584 }); 585 } 586 587 function ProductLightbox() { 588 $('.product-images-wrapper > .images').on('click', '.woocommerce-product-gallery__image a', function(e) { 589 e.preventDefault(); 590 var items = PhotoswipeItems(); 591 var index = $(this).find('img').attr('data-index'); 592 var pswpElement = $('.pswp')[0]; 593 var options = { 594 index: parseInt(index), 595 shareEl: false, 596 closeOnScroll: false, 597 history: false, 598 hideAnimationDuration: 0, 599 showAnimationDuration: 0 600 }; 601 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 602 gallery.init(); 603 }); 604 } 605 606 function PhotoswipeItems() { 607 var items = []; 608 $('.product-images-wrapper > .images .woocommerce-product-gallery__image a').each(function(index, ele) { 609 if ($(ele).parents('.owl-item.cloned').length === 0) { 610 var img = $(ele).find('img'); 611 var large_image_src = img.attr('data-large_image'); 612 var large_image_w = img.attr('data-large_image_width'); 613 var large_image_h = img.attr('data-large_image_height'); 614 var item = { 615 src: large_image_src, 616 w: large_image_w, 617 h: large_image_h, 618 title: img.attr('title') 619 }; 620 items.push(item); 621 } 622 }); 623 624 return items; 625 } 626 627 function ProductThumbnailBottom() { 628 var $thumbnail = $('.single-product .thumbnails:not(.vertical-thumbnail) .product-thumbnails'); 629 $thumbnail.addClass('owl-carousel').owlCarousel({ 630 loop: false, 631 nav: false, 632 navText: false, 633 dots: false, 634 navSpeed: 1000, 635 rtl: $('body').hasClass('rtl'), 636 margin: 15, 637 autoplay: true, 638 responsive: { 639 0: { 640 items: 1 641 }, 642 100: { 643 items: 2 644 }, 645 290: { 646 items: 3 647 } 648 }, 649 onInitialized: function() { 650 $thumbnail.addClass('loaded').removeClass('loading'); 651 } 652 }); 653 654 var $thumbSlider = $thumbnail.owlCarousel(), 655 $imageWrap = $('.product-images-wrapper > .images'); 656 657 $thumbnail.on('click', '.owl-item', function(e) { 658 var i = $(this).index(); 659 $thumbSlider.trigger('to.owl.carousel', i); 660 $imageWrap.trigger('to.owl.carousel', i); 661 }); 662 663 $imageWrap.on('changed.owl.carousel', function(e) { 664 var i = e.item.index; 665 $thumbSlider.trigger('to.owl.carousel', i); 666 $thumbnail.find('.is-selected').removeClass('is-selected'); 667 $thumbnail.find('.thumbnail-image').eq(i).addClass('is-selected'); 668 }); 669 $thumbnail.find('.thumbnail-image').eq(0).addClass('is-selected'); 670 } 671
672 function ProductThumbnailLeft() { 673 var $thumbnail = $('.single-product .thumbnails.vertical-thumbnail .product-thumbnails'); 674 if ($thumbnail.length > 0) { 675 var _slider_data = { 676 slidesToShow: 3, 677 dot: false, 678 lazy: 'ondemand', 679 slidesToScroll: 1, 680 vertical: true, 681 verticalSwiping: true, 682 infinite: false 683 }; 684 $thumbnail.slick(_slider_data); 685 $thumbnail.addClass('loaded').removeClass('loading'); 686 } 687 var $imageWrap = $('.product-images-wrapper > .images'); 688 $thumbnail.on('click', '.thumbnail-image', function(e) { 689 var i = $(this).index(); 690 $imageWrap.trigger('to.owl.carousel', i); 691 }); 692 693 $imageWrap.on('changed.owl.carousel', function(e) { 694 var i = e.item.index; 695 $thumbnail.on('init', function() { 696 $thumbnail.slick('slickGoTo', i, true); 697 }); 698 $thumbnail.find('.is-selected').removeClass('is-selected'); 699 $thumbnail.find('.thumbnail-image').eq(i).addClass('is-selected'); 700 }); 701 $thumbnail.find('.thumbnail-image').eq(0).addClass('is-selected'); 702 } 703 704 $('.single-product').on('click', 'a.woocommerce-review-link', function(t) { 705 $.scrollTo('.reviews_tab', { 706 duration: 300, 707 offset: -150 708 }); 709 }); 710 }, 711 712 VariationsProduct: function() { 713 $( '.variations_form' ).on( 'click', '.kft-product-attribute .variation-
713product__option a', function() { 714 var element = $( this ); 715 var val = element.closest( '.variation-product__option' ).data( 'variation' ); 716 var selector = element.closest( '.kft-product-attribute' ).siblings( 'select' ); 717 if ( 0 < selector.length ) { 718 if ( 0 < selector.find( 'option[value="' + val + '"]' ).length ) { 719 selector.val( val ).trigger( 'change' ); 720 element.closest( '.kft-product-attribute' ).find( '.variation-product__option' ).removeClass( 'selected' ); 721 element.closest( '.variation-product__option' ).addClass( 'selected' ); 722 } 723 } 724 return false; 725 }); 726 727 $( '.variations_form' ).on( 'click', '.reset_variations', function() { 728 $( this ).closest( '.variations' ).find( '.kft-product-attribute .variation-product__option' ).removeClass( 'selected' ); 729 }); 730 }, 731 732 ProductDefaultSlider: function() { 733 $('.single-product .related .products, .single-product .up-sells .products, .woocommerce .cross-sells .products').each(function() { 734 var element = $(this); 735 element.addClass('owl-carousel').owlCarousel({ 736 loop: false, 737 nav: false, 738 navText: false, 739 dots: true, 740 slideBy: 1, 741 rtl: $('body').hasClass('rtl'), 742 margin: 30, 743 autoplayTimeout: 5000, 744 responsive: { 745 0: { 746 items: 1 747 }, 748 667: { 749 items: 2 750 }, 751 736: { 752 items: 2 753 }, 754 800: { 755 items: 3 756 }, 757 1400: { 758 items: 4 759 } 760 }, 761 onInitialized: function() { 762 element.addClass('loaded').removeClass('loading'); 763 } 764 }); 765 }); 766 }, 767 768 RelatedPostSlider: function() { 769 $('.related-posts.loading .meta-slider > .blogs').each(function() { 770 var element = $(this); 771 772 element.addClass('owl-carousel').owlCarousel({ 773 loop: true, 774 nav: false, 775 navText: false, 776 dots: false, 777 slideBy: 1, 778 rtl: $('body').hasClass('rtl'), 779 margin: 30, 780 autoplayTimeout: 5000, 781 responsive: { 782 0: { 783 items: 1 784 }, 785 600: { 786 items: 1 787 }, 788 800: { 789 items: 3 790 }, 791 1400: { 792 items: 4 793 } 794 } 795 }); 796 }); 797 }, 798 799 BlogGallerySlider: function() { 800 $('.blog-image.gallery').each(function() { 801 var element = $(this); 802 element.addClass('owl-carousel').owlCarousel({ 803 items: 1, 804 loop: true, 805 nav: false, 806 dots: true, 807 navText: false, 808 slideBy: 1, 809 rtl: $('body').hasClass('rtl'), 810 margin: 0, 811 autoplay: true, 812 autoplayTimeout: 5000, 813 autoHeight: true, 814 responsive: { 815 0: { 816 items: 1 817 } 818 }, 819 onInitialized: function() { 820 element.addClass('loaded').removeClass('loading'); 821 } 822 823 }); 824 825 }); 826 }, 827 828 CountdownTimer: function() { 829 $('.countdown-timer').each(function() { 830 var time = $(this).data('countdown'); 831 $(this).countdown(time, function(event) { 832 $(this).html(event.strftime('' + 833 '<div class="days"><span class="number">%-D </span><div class="countdown-meta">' + mipro_settings.countdown_days + '</div></div> ' + 834 '<div class="hours"><span class="number">%H </span><div class="countdown-meta">' + mipro_settings.countdown_hours + '</div></div> ' + 835 '<div class="minutes"><span class="number">%M </span><div class="countdown-meta">' + mipro_settings.countdown_mins + '</div></div> ' + 836 '<div class="sec"><span class="number">%S </span><div class="countdown-meta">' + mipro_settings.countdown_sec + '</div></div>')); 837 }); 838 }); 839 }, 840 841 ProductWgSlider: function() { 842 $('.kft-product-items-widget.slider').each(function() { 843 var element = $(this); 844 var nav = element.data('nav') === 1; 845 var autoplay = element.data('auto_play') === 1; 846 var columns = element.data('columns'); 847 var margin = element.data('margin'); 848 849 element.addClass('owl-carousel').owlCarousel({ 850 loop: true, 851 items: 1, 852 nav: nav, 853 navText: false, 854 dots: false, 855 slideBy: 1, 856 rtl: $('body').hasClass('rtl'), 857 columns: columns, 858 margin: margin, 859 autoplay: autoplay, 860 autoplayTimeout: 5000, 861 responsive: { 862 0: { 863 items: columns 864 } 865 }, 866 onInitialized: function() { 867 element.addClass('loaded').removeClass('loading'); 868 } 869 }); 870 }); 871 }, 872 873 RecentPostWg: function() { 874 var element = $('.kft_recent_comments.is-slider, .kft_blog_widget.is-sli
874der'); 875 var nav = element.data('nav') === 1; 876 var autoplay = element.data('autoplay') === 1; 877 878 element.addClass('owl-carousel').owlCarousel({ 879 loop: false, 880 items: 1, 881 margin: 10, 882 nav: nav, 883 navText: false, 884 dots: false, 885 slideBy: 1, 886 rtl: $('body').hasClass('rtl'), 887 autoplay: autoplay, 888 autoplayTimeout: 5000, 889 responsive: { 890 0: { 891 items: 1 892 } 893 }, 894 onInitialized: function() { 895 element.addClass('loaded').removeClass('loading'); 896 } 897 }); 898 }, 899 900 WishlistAction: function() { 901 $('body').on('click', '.add_to_wishlist', function() { 902 $(this).parent().addClass('loading'); 903 }); 904 $('body').on('added_to_wishlist', function() { 905 WishlistButton(); 906 $('.yith-wcwl-wishlistaddedbrowse.show, .yith-wcwl-wishlistexistsbrowse.show').closest('.yith-wcwl-add-to-wishlist').removeClass('loading').addClass('added'); 907 }); 908 var WishlistButton = function() { 909 var wishlist = $('.header-wishlist'); 910 if (wishlist.length === 0) { 911 return; 912 } 913 914 wishlist.addClass('loading'); 915 $.ajax({
916 type: 'POST', 917 url: mipro_settings.ajax_uri, 918 data: { action: 'update_tini_wishlist' }, 919 success: function(response) { 920 var first_icon = wishlist.children('i.fa:first'); 921 wishlist.html(response); 922 if (first_icon.length > 0) { 923 wishlist.prepend(first_icon); 924 } 925 wishlist.removeClass('loading'); 926 } 927 }); 928 }; 929 930 $(document).on('click', '#yith-wcwl-form table tbody tr td a.remove, #yith-wcwl-form table tbody tr td a.add_to_cart_button', function() { 931 var old_num_product = $('#yith-wcwl-form table tbody tr[id^="yith-wcwl-row"]').length; 932 var count = 1; 933 var time_interval = setInterval(function() { 934 count++; 935 var new_num_product = $('#yith-wcwl-form table tbody tr[id^="yith-wcwl-row"]').length; 936 if (old_num_product != new_num_product || count === 20) { 937 clearInterval(time_interval); 938 WishlistButton(); 939 } 940 }, 500); 941 }); 942 }, 943 944 HideMessagePopup: function() { 945 var wrapper = '#yith-wcwl-popup-message'; 946 $('body').on('click', wrapper, function() { 947 $(wrapper).addClass('hidden-message'); 948 }); 949 }, 950 951 QuickviewAction: function() { 952 $(document).on('click', '.quickview', function(e) { 953 e.preventDefault(); 954 955 var id = $(this).data('id'), 956 prev = '', 957 next = '', 958 btn = $(this); 959 btn.addClass('loading'); 960 961 $.ajax({
962 url: mipro_settings.ajax_uri, 963 data: { 964 id: id, 965 action: 'load_quickshop_content' 966 }, 967 type: 'POST', 968 success: function(data) { 969 $.magnificPopup.open({ 970 items: { 971 src: '<div class="quick-view-popup">' + data + '</div>', 972 type: 'inline' 973 }, 974 tClose: '', 975 tLoading: '', 976 removalDelay: 500, 977 callbacks: { 978 beforeOpen: function() { 979 this.st.mainClass = 'mfp-move-horizontal' + ' quick-view-wrapper woocommerce'; 980 }, 981 open: function() { 982 $('.variations_form').each(function() { 983 $(this).wc_variation_form().find('.variations select:eq(0)').trigger('change'); 984 }); 985 $('.variations_form').trigger('wc_variation_form'); 986 } 987 }, 988 }); 989 990 var element = $('.kft-quickshop-wrapper .images-slider-wrapper'); 991 if (element.find('.woocommerce-product-gallery__image').length <= 1) { 992 return; 993 } 994 995 var owl = element.find('.image-items').addClass('owl-carousel').owlCarousel({ 996 items: 1, 997 loop: true, 998 nav: true, 999 navText: false, 1000 dots: true, 1001 slideBy: 1, 1002 rtl: $('body').hasClass('rtl'), 1003 margin: 0, 1004 autoplay: false, 1005 autoplayTimeout: 5000, 1006 onInitialized: function() { 1007 element.addClass('loaded').removeClass('loading'); 1008 } 1009 }); 1010 1011 var imgVariation = $('.kft-quickshop-wrapper .woocommerce-product-gallery__image.first img'); 1012 $('form.variations_form').on('show_variation', function(e, variation, purchasable) { 1013 $('.kft-quickshop-wrapper .images-slider-wrapper > .image-items').trigger('to.owl.carousel', 0); 1014 1015 var image_src = variation.image.src; 1016 if (!image_src) { 1017 return; 1018 } 1019 if (typeof $.fn.wc_set_variation_attr === 'function') { 1020 imgVariation.attr('srcset', '').wc_set_variation_attr('src', image_src); 1021 } 1022 }); 1023 1024 $('form.variations_form').on('click', '.reset_variations', function() { 1025 if (typeof $.fn.wc_reset_variation_attr === 'function') { 1026 imgVariation.wc_reset_variation_attr('src'); 1027 } 1028 }); 1029 1030 MiproTheme.VariationsProduct(); 1031 }, 1032 complete: function() { 1033 btn.removeClass('loading'); 1034 }, 1035 error: function() {}, 1036 }); 1037 }); 1038 }, 1039 1040 AccordionProductTab: function() { 1041 if ($('.woocommerce-tabs.accordion-product-tabs').length > 0) { 1042 $('a.woocommerce-review-link').on('click', function() { 1043 var reviews = $('#reviews').parents('.kc_accordion_section'); 1044 if (!reviews.hasClass('kc-section-active')) { 1045 reviews.find('>h3.kc_accordion_header a').trigger('click'); 1046 } 1047 $.scrollTo('.accordion-product-tabs', { 1048 duration: 300, 1049 offset: -150 1050 }); 1051 }); 1052 } 1053 }, 1054 1055 HoverGalleryProduct: function() { 1056 $('body').on('mouseenter mouseleave', '.kft_thumb_list_hover', function() { 1057 $(this).closest('.kft-product').find('.images a img').attr('src', $(this).attr('data-hover')); 1058 }); 1059 }, 1060 1061 AjaxSearch: function() { 1062 var results, 1063 form = $( '.kft_search_products' ), 1064 searchCache = new Array; 1065 1066 if ( 'undefined' === typeof mipro_settings.kft_enable_ajax_search || 1 != mipro_settings.kft_enable_ajax_search ) { 1067 return; 1068 } 1069 1070 $.xhrPool = []; 1071 $.xhrPool.abortAll = function() { 1072 $( this ).each( function( i, jqXHR ) { 1073 jqXHR.abort(); 1074 $.xhrPool.splice( i, 1 ); 1075 }); 1076 }; 1077 1078 $( '.kft_search_products' ).append( '<div class="kft-live-search-results"></div>' ); 1079 ( results = $( '.kft-live-search-results' ) ), 1080 form.on( 'keyup', 'input[type="text"]', function( e ) { 1081 var thisForm = $( this ).parents( '.searchform' ),
1082 s = thisForm.find( 'input[type="text"]' ).val(), 1083 cat = '', 1084 selectCat = $( this ).parents( '.kft_search_products' ).siblings( '.select-category' ); 1085 1086 results.hide(); 1087 1088 if ( 2 > s.length ) { 1089 form.removeClass( 'loading' ); 1090 return; 1091 } 1092 1093 if ( 0 < selectCat.length && '0' != selectCat.find( ':selected' ).val() ) { 1094 cat = selectCat.find( ':selected' ).val(); 1095 } 1096 1097 $.xhrPool.abortAll(); 1098 1099 if ( searchCache[s + cat] !== undefined ) { 1100 results.html( searchCache[s + cat]).show(); 1101 } else { 1102 $.ajax({ 1103 url: mipro_settings.ajax_uri, 1104 method: 'POST', 1105 cache: true, 1106 data: { 1107 action: 'mipro_ajax_search', 1108 security: mipro_settings.kft_ajax_search_nonce, 1109 s: s, 1110 cat: cat 1111 }, 1112 dataType: 'json', 1113 beforeSend: function( jqXHR ) { 1114 $.xhrPool.push( jqXHR ); 1115 1116 form.addClass( 'loading' ); 1117 results.hide(); 1118 }, 1119 complete: function( jqXHR ) { 1120 var i = $.xhrPool.indexOf( jqXHR ); 1121 if ( -1 < i ) { 1122 $.xhrPool.splice( i, 1 ); 1123 } 1124 1125 form.removeClass( 'loading' ); 1126 results.on( 'click', '.view-all a', function( e ) { 1127 e.preventDefault(); 1128 form.find( '.search-submit' ).trigger( 'click' ); 1129 }); 1130 }, 1131 success: function( response ) { 1132 searchCache[s + cat] = response.html; 1133 results.html( response.html ).show(); 1134 }, 1135 error: function() { } 1136 }); 1137 } 1138 1139 $( 'body' ).on( 'click', function( event ) { 1140 if ( ! $( event.target ).is( '.search-form-wrapper' ) && $( event.target ).closest( '.search-form-wrapper' ).length ) { 1141 return; 1142 } 1143 results.hide(); 1144 }); 1145 }); 1146 1147 $( '.search-form-wrapper' ).on( 'change', 'select.select-category', function() { 1148 $.xhrPool.abortAll(); 1149 $( this ).parents( '.search-form-wrapper' ).find( '.kft_search_products input[type="text"]' ).trigger( 'keyup' ); 1150 }); 1151 }, 1152 1153 CounterUpShortcode: function() { 1154 $('.kft-counter .number').counterUp({ 1155 delay: 10, 1156 time: 1000, 1157 formatter: function(n) { 1158 return n.replace(/,/g, '.'); 1159 } 1160 }); 1161 }, 1162 1163 VideoLightbox: function() { 1164 $('a.kft-video-lightbox').magnificPopup({ 1165 type: 'iframe', 1166 preloader: false, 1167 fixedContentPos: false 1168 }); 1169 }, 1170 1171 SizeChartProductImg: function() { 1172 $('a.size-guide-btn').magnificPopup({ 1173 type: 'image', 1174 closeOnContentClick: false, 1175 mainClass: 'mfp-img-mobile', 1176 image: { 1177 verticalFit: true 1178 }, 1179 zoom: { 1180 enable: true 1181 } 1182 }); 1183 }, 1184 1185 GalleryImagesShortcode: function() { 1186 $('.lightbox.kft-images-shortcode a').parent().magnificPopup({ 1187 delegate: 'a', 1188 type: 'image', 1189 closeBtnInside: false, 1190 tLoading: '<div class="loading"></div>', 1191 removalDelay: 300, 1192 gallery: { 1193 enabled: true, 1194 navigateByImgClick: true, 1195 arrowMarkup: '<button class="mfp-arrow mfp-arrow-%dir%" title="%title%"><i class="icon-angle-%dir%"></i></button>', 1196 preload: [0, 1] 1197 }, 1198 image: { 1199 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 1200 verticalFit: false 1201 }, 1202 zoom: { 1203 enabled: true, 1204 duration: 300 1205 } 1206 }); 1207 1208 $('.layout-masonry.kft-images-shortcode').each(function() { 1209 if (typeof($.fn.isotope) === 'undefined' || typeof($.fn.imagesLoaded) == 'undefined') { 1210 return; 1211 } 1212 var $container = $(this).find('.images-gallery'); 1213 $container.imagesLoaded(function() { 1214 $container.isotope({ 1215 gutter: 0, 1216 isOriginLeft: !$('body').hasClass('rtl'), 1217 itemSelector: '.images-gallery-item' 1218 }); 1219 }); 1220 }); 1221 1222 $('.layout-slider.kft-images-shortcode').each(function() { 1223 var element = $(this); 1224 var margin = element.data('margin'); 1225 var columns = element.data('columns'); 1226 var nav = element.data('nav') === 1; 1227 var dots = element.data('dots') === 1; 1228 var autoplay = element.data('autoplay') === 1;
1229 var desksmini = element.data('desksmini'); 1230 var tabletmini = element.data('tabletmini'); 1231 var tablet = element.data('tablet'); 1232 var mobile = element.data('mobile'); 1233 var mobilesmini = element.data('mobilesmini'); 1234 var _slider_data = { 1235 loop: false, 1236 nav: nav, 1237 dots: dots, 1238 slideBy: 1, 1239 navText: false, 1240 navRewind: false, 1241 rtl: $('body').hasClass('rtl'), 1242 margin: margin, 1243 autoplay: autoplay, 1244 autoplayTimeout: 5000, 1245 responsive: { 1246 0: { 1247 items: mobilesmini 1248 }, 1249 480: { 1250 items: mobile 1251 }, 1252 640: { 1253 items: tabletmini 1254 }, 1255 768: { 1256 items: tablet 1257 }, 1258 991: { 1259 items: desksmini 1260 }, 1261 1199: { 1262 items: columns 1263 } 1264 } 1265 }; 1266 element.find('.images-gallery').addClass('owl-carousel').owlCarousel(_slider_data); 1267 }); 1268 }, 1269 1270 BackgroundPrlx: function() { 1271 if ($(window).width() <= 1024) { 1272 return; 1273 } 1274 $('.kft-prlx-background').each(function() { 1275 $(this).parallax('50%', 0.3); 1276 }); 1277 }, 1278 1279 MegaMenuSetting: function() { 1280 var mainMenu = $( '.main-navigation' ).find( 'ul.menu' ), 1281 activeMega = mainMenu.find( ' > li.menu-item-sized, li.menu-item-full-width' ); 1282 var setOffset = function( li ) { 1283 var dropdown = li.find( ' > .sub-menu-dropdown' ), 1284 siteWrapper = $( '#wrapper' ); 1285 1286 var submenuWidth = dropdown.outerWidth(), 1287 submenuOffset = dropdown.offset(), 1288 windowWidth = $( window ).width(), 1289 bodyRight = siteWrapper.outerWidth() + siteWrapper.offset().left, 1290 viewportWidth = $( 'body' ).hasClass( 'wrapper-layout-boxed' ) ? bodyRight : windowWidth, 1291 extraSpace = li.hasClass( 'menu-item-full-width' ) ? 0 : 10; 1292 1293 if( ! submenuWidth || ! submenuOffset ) return; 1294 1295 var submenuOffsetRight = windowWidth - submenuOffset.left - submenuWidth; 1296 var toLeft = submenuOffsetRight + submenuWidth - viewportWidth; 1297 var toRight = submenuOffset.left + submenuWidth - viewportWidth; 1298 1299 dropdown.attr( 'style', '' ); 1300 1301 if ( $( 'body' ).hasClass( 'rtl' ) && submenuOffsetRight + submenuWidth >= viewportWidth && ( li.hasClass( 'menu-item-sized' ) || li.hasClass( 'menu-item-full-width' ) ) ) { 1302 dropdown.css({ 1303 right: -toLeft - extraSpace 1304 }); 1305 } else if ( submenuOffset.left + submenuWidth >= viewportWidth && ( li.hasClass( 'menu-item-sized' ) || li.hasClass( 'menu-item-full-width' ) ) ) { 1306 dropdown.css({ 1307 left: -toRight - extraSpace 1308 }); 1309 } 1310 }; 1311 1312 mainMenu.on( 'mouseenter mouseleave', ' > li.menu-item-sized, li.menu-item-full-width', function( e ) { 1313 setOffset( $( this ) ); 1314 }); 1315 1316 activeMega.each( function() { 1317 setOffset( $( this ) ); 1318 }); 1319 }, 1320 1321 MobileNavigation: function() { 1322 $('.kft-mobile-navigation .menu-item-has-children').append('<span class="sub-menu-icon"></span>');
1323 $('.kft-mobile-navigation').on('click', '.sub-menu-icon', function(e) { 1324 e.preventDefault(); 1325 1326 if ($(this).parent().hasClass('active')) { 1327 $(this).parent().removeClass('active').find('> ul').slideUp(200); 1328 $(this).parent().removeClass('active').find('.sub-menu-dropdown .container > ul, .sub-menu-dropdown > ul').slideUp(200); 1329 $(this).parent().find('> .icon-sub-menu').removeClass('up-icon'); 1330 } else { 1331 $(this).parent().addClass('active').find('> ul').slideDown(200); 1332 $(this).parent().addClass('active').find('.sub-menu-dropdown .container > ul, .sub-menu-dropdown > ul').slideDown(200); 1333 $(this).parent().find(' > .icon-sub-menu').addClass('up-icon'); 1334 } 1335 }); 1336 $('body').on('click', '.mobile-nav > a', function(e) { 1337 e.preventDefault(); 1338 if ($('body').hasClass('has-mobile-menu')) { 1339 $('body').removeClass('has-mobile-menu'); 1340 } else { 1341 $('body').addClass('has-mobile-menu'); 1342 } 1343 }); 1344 $('body').on('click touchstart', '.kft-close-popup', function() { 1345 $('body').removeClass('has-mobile-menu'); 1346 }); 1347 }, 1348 1349 HeaderSticky: function() { 1350 if ($('body').hasClass('has_sticky_header')) { 1351 var headerSticky = $('.sticky-header'), 1352 headerHeight = $('.site-header').outerHeight() + 100; 1353 1354 $(window).on('scroll', function() { 1355 if ($(this).scrollTop() > headerHeight) { 1356 headerSticky.addClass('is-sticky'); 1357 } else { 1358 headerSticky.removeClass('is-sticky'); 1359 } 1360 }); 1361 } 1362 }, 1363 1364 PopupNewletter: function() { 1365 1366 if (typeof mipro_settings.kft_enable_popup === 'undefined' || mipro_settings.kft_enable_popup != 1 || $(window).width() < 768) { 1367 return; 1368 } 1369 var show = false; 1370 1371 if ($.cookie('mipro_popup_show') != 'show') { 1372 if (mipro_settings.kft_popup_event === 'scroll') { 1373 $(window).on('scroll', function() { 1374 if (show) { 1375 return false; 1376 } 1377 if ($(document).scrollTop() >= mipro_settings.kft_popup_scroll) { 1378 showPopup(); 1379 show = true; 1380 } 1381 }); 1382 } else { 1383 setTimeout(function() { 1384 showPopup(); 1385 }, mipro_settings.kft_popup_timeout); 1386 } 1387 } 1388 1389 var showPopup = function() { 1390 $.magnificPopup.open({ 1391 items: { 1392 src: '.kft-popup' 1393 }, 1394 type: 'inline', 1395 removalDelay: 500, 1396 callbacks: { 1397 beforeOpen: function() { 1398 this.st.mainClass = 'mfp-move-horizontal' + ' promo-popup-wrapper'; 1399 }, 1400 open: function() {}, 1401 close: function() { 1402 $.cookie('mipro_popup_show', 'show', { expires: 7, path: '/' }); 1403 } 1404 } 1405 }); 1406 }; 1407 }, 1408 1409 Backtotop: function() { 1410 if ($('.back-to-top').length > 0) { 1411 $(window).on('scroll', function() { 1412 if ($(this).scrollTop() > 100) { 1413 $('.back-to-top').addClass('show'); 1414 } else { 1415 $('.back-to-top').removeClass('show'); 1416 } 1417 }); 1418 $('.back-to-top').on('click', '.scroll-button', function() { 1419 $('body, html').animate({ 1420 scrollTop: '0px' 1421 }, 800); 1422 return false; 1423 }); 1424 } 1425 }, 1426 1427 BannerPrlxShortcode: function() { 1428 $('.has-hover.image-hover-parallax .image').panr({ 1429 sensitivity: 20, 1430 scale: false, 1431 scaleOnHover: true, 1432 scaleTo: 1.12, 1433 scaleDuration: 0.34, 1434 panY: true, 1435 panX: true, 1436 panDuration: 0.5, 1437 resetPanOnMouseLeave: true 1438 }); 1439 }, 1440 1441 ShopSidebar: function() { 1442 $('body').on('click', '.kft-show-sidebar-button', function(e) { 1443 e.preventDefault(); 1444 if ($('.shop-sidebar').hasClass('show-hidden-sidebar')) { 1445 hideSidebar(); 1446 } else { 1447 showSidebar(); 1448 } 1449 }); 1450 $('body').on('click touchstart', '.kft-close-popup, .close-sidebar', function() { 1451 hideSidebar(); 1452 }); 1453 var showSidebar = function() { 1454 $('.shop-sidebar').addClass('show-hidden-sidebar'); 1455 $('body').addClass('show-shop-sidebar'); 1456 $('.kft-show-sidebar-button').addClass('shown'); 1457 }; 1458 var hideSidebar = function() { 1459 $('.kft-show-sidebar-button').removeClass('shown'); 1460 $('.shop-sidebar').removeClass('show-hidden-sidebar'); 1461 $('body').removeClass('show-shop-sidebar'); 1462 }; 1463 }, 1464 1465 ShopFilters: function() { 1466 $('body').on('click', '.kft-filters-button', function(e) { 1467 e.preventDefault(); 1468 if ($('.kft-filters-content').hasClass('show-filter-content')) { 1469 hideSidebar(); 1470 } else { 1471 showSidebar(); 1472 } 1473 }); 1474 $('body').on('click touchstart', '.kft-close-popup, .close-sidebar', function() { 1475 hideSidebar(); 1476 }); 1477 var showSidebar = function() { 1478 $('body').addClass('show-filter'); 1479 $('.kft-filters-content').addClass('show-filter-content'); 1480 $('.kft-filters-button').addClass('shown'); 1481 }; 1482 var hideSidebar = function() { 1483 $('.kft-filters-button').removeClass('shown'); 1484 $('.kft-filters-content').removeClass('show-filter-content'); 1485 $('body').removeClass('show-filter'); 1486 }; 1487 }, 1488 1489 loginSidebar: function() { 1490 var body = $('body'); 1491 $('.login-canvas').on('click', '.login', function(e) { 1492 e.preventDefault(); 1493 if (isOpened()) { 1494 hideLogin(); 1495 } else { 1496 setTimeout(function() { 1497 showLogin(); 1498 }, 10); 1499 } 1500 }); 1501 1502 body.on('click touchstart', '.kft-close-popup, .login-close', function() { 1503 if (isOpened()) { 1504 hideLogin(); 1505 } 1506 }); 1507 1508 var hideLogin = function() { 1509 body.removeClass('has-login-form'); 1510 }; 1511 1512 var showLogin = function() { 1513 if ($('body').hasClass('woocommerce-account')) { 1514 return false; 1515 } 1516 body.addClass('has-login-form'); 1517 }; 1518 1519 var isOpened = function() { 1520 return body.hasClass('has-login-form'); 1521 }; 1522 }, 1523 1524 CartSidebar: function() { 1525 var body = $('body'); 1526 $('.cart-canvas').on('click', '.kft_cart', function(e) { 1527 e.preventDefault(); 1528 if (isOpened()) { 1529 hideCartSidebar(); 1530 } else { 1531 setTimeout(function() { 1532 showCartSidebar(); 1533 }, 10); 1534 } 1535 }); 1536 1537 body.on('click', '.added-to-cart-message', function(e) { 1538 $('.added-to-cart-message').hide(); 1539 $('.cart-canvas').find('.kft_cart').trigger('click'); 1540 e.preventDefault(); 1541 }); 1542 1543 body.on('click touchstart', '.kft-close-popup, .close-cart', function() { 1544 if (isOpened()) { 1545 hideCartSidebar(); 1546 } 1547 }); 1548 1549 var hideCartSidebar = function() { 1550 body.removeClass('has-cart-sidebar'); 1551 }; 1552 1553 var showCartSidebar = function() { 1554 if (body.hasClass('woocommerce-checkout') || body.hasClass('woocommerce-cart')) { 1555 return false; 1556 } 1557 body.addClass('has-cart-sidebar'); 1558 }; 1559 1560 var isOpened = function() { 1561 return body.hasClass('has-cart-sidebar'); 1562 }; 1563 }, 1564 1565 CatMasonryShot: function() { 1566 var element = $('.kft-product-categories-shortcode.layout-masonry'), 1567 is_masonry = false; 1568 if (typeof $.fn.isotope === 'function' && typeof($.fn.imagesLoaded) === 'function') { 1569 is_masonry = true; 1570 } 1571 1572 if (is_masonry) { 1573 $(window).on('load', function() { 1574 var $container = element.find('.meta-slider > .products'); 1575 $container.imagesLoaded(function() { 1576 $container.isotope(); 1577 }); 1578 }); 1579 } 1580 }, 1581 1582 MessageAddtoCart: function() { 1583 var src, 1584 title, 1585 message = false; 1586 1587 $('body').on('click', '.ajax_add_to_cart', function() { 1588 $('.woocommerce-message').remove(); 1589 if ($('body').hasClass('woocommerce-wishlist')) { 1590 src = $(this).parents('tr').find('img.attachment-woocommerce_thumbnail').attr('src'); 1591 title = $(this).parents('tr').find('.product-name').html(); 1592 } else { 1593 src = $(this).parents('div.kft-product').find('img.attachment-woocommerce_thumbnail').attr('src'); 1594 title = $(this).parents('div.kft-product').find('.product-title').html(); 1595 } 1596 1597 if (typeof src !== 'undefined' && typeof title !== 'undefined') { 1598 message = '<div class="added-to-cart-message"><div class="product_message_wrapper"><div class="product_message_image"><img src="' + src + '" alt></div><div class="product_notification_text">' + title + mipro_settings.cart_message + '</div></div></div>'; 1599 } 1600 }); 1601 1602 $(document).on('added_to_cart', function(event, data) { 1603 if (message !== false) { 1604 $('body').prepend(message); 1605 } 1606 }); 1607 }, 1608 1609 StickyProduct: function() { 1610 if ($(window).width() <= 1024) { 1611 return; 1612 } 1613 var productSticky = $('.mipro_product_sticky'); 1614 $('.product-single-wrapper').waypoint({ 1615 handler: function(d) { 1616 productSticky.toggleClass('shown', d === 'down'); 1617 } 1618 }); 1619 1620 productSticky.on('click', '.kft-add-to-cart a:not(".ajax_add_to_cart, .added_to_cart")', function(e) { 1621 e.preventDefault(); 1622 $.scrollTo('.product-single-wrapper', { 1623 duration: 300, 1624 offset: -150 1625 }); 1626 }); 1627 }, 1628 1629 LazyLoading: function() { 1630 $('img.lazyload').Lazy();
1631 }, 1632 1633 ColorSwatches: function() { 1634 $('body').on('click', '.color-swatch', function() { 1635 var src, srcset, 1636 imageSrc = $(this).data('src'), 1637 imageSrcset = $(this).data('srcset'), 1638 product = $(this).parents('.kft-product'), 1639 image = product.find('.images > a > img'), 1640 currentSrc = image.data('current-src'), 1641 currentSrcset = image.data('current-srcset'); 1642 1643 if (typeof imageSrc === 'undefined') { 1644 return; 1645 } 1646 1647 if (typeof currentSrc === 'undefined') { 1648 currentSrc = image.data('current-src', image.attr('src')); 1649 } 1650 1651 if (typeof currentSrcset === 'undefined') { 1652 if (typeof image.attr('srcset') === 'undefined') { 1653 currentSrcset = image.data('current-srcset', ''); 1654 } else { 1655 currentSrcset = image.data('current-srcset', image.attr('srcset')); 1656 } 1657 } 1658 1659 if ($(this).hasClass('chosen')) { 1660 src = currentSrc; 1661 srcset = currentSrcset; 1662 $(this).removeClass('chosen'); 1663 } else { 1664 $(this).parent().find('.chosen').removeClass('chosen'); 1665 src = imageSrc; 1666 srcset = imageSrcset; 1667 $(this).addClass('chosen'); 1668 } 1669 1670 if (image.attr('src') === src) { 1671 return; 1672 } 1673 1674 image.attr('src', src).attr('srcset', srcset); 1675 1676 }); 1677 }, 1678 1679 CookieNotice: function() { 1680 if (typeof mipro_settings.kft_cookie_notice === 'undefined' || mipro_settings.kft_cookie_notice != 1) { 1681 return; 1682 } 1683 if ($.cookie('mipro_show_cookie') == '1') { 1684 return; 1685 } 1686 var body = $('body'),
1687 cookiePopup = $('.mipro-cookie-notice'), 1688 expiry = parseInt(mipro_settings.kft_cookie_expiry); 1689 1690 setTimeout(function() { 1691 body.addClass('cookie-show'); 1692 cookiePopup.on('click', '.cookie-accept', function(e) { 1693 e.preventDefault(); 1694 body.removeClass('cookie-show'); 1695 $.cookie('mipro_show_cookie', '1', { expires: expiry, path: '/' }); 1696 }); 1697 }, 2000); 1698 }, 1699 1700 ProductVideo360: function() { 1701 $('.product-360-btn a').magnificPopup({ 1702 type: 'inline', 1703 mainClass: 'product-360-wrap', 1704 preloader: false, 1705 fixedContentPos: false, 1706 callbacks: { 1707 open: function() { 1708 $(window).resize() 1709 }, 1710 }, 1711 }); 1712 }, 1713 1714 infiniteProduct: function() { 1715 var container = $('.archive .woocommerce > .products'), 1716 paginationNext = '.woocommerce-pagination li a.next'; 1717 if (container.length === 0 || $(paginationNext).length === 0) { 1718 return; 1719 } 1720 if (mipro_settings.kft_shop_pagination === 'pagination') { 1721 return; 1722 } 1723 var loadMore = $('.mipro-products-load-more'); 1724 var loadProduct = container.infiniteScroll({ 1725 path: paginationNext, 1726 append: '.product', 1727 checkLastPage: true, 1728 status: '.page-load-status', 1729 hideNav: '.woocommerce-pagination', 1730 button: '.mipro-products-load-more', 1731 history: 'push', 1732 debug: false, 1733 scrollThreshold: 400 1734 }); 1735 1736 if (mipro_settings.kft_shop_pagination === 'loadmore') { 1737 loadMore.removeClass('hidden'); 1738 loadProduct.infiniteScroll('option', { 1739 scrollThreshold: false, 1740 loadOnScroll: false 1741 }); 1742 } 1743 1744 if (mipro_settings.kft_shop_pagination === 'infinit') { 1745 loadProduct.infiniteScroll('option', { 1746 scrollThreshold: true, 1747 loadOnScroll: true 1748 }); 1749 } 1750 1751 loadProduct.on('request.infiniteScroll', function(event, path) { 1752 if (loadMore) { 1753 loadMore.addClass('loading'); 1754 } 1755 }); 1756 1757 loadProduct.on('append.infiniteScroll', function(event, response, path, items) { 1758 if (loadMore) { 1759 loadMore.removeClass('loading'); 1760 } 1761 $(items).find('img').each(function(index, img) { 1762 img.outerHTML = img.outerHTML 1763 }); 1764 MiproTheme.BootrapTooltip(); 1765 MiproTheme.LazyLoading(); 1766 }); 1767 }, 1768 1769 GridListShop: function() { 1770 if (typeof $.cookie == 'function') { 1771 if ($.cookie('mipro_grid_list')) { 1772 $('.shop-content div.products').addClass($.cookie('mipro_grid_list')); 1773 $('.grid_list_nav a').removeClass('active'); 1774 $('.grid_list_nav #' + $.cookie('mipro_grid_list')).addClass('active'); 1775 } else { 1776 $('.shop-content div.products').addClass(mipro_settings.kft_grid_list); 1777 $('.grid_list_nav #' + mipro_settings.kft_grid_list).addClass('active'); 1778 } 1779 1780 $('#grid, #list').on('click', function() { 1781 if ($(this).hasClass('active')) { 1782 return; 1783 } 1784 1785 var id = $(this).attr('id'), 1786 currentClass = (id == 'grid') ? 'list' : 'grid'; 1787 1788 $('#grid, #list').removeClass('active'); 1789 $(this).addClass('active'); 1790 1791 $.cookie('mipro_grid_list', id, { path: '/' });
1792 $('.shop-content div.products').fadeOut(300, function() { 1793 $(this).removeClass(currentClass).addClass(id).fadeIn(300); 1794 }); 1795 }); 1796 1797 $('.grid_list_nav a').on('click', function(e) { 1798 e.preventDefault(); 1799 }); 1800 } 1801 }, 1802 1803 AjaxShop: function() { 1804 if (!$('body').hasClass('is_ajax_shop') || typeof($.fn.pjax) == 'undefined') { 1805 return; 1806 } 1807 var that = this, 1808 body = $('body'), 1809 ajaxLinks = 'a.kft-per-page-options, .widget_product_categories a, .product-categories-wg a, .product-filter-by-color a, .mipro-active-filters a, .woocommerce-pagination a, .widget_layered_nav_filters a, .widget_layered_nav a, .widget_product_tag_cloud a'; 1810 1811 var scrollToTop = function() { 1812 $.scrollTo('.site-main', { 1813 duration: 400, 1814 offset: -80 1815 }); 1816 }; 1817 1818 $(document).pjax(ajaxLinks, '.site-main', { 1819 timeout: 6000, 1820 scrollTo: false, 1821 fragment: '.site-main' 1822 }); 1823 1824 $(document).on('click', '.widget_price_filter form .button', function() { 1825 var form = $('.widget_price_filter form'); 1826 $.pjax({ 1827 container: '.site-main', 1828 fragment: '.site-main', 1829 timeout: 5000, 1830 url: form.attr('action'), 1831 data: form.serialize(), 1832 scrollTo: false 1833 }); 1834 1835 return false; 1836 }); 1837 1838 $(document).on('pjax:start', function(xhr, options) { 1839 body.addClass('shop-loading'); 1840 scrollToTop(); 1841 }); 1842 1843 $(document).on('pjax:complete', function(xhr, textStatus, options) { 1844 that.BootrapTooltip(); 1845 that.CountdownTimer(); 1846 that.LazyLoading(); 1847 that.wooPriceSlider(); 1848 that.GridListShop(); 1849 that.infiniteProduct(); 1850 that.ProductWgSlider(); 1851 that.OrderByWoo(); 1852 1853 body.removeClass('shop-loading'); 1854 body.removeClass('show-filter'); 1855 body.removeClass('show-shop-sidebar'); 1856 }); 1857 1858 $(document).on('pjax:end', function(xhr, textStatus, options) { 1859 body.removeClass('shop-loading'); 1860 }); 1861 1862 $(document).on('pjax:error', function(xhr, textStatus, error, options) { 1863 console.log('pjax error ' + error); 1864 }); 1865 1866 $(document).on('yith-wcan-ajax-loading', function() { 1867 if ($('.yit-wcan-container').length) { 1868 scrollToTop(); 1869 } 1870 }); 1871 }, 1872 1873 OrderByWoo: function() { 1874 $('form.woocommerce-ordering ul.orderby ul a').on('click', function(e) { 1875 e.preventDefault(); 1876 if ($(this).hasClass('current')) { 1877 return; 1878 } 1879 1880 var $form = $('form.woocommerce-ordering'); 1881 1882 $(this).closest($form).find('select.orderby').val($(this).attr('data-orderby')); 1883 1884 if (!$('body').hasClass('is_ajax_shop') || typeof($.fn.pjax) == 'undefined') { 1885 $(this).closest('form.woocommerce-ordering').trigger('submit'); 1886 } else { 1887 $form.find('[name="_pjax"]').remove(); 1888 1889 $.pjax({ 1890 container: '.site-main', 1891 fragment: '.site-main', 1892 timeout: 5000, 1893 data: $form.serialize(), 1894 scrollTo: false 1895 }); 1896 } 1897 }); 1898 }, 1899 1900 wooPriceSlider: function() { 1901 if (typeof woocommerce_price_slider_params === 'undefined' || !$.fn.slider) { 1902 return false; 1903 } 1904 1905 $('input#min_price, input#max_price').hide(); 1906 $('.price_slider, .price_label').show(); 1907 1908 var $products = $('.products'), 1909 min_price = $('.price_slider_amount #min_price').data('min'), 1910 max_price = $('.price_slider_amount #max_price').data('max'), 1911 current_min_price = parseInt(min_price, 10), 1912 current_max_price = parseInt(max_price, 10); 1913 1914 if ($products.attr('data-min_price') && $products.attr('data-min_price').length) { 1915 current_min_price = parseInt($products.attr('data-min_price'), 10); 1916 } 1917 if ($products.attr('data-max_price') && $products.attr('data-max_price').length) { 1918 current_max_price = parseInt($products.attr('data-max_price'), 10); 1919 } 1920 1921 $('.price_slider').slider({ 1922 range: true, 1923 animate: true, 1924 min: min_price, 1925 max: max_price, 1926 values: [current_min_price, current_max_price, ], 1927 create: function() { 1928 1929 $('.price_slider_amount #min_price').val(current_min_price); 1930 $('.price_slider_amount #max_price').val(current_max_price); 1931 1932 $(document.body).trigger('price_slider_create', [current_min_price, current_max_price, ]); 1933 }, 1934 slide: function(event, ui) { 1935 1936 $('input#min_price').val(ui.values[0]); 1937 $('input#max_price').val(ui.values[1]); 1938 1939 $(document.body).trigger('price_slider_slide', [ui.values[0], ui.values[1], ]); 1940 }, 1941 change: function(event, ui) { 1942 1943 $(document.body).trigger('price_slider_change', [ui.values[0], ui.values[1], ]); 1944 }, 1945 }); 1946 1947 setTimeout(function() { 1948 $(document.body).trigger('price_slider_create', [current_min_price, current_max_price, ]); 1949 }, 10); 1950 }, 1951 1952 preloadJs: function() { 1953 var loaded = $( '.kft-preload-wrapper' ); 1954 1955 if ( loaded.length ) {
1956 loaded.css( { 1957 'opacity':'0', 1958 'visibility':'hidden', 1959 } ); 1960 } 1961 1962 $('body').css('opacity', '1'); 1963 }, 1964 1965 }; 1966 1967 $(document).ready(function() { 1968 MiproTheme.init(); 1969 }); 1970 1971})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.