0
1
Fork 0
hedera-web-mindshore/js/htk/loader.js

80 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-01-16 16:26:37 +00:00
var Widget = require ('./widget');
module.exports = new Class
({
Tag: 'htk-loader'
,Extends: Widget
,Properties: {
form:
{
type: Db.Form
,set: function (x)
{
this.link ({_form: x}, {'status-changed': this.onFormChange});
this.onFormChange ();
}
,get: function ()
{
return this._form;
}
}
}
,initialize: function ()
{
var node = this.createRoot ('div');
node.className = 'htk-loader';
var div = this.createElement ('div');
div.className = 'spinner';
var spinner = new Htk.Spinner ();
div.appendChild (spinner.node);
var childs = this.createElement ('div');
this.spinner = spinner;
this.div = div;
this.childs = childs;
this.isLoading = true;
this.stop ();
}
,appendChild: function (child)
{
this.childs.appendChild (child);
}
,stop: function ()
{
if (!this.isLoading)
return;
this.isLoading = false;
this.spinner.stop ();
Vn.Node.removeChilds (this.node);
this.node.appendChild (this.childs);
}
,start: function ()
{
if (this.isLoading)
return;
this.isLoading = true;
this.spinner.start ();
Vn.Node.removeChilds (this.node);
this.node.appendChild (this.div);
}
,onFormChange: function ()
{
if (this._form.ready)
this.stop ();
else
this.start ();
}
});