2022-06-06 08:53:59 +00:00
|
|
|
require('./style.scss');
|
2016-09-26 09:28:47 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
module.exports = new Class({
|
2015-03-27 19:10:49 +00:00
|
|
|
Extends: Htk.Field
|
|
|
|
,Tag: 'htk-button'
|
2022-05-25 18:04:16 +00:00
|
|
|
,Properties: {
|
2022-05-21 21:31:56 +00:00
|
|
|
image: {
|
2015-03-27 19:10:49 +00:00
|
|
|
type: String
|
2022-05-21 21:31:56 +00:00
|
|
|
,set: function(x) {
|
2022-05-24 10:18:44 +00:00
|
|
|
this.iconNode.name = x;
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
2016-09-19 06:40:18 +00:00
|
|
|
},
|
2022-05-21 21:31:56 +00:00
|
|
|
icon: {
|
2016-09-19 06:40:18 +00:00
|
|
|
type: String
|
2022-05-21 21:31:56 +00:00
|
|
|
,set: function(x) {
|
2022-05-24 10:18:44 +00:00
|
|
|
this.iconNode.name = x;
|
2016-09-19 06:40:18 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
},
|
2022-05-21 21:31:56 +00:00
|
|
|
tip: {
|
2015-03-27 19:10:49 +00:00
|
|
|
type: String
|
2022-05-21 21:31:56 +00:00
|
|
|
,set: function(x) {
|
2022-05-25 18:04:16 +00:00
|
|
|
this.node.title = x ? _(x) : '';
|
2022-05-21 21:31:56 +00:00
|
|
|
this.renderContent();
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
2022-05-21 21:31:56 +00:00
|
|
|
,get: function() {
|
2015-09-16 16:11:15 +00:00
|
|
|
return this.node.title;
|
|
|
|
}
|
|
|
|
},
|
2022-05-21 21:31:56 +00:00
|
|
|
showText: {
|
2015-09-16 16:11:15 +00:00
|
|
|
type: Boolean
|
2022-05-25 18:04:16 +00:00
|
|
|
,set: function(x) {
|
2015-09-16 16:11:15 +00:00
|
|
|
this._showText = x;
|
2022-05-21 21:31:56 +00:00
|
|
|
this.renderContent();
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
2022-05-21 21:31:56 +00:00
|
|
|
,get: function() {
|
2015-09-16 16:11:15 +00:00
|
|
|
return this._showText;
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-16 16:11:15 +00:00
|
|
|
,_showText: false
|
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
,render: function() {
|
|
|
|
var node = this.createRoot('button');
|
2015-11-09 08:14:33 +00:00
|
|
|
|
2022-05-24 10:18:44 +00:00
|
|
|
this.iconNode = new Htk.Icon();
|
|
|
|
node.appendChild(this.iconNode.node);
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
2015-09-16 16:11:15 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
,renderContent: function() {
|
2015-09-16 16:11:15 +00:00
|
|
|
if (this._textNode)
|
2022-05-21 21:31:56 +00:00
|
|
|
Vn.Node.remove(this._textNode);
|
2015-09-16 16:11:15 +00:00
|
|
|
|
2022-05-21 21:31:56 +00:00
|
|
|
if (this._showText && this.node.title) {
|
|
|
|
this._textNode = this.createElement('span');
|
|
|
|
this._textNode.className = 'text';
|
|
|
|
this._textNode.appendChild(this.createTextNode(this.node.title));
|
|
|
|
this.node.appendChild(this._textNode);
|
2015-09-16 16:11:15 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
});
|