albums.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. 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. },
  65. parse: function(album) {
  66. if (album.password&&lychee.publicMode) {
  67. album.thumb0 = "assets/img/password.svg";
  68. album.thumb1 = "assets/img/password.svg";
  69. album.thumb2 = "assets/img/password.svg";
  70. } else {
  71. if (!album.thumb0) album.thumb0 = "assets/img/no_images.svg";
  72. if (!album.thumb1) album.thumb1 = "assets/img/no_images.svg";
  73. if (!album.thumb2) album.thumb2 = "assets/img/no_images.svg";
  74. }
  75. }
  76. };