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({
|
2022-06-07 08:19:29 +00:00
|
|
|
Extends: Component
|
|
|
|
,Tag: 'htk-loader'
|
2022-06-06 08:53:59 +00:00
|
|
|
,Properties: {
|
|
|
|
form: {
|
|
|
|
type: Db.Form
|
2022-11-16 01:46:44 +00:00
|
|
|
,set(x) {
|
2022-06-06 08:53:59 +00:00
|
|
|
this.link({_form: x}, {'status-changed': this.onFormChange});
|
|
|
|
this.onFormChange();
|
|
|
|
}
|
2022-11-16 01:46:44 +00:00
|
|
|
,get() {
|
2022-06-06 08:53:59 +00:00
|
|
|
return this._form;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,initialize(props) {
|
2022-06-06 17:13:57 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,appendChild(child) {
|
2022-06-06 08:53:59 +00:00
|
|
|
this.childs.appendChild(child);
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,stop() {
|
2022-06-06 08:53:59 +00:00
|
|
|
if (!this.isLoading)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.isLoading = false;
|
|
|
|
this.spinner.stop();
|
|
|
|
Vn.Node.removeChilds(this.node);
|
|
|
|
this.node.appendChild(this.childs);
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,start() {
|
2022-06-06 08:53:59 +00:00
|
|
|
if (this.isLoading)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.isLoading = true;
|
|
|
|
this.spinner.start();
|
|
|
|
Vn.Node.removeChilds(this.node);
|
|
|
|
this.node.appendChild(this.div);
|
|
|
|
}
|
|
|
|
|
2022-11-16 01:46:44 +00:00
|
|
|
,onFormChange() {
|
2022-06-06 08:53:59 +00:00
|
|
|
if (this._form.ready)
|
|
|
|
this.stop();
|
|
|
|
else
|
|
|
|
this.start();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|