hedera-web/js/htk/column.js

113 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-10-16 14:16:08 +00:00
var NodeBuilder = require ('./node-builder');
/**
* Represents a grid column. This is an abstract class and should not be
* instantiated directly.
2016-12-20 09:32:17 +00:00
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-10-16 14:16:08 +00:00
Extends: NodeBuilder
,Tag: 'htk-column'
,Properties:
{
value:
{
2015-07-03 05:49:45 +00:00
type: String
,value: null
},
column:
{
type: String
,value: null
},
columnIndex:
{
type: Number
,value: -1
},
title:
{
type: String
,value: null
},
editable:
{
type: Boolean
,value: false
},
renderer:
{
type: Function
,value: false
},
2015-08-17 18:02:14 +00:00
class:
{
type: String
,set: function (x)
{
this._userCssClass = x;
if (this._cssClass)
this._cssClass = x +' '+ this._cssClass;
else
this._cssClass = x;
2015-08-17 18:02:14 +00:00
}
,get: function ()
{
return this._userCssClass;
2015-08-17 18:02:14 +00:00
}
}
}
,_cssClass: null
,_userCssClass: null
/**
* Initializes the column.
2016-12-20 09:32:17 +00:00
*/
,initialize: function (props)
{
2015-11-09 08:14:33 +00:00
this.parent (props);
2016-10-16 14:16:08 +00:00
this.td = this.createElement ('td');
}
,renderHeader: function ()
{
2016-10-16 14:16:08 +00:00
var th = this.createElement ('th');
if (this.title)
2016-10-16 14:16:08 +00:00
th.appendChild (this.createTextNode (this.title));
return th;
}
/**
* Draws the cell and returns its associated td.
*
* @param {HTMLTableRow} tr the table row
* @return {HTMLTableData} the rendered cell
2016-12-20 09:32:17 +00:00
*/
,render: function (tr)
{
2015-08-17 18:02:14 +00:00
var td = this.td.cloneNode (true);
if (this._cssClass)
td.className = this._cssClass;
2015-08-17 18:02:14 +00:00
return td;
}
,updateColumnIndex: function (model)
{
if (this.column)
this.columnIndex = model.getColumnIndex (this.column);
}
,changed: function (tr, newValue)
{
this.signalEmit ('changed', tr.rowIndex - 1, newValue);
}
});