Commit ef3d5840 authored by Mart Lubbers's avatar Mart Lubbers

Also support disabled on numberfield

parent e8435beb
......@@ -90,26 +90,30 @@ itasks.NumberField = {
el.type = 'text';
el.value = (me.attributes.value === undefined || me.attributes.value === null) ? '' : me.attributes.value;
el.addEventListener('keypress',function(e) {
if(me.invalidKey(e.which)) {
e.stopPropagation();
e.preventDefault();
}
});
el.addEventListener('keyup',function(e) {
var value;
if(me.invalidKey(e.which)) {
return;
}
if(e.target.value === "") {
value = null;
} else if(me.invalidValue(e.target.value)) {
value = e.target.value;
} else {
value = me.allowDecimal ? parseFloat(e.target.value) : (e.target.value | 0);
}
me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value);
});
if('enabled' in me.attributes && me.attributes['enabled'] === false) {
el.disabled = true;
} else {
el.addEventListener('keypress',function(e) {
if(me.invalidKey(e.which)) {
e.stopPropagation();
e.preventDefault();
}
});
el.addEventListener('keyup',function(e) {
var value;
if(me.invalidKey(e.which)) {
return;
}
if(e.target.value === "") {
value = null;
} else if(me.invalidValue(e.target.value)) {
value = e.target.value;
} else {
value = me.allowDecimal ? parseFloat(e.target.value) : (e.target.value | 0);
}
me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value);
});
}
},
invalidKey: function(charCode) {
return !(charCode < 32 || (charCode > 47 && charCode < 58) || charCode == 45 || (this.allowDecimal && charCode == 46));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment