hedera-web/js/htk/widget.js

104 lines
1.6 KiB
JavaScript

module.exports = new Class
({
Extends: Vn.Object
,Properties:
{
node:
{
type: Object
,get: function ()
{
return this._node;
}
},
class:
{
type: String
,set: function (x)
{
this._cssClass = x;
this._refreshClass ();
}
,get: function ()
{
return this._node.className;
}
}
}
/** Main HTML node that represents the widget **/
,_node: null
,builder: null
,builderInit: function (path)
{
var builder = new Vn.Builder ();
builder.signalData = this;
builder.loadXml (path);
this.builderResultInit (builder);
}
,builderInitString: function (xmlString)
{
var builder = new Vn.Builder ();
builder.signalData = this;
builder.loadFromString (xmlString);
this.builderResultInit (builder);
}
,builderResultInit: function (builder)
{
var res = this.builder = builder.load ();
this._node = res.$('main');
res.link ();
}
,createElement: function (tagName)
{
this._node = document.createElement (tagName);
return this._node;
}
,getNode: function ()
{
if (!this._node)
{
this._createNode ();
this._refreshClass ();
}
return this._node;
}
,_createNode: function () {}
,_refreshClass: function ()
{
if (this._node && this._cssClass)
this._node.className = this._cssClass +' '+ this._node.className;
}
,$: function (id)
{
if (this.builder)
return this.builder.getById (id);
return null;
}
,remove: function ()
{
Vn.Node.remove (this._node);
}
,_destroy: function ()
{
if (this.builder)
this.builder.unref ();
this.parent ();
}
});