vendor/assets/javascripts/webshims/shims/forms-picker.js in webshims-rails-1.12.7 vs vendor/assets/javascripts/webshims/shims/forms-picker.js in webshims-rails-1.13.0

- old
+ new

@@ -593,19 +593,25 @@ factor = 1; } if(o.stepfactor){ factor *= o.stepfactor; } - try { - that.elemHelper[name](factor); - - ret = that.elemHelper.prop('value'); - - } - catch (er) { - if (!o.value && that.maxAsNumber >= that.minAsNumber) { - ret = o.defValue; + + if(factor > 0 && !isNaN(that.minAsNumber) && (isNaN(that.valueAsNumber) || that.valueAsNumber < that.minAsNumber) && that.elemHelper.prop('valueAsNumber') <= that.minAsNumber){ + ret = that.asValue(that.minAsNumber); + } else if(factor < 0 && !isNaN(that.maxAsNumber) && (isNaN(that.valueAsNumber) || that.valueAsNumber > that.minAsNumber) && that.elemHelper.prop('valueAsNumber') <= that.maxAsNumber){ + ret = that.asValue(that.maxAsNumber); + } + + if(ret === false){ + try { + that.elemHelper[name](factor); + ret = that.elemHelper.prop('value'); + } catch (er) { + if (!o.value && that.maxAsNumber >= that.minAsNumber) { + ret = o.defValue; + } } } if (ret !== false && o.value != ret) { that.value(ret); if(o.toFixed && o.type == 'number'){ @@ -643,13 +649,10 @@ if (stepped) { e.preventDefault(); } }; - spinElement.attr({ - 'autocomplete': 'off', - role: 'spinbutton' - }).on(spinEvents); + spinElement.on(spinEvents); } $(this.buttonWrapper) .on('mousepressstart mousepressend', '.step-up, .step-down', mousePress) .on('mousedown mousepress', '.step-up', function(e){ step.stepUp();