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

1 line
3.8 KiB
JavaScript

jQuery(function(d){function t(t,a){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},a))}}var m;function a(){try{return generateWooCommerce.hooks.generateQuantityButtons()}catch(t){}var a,e;if(d(".woocommerce div.product form.cart").first().closest(".elementor-add-to-cart").length)d(".elementor.product").removeClass("do-quantity-buttons");else{try{a=generateWooCommerce.selectors.generateQuantityButtons.quantityBoxes}catch(t){a=d(".cart div.quantity:not(.buttons-added), .cart td.quantity:not(.buttons-added)").find(".qty")}try{if(0===a.length)return}catch(t){return}try{e=generateWooCommerce.callbacks.generateQuantityButtons.quantityBoxes}catch(t){e=function(t,a){var e,s=d(a);-1===["date","hidden"].indexOf(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>'),(e=parseFloat(d(this).attr("min")))&&0<e&&parseFloat(d(this).val())<e&&d(this).val(e),s.parent().find(".plus, .minus").on("click",function(){var t=parseFloat(s.val()),a=parseFloat(s.attr("max")),e=parseFloat(s.attr("min")),o=s.attr("step");t&&""!==t&&"NaN"!==t||(t=0),""!==a&&"NaN"!==a||(a=""),""!==e&&"NaN"!==e||(e=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),d(this).is(".plus")?a&&(a===t||a<t)?s.val(a):s.val(t+parseFloat(o)):e&&(e===t||t<e)?s.val(e):0<t&&s.val(t-parseFloat(o)),s.trigger("change")}))}}d.each(a,e)}}d("body").on("added_to_cart",function(){d(".wc-menu-item").hasClass("has-items")||d(".wc-menu-item").addClass("has-items"),d(".wc-mobile-cart-items").hasClass("has-items")||d(".wc-mobile-cart-items").addClass("has-items")}),d("body").on("removed_from_cart",function(){var t=d(".number-of-items");t.length&&t.hasClass("no-items")&&(d(".wc-menu-item").removeClass("has-items"),d(".wc-mobile-cart-items").removeClass("has-items"))}),generateWooCommerce.addToCartPanel&&(d(document.body).on("added_to_cart",function(){var t=d("#wpadminbar"),a=d(".navigation-stick"),e=0;t.length&&(e=t.outerHeight()),a.length&&"0px"===a.css("top")&&(e+=a.outerHeight()),d(".add-to-cart-panel").addClass("item-added").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"})}),d(".add-to-cart-panel .continue-shopping").on("click",function(t){t.preventDefault(),d(".add-to-cart-panel").removeClass("item-added").css({"-webkit-transform":"translateY(-100%)","-ms-transform":"translateY(-100%)",transform:"translateY(-100%)"})}),d(window).on("scroll",t(function(){var t=d(".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,d(window).on("scroll",t(function(){var t=d("#wpadminbar"),a=d(".navigation-stick"),e=0,o=d(window).scrollTop(),s=d(".add-to-cart-panel"),r=s.offset().top+s.outerHeight(),n=d(".single_add_to_cart_button"),i=n.offset().top,c=n.outerHeight(),l=d(".site-footer").offset().top;t.length&&(e=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(o<m&&"0px"===a.css("top")&&(e+=a.outerHeight()),m=o):e+=a.outerHeight()),i+c<o&&r<l?s.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+e+"px)","-ms-transform":"translateY("+e+"px)",transform:"translateY("+e+"px)"}):s.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},250)),d(".go-to-variables").on("click",function(t){t.preventDefault();var a=0,e=d(".navigation-stick"),o=d("#wpadminbar");e.length&&(a=e.outerHeight()),o.length&&(a+=o.outerHeight()),d("html, body").animate({scrollTop:d(".variations").offset().top-a},250)})),d(function(){"use strict";generateWooCommerce.quantityButtons&&a()}),d(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})});