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

39 lines
708 B
JavaScript
Raw Normal View History

2022-06-06 08:53:59 +00:00
module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-spin'
2022-11-16 01:46:44 +00:00
,render() {
2022-06-06 08:53:59 +00:00
var input = this.createRoot('input');
this.node.type = 'number';
input.addEventListener('change', this._onChange.bind(this));
this.unit = null;
this.digits = 0;
}
2022-11-16 01:46:44 +00:00
,_onChange() {
2022-06-06 08:53:59 +00:00
var newValue = (this.node.value == '') ? null : parseFloat(this.node.value);
this.node.value = newValue;
this.valueChanged(newValue);
}
2022-11-16 01:46:44 +00:00
,putValue(value) {
2022-06-06 08:53:59 +00:00
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;
}
2022-11-16 01:46:44 +00:00
,setEditable(editable) {
2022-06-06 08:53:59 +00:00
this.node.readOnly = !editable;
}
});