hedera-web/js/htk/loader/index.js

71 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-06-06 08:53:59 +00:00
require('./style.scss');
2022-06-06 12:49:18 +00:00
var Component = require('vn/component');
2022-06-06 08:53:59 +00:00
module.exports = new Class({
Tag: 'htk-loader'
2022-06-06 12:49:18 +00:00
,Extends: Component
2022-06-06 08:53:59 +00:00
,Properties: {
form: {
type: Db.Form
,set: function(x) {
this.link({_form: x}, {'status-changed': this.onFormChange});
this.onFormChange();
}
,get: function() {
return this._form;
}
}
}
2022-06-06 17:13:57 +00:00
,initialize: function(props) {
Component.prototype.initialize.call(this, props);
this.createRoot('div');
2022-06-06 08:53:59 +00:00
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();
}
});