0
1
Fork 0
hedera-web-mindshore/js/htk/spin/index.js

39 lines
708 B
JavaScript

module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-spin'
,render() {
var input = this.createRoot('input');
this.node.type = 'number';
input.addEventListener('change', this._onChange.bind(this));
this.unit = null;
this.digits = 0;
}
,_onChange() {
var newValue = (this.node.value == '') ? null : parseFloat(this.node.value);
this.node.value = newValue;
this.valueChanged(newValue);
}
,putValue(value) {
var text;
if (value != null) {
text = (new Number(value)).toFixed(this.digits);
if (this.unit != null)
text += ' ' + this.unit;
} else
text = '';
this.node.value = text;
}
,setEditable(editable) {
this.node.readOnly = !editable;
}
});