loadingBar.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @name loadingBar.js
  3. * @author Philipp Maurer
  4. * @author Tobias Reich
  5. * @copyright 2013 by Philipp Maurer, Tobias Reich
  6. *
  7. * LoadingBar Module
  8. * This module is used to show and hide the loading bar.
  9. */
  10. loadingBar = {
  11. status: null,
  12. show: function(status, errorTitle, errorText) {
  13. if (status=="error") {
  14. loadingBar.status = "error";
  15. if (!errorTitle) errorTitle = "Error";
  16. if (!errorText) errorText = "Whoops, it looks like something went wrong. Please reload the site and try again!"
  17. lychee.loadingBar
  18. .removeClass("loading uploading error")
  19. .addClass(status)
  20. .html("<h1>" + errorTitle + ": <span>" + errorText + "</span></h1>")
  21. .show()
  22. .css("height", "40px");
  23. if (visible.controls()) lychee.header.css("margin-Top", "40px");
  24. clearTimeout(lychee.loadingBar.data("timeout"));
  25. lychee.loadingBar.data("timeout", setTimeout(function() { loadingBar.hide(true) }, 3000));
  26. } else if (loadingBar.status==null) {
  27. loadingBar.status = "loading";
  28. clearTimeout(lychee.loadingBar.data("timeout"));
  29. lychee.loadingBar.data("timeout", setTimeout(function() {
  30. lychee.loadingBar
  31. .show()
  32. .removeClass("loading uploading error")
  33. .addClass("loading");
  34. if (visible.controls()) lychee.header.css("margin-Top", "3px");
  35. }, 1000));
  36. }
  37. },
  38. hide: function(force_hide) {
  39. if ((loadingBar.status!="error"&&loadingBar.status!=null)||force_hide) {
  40. loadingBar.status = null;
  41. clearTimeout(lychee.loadingBar.data("timeout"));
  42. lychee.loadingBar.html("").css("height", "3px");
  43. if (visible.controls()) lychee.header.css("marginTop", "0px");
  44. setTimeout(function() { lychee.loadingBar.hide() }, 300);
  45. }
  46. }
  47. }