loading.js
857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* 加载组件
*
* @author: Aiden Xu <aiden.xu@yoho.cn>
* @date: 2016/07/18
*/
'use strict';
const $ = require('yoho-jquery');
const Overlay = require('./overlay');
const template = require('components/loading.hbs');
if (!Overlay) {
throw new Error('Required dependency "Overlay" not found!');
}
class Loading {
constructor(opts) {
this.defaults = {};
this.settings = Object.assign({}, this.defaults, opts);
this.elem = $(template());
this.elem.appendTo('body');
}
/**
* 显示
*/
show() {
this.overlay = new Overlay({
animation: 'fade',
clickToClose: false
});
this.overlay.show();
}
/**
* 关闭
*/
hide() {
this.overlay.hide();
this.elem.remove();
}
}
module.exports = new Loading();