Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/js/core/Busy.js
12241 views
1
/**
2
* @requires javelin-install
3
* javelin-dom
4
* javelin-fx
5
* @provides phabricator-busy
6
* @javelin
7
*/
8
9
/**
10
* Show a "busy" indicator onscreen so the user knows something awesome is
11
* happening, and that the awesome thing isn't the application breaking or
12
* locking up.
13
*
14
* Example usage:
15
*
16
* JX.Busy.start();
17
* // Do something...
18
* JX.Busy.done();
19
*
20
* Calls to `start()` should be paired with calls to `done()`.
21
*/
22
JX.install('Busy', {
23
24
statics : {
25
_depth : 0,
26
start : function() {
27
var self = JX.Busy;
28
if (!self._depth) {
29
var icon = JX.$N('span',
30
{className: 'phui-icon-view phui-font-fa fa-gear ph-spin'});
31
self._indicator = JX.$N('div', {className: 'busy'}, icon);
32
self._indicator.style.opacity = 0;
33
JX.$('phabricator-standard-page').appendChild(self._indicator);
34
35
// Don't actually show the indicator for a little while, to prevent
36
// it from flashing briefly for every Ajax request.
37
38
new JX.FX(self._indicator).setDuration(1000).start({opacity: [0, 0.8]});
39
}
40
self._depth++;
41
},
42
done : function() {
43
var self = JX.Busy;
44
--self._depth;
45
46
if (!self._depth) {
47
JX.DOM.remove(self._indicator);
48
self._indicator = null;
49
}
50
}
51
}
52
53
});
54
55