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

81 lines
1.2 KiB
JavaScript

Htk.Button = new Class
({
Extends: Htk.Field
,Tag: 'htk-button'
,Properties:
{
image:
{
type: String
,set: function (x)
{
this.img.src = x;
}
},
tip:
{
type: String
,set: function (x)
{
if (x)
{
this.node.title = _(x);
this.img.title = _(x);
}
this.render ();
}
,get: function ()
{
return this.node.title;
}
},
showText:
{
type: Boolean
,set: function (x)
{
this._showText = x;
this.render ();
}
,get: function ()
{
return this._showText;
}
}
}
,_showText: false
,initialize: function (props)
{
this.createElement ('button');
this.node.className = 'htk-button';
this.node.addEventListener ('click', this.onClick.bind (this));
this.img = document.createElement ('img');
this.node.appendChild (this.img);
this.parent (props);
}
,render: function ()
{
if (this._textNode)
Vn.Node.remove (this._textNode);
if (this._showText && this.node.title)
{
this._textNode = document.createElement ('span');
this._textNode.appendChild (document.createTextNode (this.node.title));
this.node.appendChild (this._textNode);
}
}
,onClick: function ()
{
this.signalEmit ('click', this._form);
}
});