Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function amountInit() {
- $(".cart-products__item, .shop2-product-item, .shop2-product, .kind-item, .popup-product").each(function() {
- var $this = $(this);
- var $amountWrap = $this.find(".shop2-product-amount");
- var $input = $amountWrap.find('input[type="text"]');
- var $buttons = $amountWrap.find("button");
- var $minus = $amountWrap.find("button.amount-minus");
- var $plus = $amountWrap.find("button.amount-plus");
- var min = $amountWrap.find('input').data('min');
- var inputVal = +$input.val();
- if (inputVal<=min) {
- $minus.attr("disabled", "disabled");
- }
- $buttons.on("click", function(){
- var parent = $(this).parent();
- var input = parent.find("input");
- setTimeout(function(){
- var inputVal = +input.val();
- if (inputVal<=min) {
- $minus.attr("disabled", "disabled");
- } else {
- $minus.removeAttr("disabled");
- }
- }, 100);
- });
- $input.on("change", function(e) {
- var curVal = +$(this).val();
- if (curVal < min) {
- $(this).val(min);
- } else if (curVal == min) {
- $minus.attr("disabled", "disabled");
- } else if (curVal > min) {
- $minus.removeAttr("disabled");
- }
- });
- });
- };
Add Comment
Please, Sign In to add comment