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-button'
|
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
image:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
},
|
2016-09-26 09:28:47 +00:00
|
|
|
icon:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
this._icon = x;
|
|
|
|
this.image = 'image/icon/light/'+ x + '.svg';
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._icon;
|
|
|
|
}
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
tip:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
}
|
|
|
|
}
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
|
|
|
this._cssClass = 'cell-button';
|
|
|
|
this.parent (props);
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,render: function (tr)
|
|
|
|
{
|
|
|
|
var td = this.parent (tr);
|
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
var button = this.createElement ('button');
|
2015-01-23 13:09:30 +00:00
|
|
|
button.addEventListener ('click',
|
2016-12-23 08:57:49 +00:00
|
|
|
this._onClick.bind (this, this.value, tr, button));
|
2015-01-23 13:09:30 +00:00
|
|
|
td.appendChild (button);
|
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
var img = this.createElement ('img');
|
2015-01-23 13:09:30 +00:00
|
|
|
img.src = this.image;
|
|
|
|
button.appendChild (img);
|
|
|
|
|
|
|
|
if (this.tip)
|
|
|
|
{
|
|
|
|
button.title = _(this.tip);
|
|
|
|
img.title = _(this.tip);
|
|
|
|
}
|
|
|
|
|
|
|
|
return td;
|
|
|
|
}
|
|
|
|
|
2016-12-23 08:57:49 +00:00
|
|
|
,_onClick: function (value, tr, button, event)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-12-23 08:57:49 +00:00
|
|
|
event.preventDefault ();
|
|
|
|
this.signalEmit ('clicked', value, tr.rowIndex - 1, button, event);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|