From 138bf714c5d938bb7aa4266ac70f3aa75659827b Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 27 Feb 2015 22:14:19 +0100 Subject: [PATCH] Streamlined type of star and public --- dist/main.js | Bin 174382 -> 174298 bytes src/scripts/album.js | 4 +- src/scripts/albums.js | 84 ++++++++++++++++++++++-------------------- src/scripts/photo.js | 10 ++--- src/scripts/view.js | 8 ++-- 5 files changed, 56 insertions(+), 50 deletions(-) diff --git a/dist/main.js b/dist/main.js index f44d49812ebb8888fc76ccc2aee145048a7be943..922236e310c5a11b59c4a7eb87e124364af9091f 100644 GIT binary patch delta 661 zcmZ2?iR;!yu7)j)=JQyT43uoA7tCZ5o4((biEVqxJVrha79~Td;P%R8jNB~KAD(8E z&`8WlD$Om{i%%{}O)NtaY76c2u1rb>(-RjniBF#}jftHDF165_Nq9R@)|3ev*$bG&5VHJpm?WU_4HTaa zjBnxTQ{0(!rk`HQC@?*LF%#$XsOd~R2n|5vM7RHTXZohO{Zk>+LqJ2M$jGAad zuh%l_7@?@rE6pp;FDgk*(JRR)%}p}U0aJ!nD2k>Vu49zYK@mdJXH<(SJw0|EhUM++ z7}e3-vwj_;xIe17#U+VFMKI?WLY!lS>Kr{3H5gWZT*s(|W{=EzM%`Q#d!m&JN|SOj zla*rec^q98cK4vG0=a1V#6BkB=`+_eDlkIX2iG$yLfHc7c7jzyMG3l9suFOEW=?g8H#HQ!FFtIWNg|}C`FnKUB8cb(&XA+YIDby*;OfA;~ zn}G0_hNg}oNJ%Kn1kvgLr!jG{fK8USW)j^#!=34yCL`DOzCxyljN1!}nU*Ut8^UZe sp2oBh#uMER)G5paOtWG$nf|jeg3T41p8J_mYP#-BCc*8o3z%v-08@V!Z diff --git a/src/scripts/album.js b/src/scripts/album.js index cd604bc..00ced60 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -384,7 +384,7 @@ album.setPublic = function(albumID, e) { albums.refresh(); - if (!basicModal.visible()&&album.json.public==0) { + if (!basicModal.visible()&&album.json.public==='0') { var msg = '', action; @@ -475,7 +475,7 @@ album.setPublic = function(albumID, e) { view.album.public(); view.album.password(); - if (album.json.public==1) contextMenu.shareAlbum(albumID, e); + if (album.json.public==='1') contextMenu.shareAlbum(albumID, e); } diff --git a/src/scripts/albums.js b/src/scripts/albums.js index b0a0289..72dbb81 100644 --- a/src/scripts/albums.js +++ b/src/scripts/albums.js @@ -25,45 +25,7 @@ albums.load = function() { api.post('Album::getAll', {}, function(data) { /* Smart Albums */ - data.smartalbums.unsorted = { - id: 0, - title: 'Unsorted', - sysdate: data.smartalbums.unsorted.num + ' photos', - unsorted: '1', - thumb0: data.smartalbums.unsorted.thumb0, - thumb1: data.smartalbums.unsorted.thumb1, - thumb2: data.smartalbums.unsorted.thumb2 - }; - - data.smartalbums.starred = { - id: 'f', - title: 'Starred', - sysdate: data.smartalbums.starred.num + ' photos', - star: '1', - thumb0: data.smartalbums.starred.thumb0, - thumb1: data.smartalbums.starred.thumb1, - thumb2: data.smartalbums.starred.thumb2 - }; - - data.smartalbums.public = { - id: 's', - title: 'Public', - sysdate: data.smartalbums.public.num + ' photos', - public: '1', - thumb0: data.smartalbums.public.thumb0, - thumb1: data.smartalbums.public.thumb1, - thumb2: data.smartalbums.public.thumb2 - }; - - data.smartalbums.recent = { - id: 'r', - title: 'Recent', - sysdate: data.smartalbums.recent.num + ' photos', - recent: '1', - thumb0: data.smartalbums.recent.thumb0, - thumb1: data.smartalbums.recent.thumb1, - thumb2: data.smartalbums.recent.thumb2 - }; + if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums); albums.json = data; @@ -108,6 +70,50 @@ albums.parse = function(album) { } +albums._createSmartAlbums = function(data) { + + data.unsorted = { + id: 0, + title: 'Unsorted', + sysdate: data.unsorted.num + ' photos', + unsorted: '1', + thumb0: data.unsorted.thumb0, + thumb1: data.unsorted.thumb1, + thumb2: data.unsorted.thumb2 + }; + + data.starred = { + id: 'f', + title: 'Starred', + sysdate: data.starred.num + ' photos', + star: '1', + thumb0: data.starred.thumb0, + thumb1: data.starred.thumb1, + thumb2: data.starred.thumb2 + }; + + data.public = { + id: 's', + title: 'Public', + sysdate: data.public.num + ' photos', + public: '1', + thumb0: data.public.thumb0, + thumb1: data.public.thumb1, + thumb2: data.public.thumb2 + }; + + data.recent = { + id: 'r', + title: 'Recent', + sysdate: data.recent.num + ' photos', + recent: '1', + thumb0: data.recent.thumb0, + thumb1: data.recent.thumb1, + thumb2: data.recent.thumb2 + }; + +} + albums.refresh = function() { albums.json = null; diff --git a/src/scripts/photo.js b/src/scripts/photo.js index bb9d21a..9755c44 100644 --- a/src/scripts/photo.js +++ b/src/scripts/photo.js @@ -393,12 +393,12 @@ photo.setStar = function(photoIDs) { if (!photoIDs) return false; if (visible.photo()) { - photo.json.star = (photo.json.star==0) ? 1 : 0; + photo.json.star = (photo.json.star==='0') ? '1' : '0'; view.photo.star(); } photoIDs.forEach(function(id, index, array) { - album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0; + album.json.content[id].star = (album.json.content[id].star==='0') ? '1' : '0'; view.album.content.star(id); }); @@ -449,13 +449,13 @@ photo.setPublic = function(photoID, e) { if (visible.photo()) { - photo.json.public = (photo.json.public==0) ? 1 : 0; + photo.json.public = (photo.json.public==='0') ? '1' : '0'; view.photo.public(); - if (photo.json.public==1) contextMenu.sharePhoto(photoID, e); + if (photo.json.public==='1') contextMenu.sharePhoto(photoID, e); } - album.json.content[photoID].public = (album.json.content[photoID].public==0) ? 1 : 0; + album.json.content[photoID].public = (album.json.content[photoID].public==='0') ? '1' : '0'; view.album.content.public(photoID); albums.refresh(); diff --git a/src/scripts/view.js b/src/scripts/view.js index 1b7280e..745087a 100644 --- a/src/scripts/view.js +++ b/src/scripts/view.js @@ -209,14 +209,14 @@ view.album = { star: function(photoID) { $('.photo[data-id="' + photoID + '"] .iconic-star').remove(); - if (album.json.content[photoID].star==1) $('.photo[data-id="' + photoID + '"]').append("" + build.iconic('star') + ""); + if (album.json.content[photoID].star==='1') $('.photo[data-id="' + photoID + '"]').append("" + build.iconic('star') + ""); }, public: function(photoID) { $('.photo[data-id="' + photoID + '"] .iconic-share').remove(); - if (album.json.content[photoID].public==1) $('.photo[data-id="' + photoID + '"]').append(""); + if (album.json.content[photoID].public==='1') $('.photo[data-id="' + photoID + '"]').append(""); }, @@ -253,7 +253,7 @@ view.album = { public: function() { - if (album.json.public==1) { + if (album.json.public==='1') { $('#button_share_album') .addClass('active') @@ -378,7 +378,7 @@ view.photo = { public: function() { - if (photo.json.public==1||photo.json.public==2) { + if (photo.json.public==='1'||photo.json.public==='2') { // Photo public $('#button_share') .addClass('active')