albums.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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, .photo", "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. albums.json = data;
  46. durationTime = (new Date().getTime() - startTime);
  47. if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
  48. if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
  49. if (visible.album()&&lychee.content.html()==="") waitTime = 0;
  50. setTimeout(function() {
  51. view.header.mode("albums");
  52. view.albums.init();
  53. lychee.animate(".album, .photo", "contentZoomIn");
  54. }, waitTime);
  55. });
  56. },
  57. parse: function(album) {
  58. if (album.password&&lychee.publicMode) {
  59. album.thumb0 = "assets/img/password.svg";
  60. album.thumb1 = "assets/img/password.svg";
  61. album.thumb2 = "assets/img/password.svg";
  62. } else {
  63. if (album.thumb0) album.thumb0 = lychee.upload_path_thumb + album.thumb0; else album.thumb0 = "assets/img/no_images.svg";
  64. if (album.thumb1) album.thumb1 = lychee.upload_path_thumb + album.thumb1; else album.thumb1 = "assets/img/no_images.svg";
  65. if (album.thumb2) album.thumb2 = lychee.upload_path_thumb + album.thumb2; else album.thumb2 = "assets/img/no_images.svg";
  66. }
  67. }
  68. };