2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
|
|
|
Extends: Htk.Column
|
|
|
|
,Tag: 'htk-column-text'
|
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Format that applies to the value.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-01-23 13:09:30 +00:00
|
|
|
format:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
this._format = _(x);
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_format: null
|
|
|
|
|
2015-11-26 12:30:04 +00:00
|
|
|
,initialize: function (props)
|
|
|
|
{
|
|
|
|
this._cssClass = 'cell-text';
|
|
|
|
this.parent (props);
|
|
|
|
}
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
,render: function (tr)
|
|
|
|
{
|
|
|
|
var node;
|
|
|
|
|
|
|
|
if (this.editable)
|
|
|
|
{
|
|
|
|
var value = this.value ? this.value : '';
|
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
node = this.createElement ('input');
|
2015-01-23 13:09:30 +00:00
|
|
|
node.type = 'text';
|
|
|
|
node.value = value;
|
|
|
|
node.addEventListener ('changed',
|
|
|
|
this.inputChanged.bind (this, tr, node));
|
|
|
|
}
|
|
|
|
else
|
2016-10-16 14:16:08 +00:00
|
|
|
node = this.createTextNode (
|
2015-01-23 13:09:30 +00:00
|
|
|
Vn.Value.format (this.value, this._format));
|
|
|
|
|
|
|
|
var td = this.parent (tr);
|
|
|
|
td.appendChild (node);
|
|
|
|
return td;
|
|
|
|
}
|
|
|
|
|
|
|
|
,inputChanged: function (tr, node)
|
|
|
|
{
|
|
|
|
this.changed (tr, node.value);
|
|
|
|
}
|
|
|
|
});
|