[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/webroot/rsrc/js/core/ -> Busy.js (source)

   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          self._indicator = JX.$N('div', {className: 'busy'});
  30          self._indicator.style.opacity = 0;
  31          document.body.appendChild(self._indicator);
  32  
  33          // Don't actually show the indicator for a little while, to prevent
  34          // it from flashing briefly for every Ajax request.
  35  
  36          new JX.FX(self._indicator).setDuration(1000).start({opacity: [0, 0.8]});
  37        }
  38        self._depth++;
  39      },
  40      done : function() {
  41        var self = JX.Busy;
  42        --self._depth;
  43  
  44        if (!self._depth) {
  45          JX.DOM.remove(self._indicator);
  46          self._indicator = null;
  47        }
  48      }
  49    }
  50  
  51  });


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1