albums.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. setTimeout(function() {
  50. view.header.mode("albums");
  51. view.albums.init();
  52. lychee.animate(".album, .photo", "contentZoomIn");
  53. }, waitTime);
  54. });
  55. },
  56. parse: function(album) {
  57. if (album.password&&lychee.publicMode) {
  58. album.thumb0 = "assets/img/password.svg";
  59. album.thumb1 = "assets/img/password.svg";
  60. album.thumb2 = "assets/img/password.svg";
  61. } else {
  62. if (album.thumb0) album.thumb0 = lychee.upload_path_thumb + album.thumb0; else album.thumb0 = "assets/img/no_images.svg";
  63. if (album.thumb1) album.thumb1 = lychee.upload_path_thumb + album.thumb1; else album.thumb1 = "assets/img/no_images.svg";
  64. if (album.thumb2) album.thumb2 = lychee.upload_path_thumb + album.thumb2; else album.thumb2 = "assets/img/no_images.svg";
  65. }
  66. }
  67. };