parent
d0110a767c
commit
ec6d69c27f
1 changed files with 4 additions and 3 deletions
|
@ -19,7 +19,7 @@ function data_delta_update(el, direction) {
|
||||||
var delta = $(el).data('delta');
|
var delta = $(el).data('delta');
|
||||||
var granularity = $(el).data('granularity');
|
var granularity = $(el).data('granularity');
|
||||||
|
|
||||||
var val = $(el).val();
|
var val = $(el).val().replace(',', '.');
|
||||||
var oldval = $.isNumeric(val) ? Number(val) : 0;
|
var oldval = $.isNumeric(val) ? Number(val) : 0;
|
||||||
var newval = oldval + delta*direction;
|
var newval = oldval + delta*direction;
|
||||||
|
|
||||||
|
@ -31,10 +31,11 @@ function data_delta_update(el, direction) {
|
||||||
$('button[data-increment='+id+']').attr('disabled', newval>=max ? 'disabled' : null);
|
$('button[data-increment='+id+']').attr('disabled', newval>=max ? 'disabled' : null);
|
||||||
|
|
||||||
// warn when what was entered is not a number
|
// warn when what was entered is not a number
|
||||||
$(el).toggleClass('error', val!='' && val!='.' && (!$.isNumeric(val) || val < 0));
|
const erroneousValue = val!='' && val!='.' && (!$.isNumeric(val) || val < 0)
|
||||||
|
$(el).toggleClass('error', erroneousValue);
|
||||||
|
|
||||||
// update field, unless the user is typing
|
// update field, unless the user is typing
|
||||||
if (!$(el).is(':focus')) {
|
if (!$(el).is(':focus') && !erroneousValue) {
|
||||||
$(el).val(round_float(newval, granularity));
|
$(el).val(round_float(newval, granularity));
|
||||||
$(el).trigger('changed');
|
$(el).trigger('changed');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue