From c9355337e29156899bc9b31be7399a9e6eca5a0c Mon Sep 17 00:00:00 2001 From: Leon Francis Shelhamer Date: Fri, 12 May 2017 15:49:13 -0400 Subject: [PATCH] Prevent adding increment buttons to hidden fields --- assets/js/wc-quantity-increment.js | 2 +- assets/js/wc-quantity-increment.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/wc-quantity-increment.js b/assets/js/wc-quantity-increment.js index 45c5bbc..9838824 100644 --- a/assets/js/wc-quantity-increment.js +++ b/assets/js/wc-quantity-increment.js @@ -12,7 +12,7 @@ jQuery( function( $ ) { } function wcqi_refresh_quantity_increments(){ - $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '' ).prepend( '' ); + $( 'div.quantity:not(.buttons_added):not(:has(input:hidden)), td.quantity:not(.buttons_added):not(:has(input:hidden))' ).addClass( 'buttons_added' ).append( '' ).prepend( '' ); } $( document ).on( 'updated_wc_div', function() { diff --git a/assets/js/wc-quantity-increment.min.js b/assets/js/wc-quantity-increment.min.js index 7c1edb2..fdd647b 100644 --- a/assets/js/wc-quantity-increment.min.js +++ b/assets/js/wc-quantity-increment.min.js @@ -1 +1 @@ -jQuery(function(a){function b(){a("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('').prepend('')}String.prototype.getDecimals||(String.prototype.getDecimals=function(){var a=this,b=(""+a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return b?Math.max(0,(b[1]?b[1].length:0)-(b[2]?+b[2]:0)):0}),a(document).on("updated_wc_div",function(){b()}),a(document).on("click",".plus, .minus",function(){var b=a(this).closest(".quantity").find(".qty"),c=parseFloat(b.val()),d=parseFloat(b.attr("max")),e=parseFloat(b.attr("min")),f=b.attr("step");c&&""!==c&&"NaN"!==c||(c=0),""!==d&&"NaN"!==d||(d=""),""!==e&&"NaN"!==e||(e=0),"any"!==f&&""!==f&&void 0!==f&&"NaN"!==parseFloat(f)||(f=1),a(this).is(".plus")?d&&c>=d?b.val(d):b.val((c+parseFloat(f)).toFixed(f.getDecimals())):e&&c<=e?b.val(e):c>0&&b.val((c-parseFloat(f)).toFixed(f.getDecimals())),b.trigger("change")}),b()}); \ No newline at end of file +jQuery(function(a){function b(){a("div.quantity:not(.buttons_added):not(:has(input:hidden)), td.quantity:not(.buttons_added):not(:has(input:hidden))").addClass("buttons_added").append('').prepend('')}String.prototype.getDecimals||(String.prototype.getDecimals=function(){var a=this,b=(""+a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return b?Math.max(0,(b[1]?b[1].length:0)-(b[2]?+b[2]:0)):0}),a(document).on("updated_wc_div",function(){b()}),a(document).on("click",".plus, .minus",function(){var b=a(this).closest(".quantity").find(".qty"),c=parseFloat(b.val()),d=parseFloat(b.attr("max")),e=parseFloat(b.attr("min")),f=b.attr("step");c&&""!==c&&"NaN"!==c||(c=0),""!==d&&"NaN"!==d||(d=""),""!==e&&"NaN"!==e||(e=0),"any"!==f&&""!==f&&void 0!==f&&"NaN"!==parseFloat(f)||(f=1),a(this).is(".plus")?d&&c>=d?b.val(d):b.val((c+parseFloat(f)).toFixed(f.getDecimals())):e&&c<=e?b.val(e):c>0&&b.val((c-parseFloat(f)).toFixed(f.getDecimals())),b.trigger("change")}),b()}); \ No newline at end of file