albums.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if(albums.json===null) {
  17. lychee.api("getAlbums", function(data) {
  18. /* Smart Albums */
  19. data.unsortedAlbum = {
  20. id: 0,
  21. title: "Unsorted",
  22. sysdate: data.unsortedNum + " photos",
  23. unsorted: 1,
  24. thumb0: data.unsortedThumb0,
  25. thumb1: data.unsortedThumb1,
  26. thumb2: data.unsortedThumb2
  27. };
  28. data.starredAlbum = {
  29. id: "f",
  30. title: "Starred",
  31. sysdate: data.starredNum + " photos",
  32. star: 1,
  33. thumb0: data.starredThumb0,
  34. thumb1: data.starredThumb1,
  35. thumb2: data.starredThumb2
  36. };
  37. data.publicAlbum = {
  38. id: "s",
  39. title: "Public",
  40. sysdate: data.publicNum + " photos",
  41. public: 1,
  42. thumb0: data.publicThumb0,
  43. thumb1: data.publicThumb1,
  44. thumb2: data.publicThumb2
  45. };
  46. data.recentAlbum = {
  47. id: "r",
  48. title: "Recent",
  49. sysdate: data.recentNum + " photos",
  50. recent: 1,
  51. thumb0: data.recentThumb0,
  52. thumb1: data.recentThumb1,
  53. thumb2: data.recentThumb2
  54. };
  55. albums.json = data;
  56. durationTime = (new Date().getTime() - startTime);
  57. if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
  58. if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
  59. if (visible.album()&&lychee.content.html()==="") waitTime = 0;
  60. setTimeout(function() {
  61. view.header.mode("albums");
  62. view.albums.init();
  63. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  64. }, waitTime);
  65. });
  66. } else {
  67. setTimeout(function() {
  68. view.header.mode("albums");
  69. view.albums.init();
  70. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  71. }, 300);
  72. }
  73. },
  74. parse: function(album) {
  75. if (album.password&&lychee.publicMode) {
  76. album.thumb0 = "assets/img/password.svg";
  77. album.thumb1 = "assets/img/password.svg";
  78. album.thumb2 = "assets/img/password.svg";
  79. } else {
  80. if (!album.thumb0) album.thumb0 = "assets/img/no_images.svg";
  81. if (!album.thumb1) album.thumb1 = "assets/img/no_images.svg";
  82. if (!album.thumb2) album.thumb2 = "assets/img/no_images.svg";
  83. }
  84. },
  85. refresh: function() {
  86. albums.json = null;
  87. }
  88. };