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

47 lines
828 B
JavaScript

Htk.Spin = new Class
({
Extends: Htk.Field
,Tag: 'htk-spin'
,initialize: function (props)
{
var input = this.createElement ('input');
//setInputTypeNumber (input);
this.node.type = 'number';
input.addEventListener ('change', this._onChange.bind (this));
this.unit = null;
this.digits = 0;
this.parent (props);
}
,_onChange: function ()
{
var newValue = (this.node.value == '') ? null : parseFloat (this.node.value);
this.node.value = newValue;
this.valueChanged (newValue);
}
,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;
}
});