laipower/wp-content/plugins/gp-premium/woocommerce/functions/js/woocommerce.min.js

1 line
4.1 KiB
JavaScript
Raw Normal View History

jQuery(document).ready(function(c){function t(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))}}var m;function a(){var t,n=c(".woocommerce div.product form.cart");n.closest(".elementor-add-to-cart").length?c(".elementor.product").removeClass("do-quantity-buttons"):(t=c(".cart div.quantity:not(.buttons-added), .cart td.quantity:not(.buttons-added)").find(".qty"))&&c.each(t,function(t,a){var e,s=c(a);"date"!==s.prop("type")&&"hidden"!==s.prop("type")&&(s.parent().addClass("buttons-added").prepend('<a href="javascript:void(0)" class="minus">-</a>'),s.after('<a href="javascript:void(0)" class="plus">+</a>'),c("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseFloat(c(this).attr("min"));t&&0<t&&parseFloat(c(this).val())<t&&c(this).val(t)}),c("body").hasClass("single-product")&&!n.hasClass("grouped_form")&&(e=c(".woocommerce form input[type=number].qty")).on("keyup",function(){var t=c(this).val();e.val(t)}),c(".plus, .minus").unbind("click"),c(".plus, .minus").on("click",function(){var t=!c("body").hasClass("single-product")||n.hasClass("grouped_form")||n.hasClass("cart_group")?c(this).closest(".quantity").find(".qty"):c(".plus, .minus").closest(".quantity").find(".qty"),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),c(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")}))})}c("body").on("added_to_cart",function(){c(".wc-menu-item").hasClass("has-items")||c(".wc-menu-item").addClass("has-items"),c(".wc-mobile-cart-items").hasClass("has-items")||c(".wc-mobile-cart-items").addClass("has-items")}),c("body").on("removed_from_cart",function(){var t=c(".number-of-items");t.length&&t.hasClass("no-items")&&(c(".wc-menu-item").removeClass("has-items"),c(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(c(document.body).on("added_to_cart",function(){var t=c("#wpadminbar"),a=c(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),c(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),c(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),c(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),c(window).on("scroll",t(function(){var t=c(".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&&(m=0,c(window).on("scroll",t(function(){var t=c("#wpadminbar"),a=c(".navigation-stick"),e=0,s=c(window).scrollTop(),o=c(".add-to-cart-panel"),n=o.offset().top+o.outerHeight(),r=c(".single_add_to_cart_button"),i=r.offset().top,l=r.outerHeight(),d=c(".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()),m=s):e+=a.outerHeight()),i+l<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)),c(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=c(".navigation-stick"),s=c("#wpadminbar");e.length&&(a=e.outerHeight()),s.length&&(a+=s.outerHeight()),c("html, body").animate({scrollTop:c(".variations").offset().top-a},250)})),c(document).on("ready",function(){"use strict";generateWooCommerce.quantityButtons&&a()}),c