-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoadingMixin.js
85 lines (78 loc) · 1.85 KB
/
LoadingMixin.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/_base/fx',
'dojo/dom-style',
'dojo/dom-construct',
'dojo/topic',
'dojo/query'
], function(
declare,
lang,
fx,
domStyle,
domConstruct,
topic,
query
){
return declare(null, {
loadingContainer: null,
/**
* Naar events luisteren om de loading overlay te tonen/verbergen
* @public
*/
registerLoadingEvents: function () {
topic.subscribe('standby.show',lang.hitch(this, function(evt){
this.showLoading(evt.message);
}));
topic.subscribe('standby.stop',lang.hitch(this, function(){
this.hideLoading();
}));
topic.subscribe('clear.dgrowl', lang.hitch(this, function() {
this._clearDgrowlMessages();
}));
},
/**
* Verbergt de 'Loading'-overlay.
* @public
*/
hideLoading: function () {
var node = this.loadingContainer;
fx.fadeOut({
node: node,
onEnd: function (node) {
domStyle.set(node, 'display', 'none');
},
duration: 1000
}).play();
},
/**
* Toont de 'Loading'-overlay.
* @public
*/
showLoading: function (message) {
console.debug('mixin::showloading', message, this.loadingContainer);
if (!message) {
message = '';
}
query('.loadingMessage', this.loadingContainer).forEach(function(node){
node.innerHTML = message;
});
domStyle.set(this.loadingContainer, 'display', 'block');
fx.fadeIn({
node: this.loadingContainer,
duration: 1
}).play();
topic.publish('clear.dgrowl');
},
/**
* Verbergt al de dgrowl notifications
* @private
*/
_clearDgrowlMessages: function() {
query('.dGrowl-notification').forEach(function (item) {
domConstruct.destroy(item);
}, this);
}
});
});