2 lines
4.2 KiB
JavaScript
2 lines
4.2 KiB
JavaScript
jQuery(document).ready(function(l){var t=function(s,o,n){var r,i;return o||(o=250),function(){var t=n||this,a=+new Date,e=arguments;r&&a<r+o?(clearTimeout(i),i=setTimeout(function(){r=a,s.apply(t,e)},o)):(r=a,s.apply(t,e))}};if(l(".wc-has-gallery .wc-product-image").hover(function(){l(this).find(".secondary-image").css("opacity","1")},function(){l(this).find(".secondary-image").css("opacity","0")}),l("body").on("added_to_cart",function(){l(".wc-menu-item").hasClass("has-items")||l(".wc-menu-item").addClass("has-items"),l(".wc-mobile-cart-items").hasClass("has-items")||l(".wc-mobile-cart-items").addClass("has-items")}),l("body").on("removed_from_cart",function(){var t=l(".number-of-items");t.length&&t.hasClass("no-items")&&(l(".wc-menu-item").removeClass("has-items"),l(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(l(document.body).on("added_to_cart",function(){var t=l("#wpadminbar"),a=l(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),l(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),l(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),l(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),l(window).on("scroll",t(function(){var t=l(".add-to-cart-panel");t.hasClass("item-added")&&t.removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})},250))),generateWooCommerce.stickyAddToCart){var m=0;l(window).on("scroll",t(function(){var t=l("#wpadminbar"),a=l(".navigation-stick"),e=0,s=l(window).scrollTop(),o=l(".add-to-cart-panel"),n=o.offset().top+o.outerHeight(),r=l(".single_add_to_cart_button"),i=r.offset().top,c=r.outerHeight(),d=l(".site-footer").offset().top;t.length&&(e=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(s<m&&"0px"===a.css("top")?e+=a.outerHeight():e=e,m=s):e+=a.outerHeight()),i+c<s&&n<d?o.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"}):o.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},250)),l(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=l(".navigation-stick"),s=l("#wpadminbar");e.length&&(a=e.outerHeight()),s.length&&(a+=s.outerHeight()),l("html, body").animate({scrollTop:l(".variations").offset().top-a},250)})}function a(n){var t,r=l(".woocommerce div.product form.cart");if(r.closest(".elementor-add-to-cart").length)l(".elementor.product").removeClass("do-quantity-buttons");else if(n||(n=".qty"),(t=l("div.quantity:not(.buttons-added), td.quantity:not(.buttons-added)").find(n))&&"date"!==t.prop("type")&&"hidden"!==t.prop("type")){if(t.parent().addClass("buttons-added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),t.after('<a href="javascript:void(0)" class="plus">+</a>'),l("input"+n+":not(.product-quantity input"+n+")").each(function(){var t=parseFloat(l(this).attr("min"));t&&0<t&&parseFloat(l(this).val())<t&&l(this).val(t)}),l("body").hasClass("single-product")&&!r.hasClass("grouped_form")){var a=l(".woocommerce form input[type=number].qty");a.on("keyup",function(){var t=l(this).val();a.val(t)})}l(".plus, .minus").unbind("click"),l(".plus, .minus").on("click",function(){var t;t=!l("body").hasClass("single-product")||r.hasClass("grouped_form")||r.hasClass("cart_group")?l(this).closest(".quantity").find(n):l(".plus, .minus").closest(".quantity").find(n);var a=parseFloat(t.val()),e=parseFloat(t.attr("max")),s=parseFloat(t.attr("min")),o=t.attr("step");a&&""!==a&&"NaN"!==a||(a=0),""!==e&&"NaN"!==e||(e=""),""!==s&&"NaN"!==s||(s=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),l(this).is(".plus")?e&&(e==a||e<a)?t.val(e):t.val(a+parseFloat(o)):s&&(s==a||a<s)?t.val(s):0<a&&t.val(a-parseFloat(o)),t.trigger("change")})}}l(document).on("ready",function(){"use strict";generateWooCommerce.quantityButtons&&a()}),l(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})});
|