0
1
Fork 0
hedera-web-mindshore/package/usr/share/hedera-web/js/htk/column/spin.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

Htk.ColumnSpin = new Class
({
Extends: Htk.Column
,Tag: 'htk-column-spin'
,Properties:
{
/**
* The text to append to the number.
**/
unit:
{
type: String
,value: null
},
/**
* The number of decimal places to display.
**/
digits: {
type: Number
,value: 0
}
}
,render: function (tr)
{
var td = this.parent (tr);
td.style.textAlign = 'right';
var valueString = null;
if (this.value !== null && this.value !== undefined)
valueString = new Number (this.value).toFixed (this.digits);
if (this.editable)
{
var entry = document.createElement ('input');
entry.type = 'text';
entry.className = 'cell-spin';
entry.addEventListener ('change', this.inputChanged.bind (this, tr, entry));
td.appendChild (entry);
if (valueString)
entry.value = valueString;
}
else if (valueString)
{
if (this.unit)
valueString = valueString +' '+ this.unit;
var text = document.createTextNode (valueString);
td.appendChild (text);
}
return td;
}
,inputChanged: function (tr, entry)
{
this.changed (tr, parseInt (entry.value));
}
});