spinner.js 471 B

12345678910111213141516171819202122232425
  1. define(function (require) {
  2. var $ = require('jquery');
  3. var active = false;
  4. var SHOW_DELAY = 20;
  5. $('body').append('<div class="elgg-spinner"><div class="elgg-ajax-loader"></div></div>');
  6. return {
  7. start: function () {
  8. active = true;
  9. setTimeout(function () {
  10. if (active) {
  11. $('body').addClass('elgg-spinner-active');
  12. }
  13. }, SHOW_DELAY);
  14. },
  15. stop: function () {
  16. active = false;
  17. $('body').removeClass('elgg-spinner-active');
  18. }
  19. };
  20. });