-
Notifications
You must be signed in to change notification settings - Fork 2
/
loader.js
61 lines (49 loc) · 1.22 KB
/
loader.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
// TODO use bind for dom interaction/manipulation
function get(s,c) {
try {
return (c||document).querySelector(s);
} catch (err) {
return null;
}
}
function handleInputs(disable) {
var self = this;
// TODO disable inputs while loading
}
function hideShowFilters (hide) {
var self = this;
for (var i = 0, l = self.loader.hide.length; i < l; ++i) {
self.loader.hide[i].style.display = hide ? 'none' : 'block';
}
}
function show () {
var self = this;
// hide filter
hideShowFilters.call(self, true);
// disable inputs
handleInputs.call(self, true);
// show loader
self.loader.loader.style.display = 'block';
}
function hide () {
var self = this;
// hide loader
self.loader.loader.style.display = 'none';
// enable inputs
handleInputs.call(self);
// show filter
hideShowFilters.call(self);
}
function init () {
var self = this;
if (!self.config.ui.loader) {
return;
}
self.loader = {
loader: get(self.config.ui.loader.loader, self.dom)[0],
hide: get(self.config.ui.loader.hide, self.dom)
};
self.on('showLoader', show);
self.on('hideLoader', hide);
}
module.exports = init;