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

1 line
3.9 KiB
JavaScript
Raw Normal View History

jQuery(function(d){function t(t,a){var e;return function(){clearTimeout(e),e=setTimeout(function(){e=void 0,t.call()},a)}}var m,u;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 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>'),(a=parseFloat(d(this).attr("min")))&&0<a&&parseFloat(d(this).val())<a&&d(this).val(a),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,u=300,d(window).on("scroll",t(function(){var t=d("#wpadminbar"),a=d(".navigation-stick"),e=d(".stuckElement"),o=0,s=d(window).scrollTop(),r=d(".add-to-cart-panel"),n=r.offset().top+r.outerHeight(),i=d(".single_add_to_cart_button"),c=i.offset().top,i=i.outerHeight(),l=d(".site-footer").offset().top;0===e.length&&(u=0),c+i<s&&n<l?setTimeout(function(){t.length&&(o=t.outerHeight()),a.length&&(a.hasClass("auto-hide-sticky")?(s<m&&"0px"===a.css("top")&&(o+=a.outerHeight()),m=s):o+=a.outerHeight()),r.addClass("show-sticky-add-to-cart").css({"-webkit-transform":"translateY("+o+"px)","-ms-transform":"translateY("+o+"px)",transform:"translateY("+o+"px)"})},u):r.removeClass("show-sticky-add-to-cart").css({"-webkit-transform":"","-ms-transform":"",transform:""})},50)),d(".go-to-variables").on("click",function(t){t.preventDefault();var t=0,a=d(".navigation-stick"),e=d("#wpadminbar");a.length&&(t=a.outerHeight()),e.length&&(t+=e.outerHeight()),d("html, body").animate({scrollTop:d(".variations").offset().top-t},250)})),d(function(){"use strict";generateWooCommerce.quantityButtons&&a()}),d(document).ajaxComplete(function(){"use strict";generateWooCommerce.quantityButtons&&a()})});