phorge/webroot/rsrc/js/core/Busy.js
Chad Little 8e5153e866 Make busy indicator durable column aware
Summary: Fixes T7699, moves busy indicator when durable column is present

Test Plan: visit uiexamples busy page, toggle column on and off

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7699

Differential Revision: https://secure.phabricator.com/D12257
2015-04-01 20:10:32 -07:00

54 lines
1.3 KiB
JavaScript

/**
* @requires javelin-install
* javelin-dom
* javelin-fx
* @provides phabricator-busy
* @javelin
*/
/**
* Show a "busy" indicator onscreen so the user knows something awesome is
* happening, and that the awesome thing isn't the application breaking or
* locking up.
*
* Example usage:
*
* JX.Busy.start();
* // Do something...
* JX.Busy.done();
*
* Calls to `start()` should be paired with calls to `done()`.
*/
JX.install('Busy', {
statics : {
_depth : 0,
start : function() {
var self = JX.Busy;
if (!self._depth) {
var icon = JX.$N('span',
{className: 'phui-icon-view phui-font-fa fa-gear ph-spin'});
self._indicator = JX.$N('div', {className: 'busy'}, icon);
self._indicator.style.opacity = 0;
JX.$('phabricator-standard-page').appendChild(self._indicator);
// Don't actually show the indicator for a little while, to prevent
// it from flashing briefly for every Ajax request.
new JX.FX(self._indicator).setDuration(1000).start({opacity: [0, 0.8]});
}
self._depth++;
},
done : function() {
var self = JX.Busy;
--self._depth;
if (!self._depth) {
JX.DOM.remove(self._indicator);
self._indicator = null;
}
}
}
});