hedera-web/js/htk/field/spin.js

47 lines
800 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
module.exports = new Class
({
Extends: Htk.Field
,Tag: 'htk-spin'
2016-10-16 14:16:08 +00:00
,render: function ()
{
2016-10-16 14:16:08 +00:00
var input = this.createRoot ('input');
//setInputTypeNumber (input);
this.node.type = 'number';
input.addEventListener ('change', this._onChange.bind (this));
this.unit = null;
this.digits = 0;
}
,_onChange: function ()
{
2015-03-15 12:44:57 +00:00
var newValue = (this.node.value == '') ? null : parseFloat (this.node.value);
this.node.value = newValue;
this.valueChanged (newValue);
}
2015-03-15 12:44:57 +00:00
,putValue: function (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: function (editable)
{
this.node.readOnly = !editable;
}
});