albums.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @name Albums Module
  3. * @description Takes care of every action albums can handle and execute.
  4. * @author Tobias Reich
  5. * @copyright 2014 by Tobias Reich
  6. */
  7. albums = {
  8. json: null,
  9. load: function() {
  10. var startTime,
  11. durationTime,
  12. waitTime;
  13. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomOut");
  14. lychee.animate(".divider", "fadeOut");
  15. startTime = new Date().getTime();
  16. lychee.api("getAlbums", function(data) {
  17. /* Smart Albums */
  18. data.unsortedAlbum = {
  19. id: 0,
  20. title: "Unsorted",
  21. sysdate: data.unsortedNum + " photos",
  22. unsorted: 1,
  23. thumb0: data.unsortedThumb0,
  24. thumb1: data.unsortedThumb1,
  25. thumb2: data.unsortedThumb2
  26. };
  27. data.starredAlbum = {
  28. id: "f",
  29. title: "Starred",
  30. sysdate: data.starredNum + " photos",
  31. star: 1,
  32. thumb0: data.starredThumb0,
  33. thumb1: data.starredThumb1,
  34. thumb2: data.starredThumb2
  35. };
  36. data.publicAlbum = {
  37. id: "s",
  38. title: "Public",
  39. sysdate: data.publicNum + " photos",
  40. public: 1,
  41. thumb0: data.publicThumb0,
  42. thumb1: data.publicThumb1,
  43. thumb2: data.publicThumb2
  44. };
  45. data.recentAlbum = {
  46. id: "r",
  47. title: "Recent",
  48. sysdate: data.recentNum + " photos",
  49. recent: 1,
  50. thumb0: data.recentThumb0,
  51. thumb1: data.recentThumb1,
  52. thumb2: data.recentThumb2
  53. };
  54. albums.json = data;
  55. durationTime = (new Date().getTime() - startTime);
  56. if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
  57. if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
  58. if (visible.album()&&lychee.content.html()==="") waitTime = 0;
  59. setTimeout(function() {
  60. view.header.mode("albums");
  61. view.albums.init();
  62. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  63. }, waitTime);
  64. });
  65. },
  66. parse: function(album) {
  67. if (album.password&&lychee.publicMode) {
  68. album.thumb0 = "assets/img/password.svg";
  69. album.thumb1 = "assets/img/password.svg";
  70. album.thumb2 = "assets/img/password.svg";
  71. } else {
  72. if (!album.thumb0) album.thumb0 = "assets/img/no_images.svg";
  73. if (!album.thumb1) album.thumb1 = "assets/img/no_images.svg";
  74. if (!album.thumb2) album.thumb2 = "assets/img/no_images.svg";
  75. }
  76. }
  77. };