2016-09-26 09:28:47 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
module.exports = new Class({
|
|
|
|
Extends: Htk.Column,
|
|
|
|
Tag: 'htk-column-button',
|
|
|
|
Properties: {
|
|
|
|
image: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
},
|
2018-07-02 12:54:37 +00:00
|
|
|
icon: {
|
2016-09-26 09:28:47 +00:00
|
|
|
type: String
|
2018-07-02 12:54:37 +00:00
|
|
|
,set: function(x)
|
2016-09-26 09:28:47 +00:00
|
|
|
{
|
|
|
|
this._icon = x;
|
2018-07-02 12:54:37 +00:00
|
|
|
this.image = 'image/icon/light/'+ x +'.svg';
|
2016-09-26 09:28:47 +00:00
|
|
|
}
|
2018-07-02 12:54:37 +00:00
|
|
|
,get: function()
|
2016-09-26 09:28:47 +00:00
|
|
|
{
|
|
|
|
return this._icon;
|
|
|
|
}
|
|
|
|
},
|
2018-07-02 12:54:37 +00:00
|
|
|
tip: {
|
|
|
|
type: String,
|
|
|
|
value: null
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
value: false
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
value: null
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
type: String,
|
|
|
|
value: ''
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2018-07-02 12:54:37 +00:00
|
|
|
},
|
2015-11-26 12:30:04 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
initialize: function(props) {
|
2015-11-26 12:30:04 +00:00
|
|
|
this._cssClass = 'cell-button';
|
2018-07-02 12:54:37 +00:00
|
|
|
this.parent(props);
|
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
render: function(tr) {
|
|
|
|
var td = this.parent(tr);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
var button;
|
|
|
|
|
|
|
|
if (this.href == null) {
|
|
|
|
button = this.createElement('button');
|
|
|
|
button.addEventListener('click',
|
|
|
|
this.buttonClicked.bind(this, this.value, tr, button));
|
|
|
|
} else {
|
|
|
|
button = this.createElement('a');
|
|
|
|
button.href = this.href;
|
|
|
|
button.target = this.target;
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
button.disabled = this.disabled;
|
|
|
|
td.appendChild(button);
|
|
|
|
|
|
|
|
var img = this.createElement('img');
|
2015-01-23 13:09:30 +00:00
|
|
|
img.src = this.image;
|
2018-07-02 12:54:37 +00:00
|
|
|
button.appendChild(img);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
if (this.tip) {
|
2015-01-23 13:09:30 +00:00
|
|
|
button.title = _(this.tip);
|
|
|
|
img.title = _(this.tip);
|
|
|
|
}
|
|
|
|
|
|
|
|
return td;
|
2018-07-02 12:54:37 +00:00
|
|
|
},
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2018-07-02 12:54:37 +00:00
|
|
|
buttonClicked: function(value, tr, button) {
|
|
|
|
this.signalEmit('clicked', value, tr.rowIndex - 1, button);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|