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