loadingBar.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. show: function(status, errorTitle, errorText) {
  12. if (!status) status = "loading";
  13. switch (status) {
  14. case "error":
  15. if (!errorTitle||!errorText) {
  16. errorTitle = "Error";
  17. errorText = "Whoops, it looks like something went wrong. Please reload the site and try again!"
  18. }
  19. lychee.loadingBar
  20. .removeClass("loading uploading error")
  21. .addClass(status)
  22. .html("<h1>" + errorTitle + ": <span>" + errorText + "</span></h1>")
  23. .show()
  24. .css("height", "40px");
  25. lychee.header.css("margin-Top", "40px");
  26. $.timer(3000,function(){ loadingBar.hide() });
  27. break;
  28. case "loading":
  29. clearTimeout(lychee.loadingBar.data("timeout"));
  30. lychee.loadingBar.data("timeout", setTimeout(function () {
  31. lychee.loadingBar
  32. .show()
  33. .removeClass("loading uploading error")
  34. .addClass(status);
  35. if (visible.controls()) lychee.header.css("margin-Top", "3px");
  36. }, 1000));
  37. break;
  38. }
  39. },
  40. hide: function() {
  41. clearTimeout(lychee.loadingBar.data("timeout"));
  42. lychee.loadingBar.html("").css("height", "3px");
  43. if (visible.controls()) lychee.header.css("marginTop", "0px");
  44. $.timer(300,function(){ lychee.loadingBar.hide(); });
  45. }
  46. }