albums.js 2.5 KB

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