0
1
Fork 0
hedera-web-mindshore/js/htk/columns/button/index.js

76 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-06-06 16:02:17 +00:00
require('./style.scss');
2016-09-26 09:28:47 +00:00
module.exports = new Class({
Extends: Htk.Column,
Tag: 'htk-column-button',
Properties: {
image: {
type: String
,value: null
},
icon: {
2016-09-26 09:28:47 +00:00
type: String
2022-05-21 21:31:56 +00:00
,set: function(x) {
2016-09-26 09:28:47 +00:00
this._icon = x;
}
2022-05-21 21:31:56 +00:00
,get: function() {
2016-09-26 09:28:47 +00:00
return this._icon;
}
},
tip: {
type: String,
value: null
},
disabled: {
type: Boolean,
value: false
},
href: {
type: String,
value: null
},
target: {
type: String,
value: ''
}
},
initialize: function(props) {
this._cssClass = 'cell-button';
2022-06-06 16:02:17 +00:00
Htk.Column.prototype.initialize.call(this, props);
},
render: function(tr) {
2022-06-06 16:02:17 +00:00
const td = Htk.Column.prototype.render.call(this, tr);
2022-05-25 18:04:16 +00:00
let 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;
}
2022-05-25 18:04:16 +00:00
if (this.tip)
button.title = _(this.tip);
button.disabled = this.disabled;
td.appendChild(button);
2022-05-25 18:04:16 +00:00
const icon = new Htk.Icon({
name: this._icon
});
button.appendChild(icon.node);
return td;
},
buttonClicked: function(value, tr, button) {
2022-05-30 01:30:33 +00:00
this.emit('clicked', value, tr.rowIndex - 1, button);
}
});