|
@@ -3,619 +3,617 @@
|
|
|
* @copyright 2014 by Tobias Reich
|
|
|
*/
|
|
|
|
|
|
-photo = {
|
|
|
+photo = {}
|
|
|
|
|
|
- json: null,
|
|
|
- cache: null,
|
|
|
+photo.json = null;
|
|
|
+photo.cache = null;
|
|
|
|
|
|
- getID: function() {
|
|
|
+photo.getID = function() {
|
|
|
|
|
|
- var id;
|
|
|
+ var id;
|
|
|
|
|
|
- if (photo.json) id = photo.json.id;
|
|
|
- else id = $(".photo:hover, .photo.active").attr("data-id");
|
|
|
+ if (photo.json) id = photo.json.id;
|
|
|
+ else id = $('.photo:hover, .photo.active').attr('data-id');
|
|
|
|
|
|
- if (id) return id;
|
|
|
- else return false;
|
|
|
+ if (id) return id;
|
|
|
+ else return false;
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- load: function(photoID, albumID) {
|
|
|
+photo.load = function(photoID, albumID) {
|
|
|
|
|
|
- var params,
|
|
|
- checkPasswd;
|
|
|
+ var params,
|
|
|
+ checkPasswd;
|
|
|
|
|
|
- params = "getPhoto&photoID=" + photoID + "&albumID=" + albumID + "&password=" + password.value;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ params = 'getPhoto&photoID=' + photoID + '&albumID=' + albumID + '&password=' + password.value;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- if (data==="Warning: Wrong password!") {
|
|
|
- checkPasswd = function() {
|
|
|
- if (password.value!=="") photo.load(photoID, albumID);
|
|
|
- else setTimeout(checkPasswd, 250);
|
|
|
- };
|
|
|
- checkPasswd();
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- photo.json = data;
|
|
|
- if (!visible.photo()) view.photo.show();
|
|
|
- view.photo.init();
|
|
|
-
|
|
|
- lychee.imageview.show();
|
|
|
- setTimeout(function() {
|
|
|
- lychee.content.show();
|
|
|
- //photo.preloadNext(photoID, albumID);
|
|
|
- }, 300);
|
|
|
+ if (data==="Warning: Wrong password!") {
|
|
|
+ checkPasswd = function() {
|
|
|
+ if (password.value!=="") photo.load(photoID, albumID);
|
|
|
+ else setTimeout(checkPasswd, 250);
|
|
|
+ };
|
|
|
+ checkPasswd();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ photo.json = data;
|
|
|
+ if (!visible.photo()) view.photo.show();
|
|
|
+ view.photo.init();
|
|
|
|
|
|
- },
|
|
|
+ lychee.imageview.show();
|
|
|
+ setTimeout(function() {
|
|
|
+ lychee.content.show();
|
|
|
+ //photo.preloadNext(photoID, albumID);
|
|
|
+ }, 300);
|
|
|
|
|
|
- // Preload the next photo for better response time
|
|
|
- preloadNext: function(photoID) {
|
|
|
+ });
|
|
|
|
|
|
- var nextPhoto,
|
|
|
- url;
|
|
|
+}
|
|
|
|
|
|
- // Never preload on mobile devices with bare RAM and
|
|
|
- // mostly mobile internet
|
|
|
- if (mobileBrowser()) return false;
|
|
|
+// Preload the next photo for better response time
|
|
|
+photo.preloadNext = function(photoID) {
|
|
|
|
|
|
- if (album.json &&
|
|
|
- album.json.content &&
|
|
|
- album.json.content[photoID] &&
|
|
|
- album.json.content[photoID].nextPhoto!="") {
|
|
|
+ var nextPhoto,
|
|
|
+ url;
|
|
|
|
|
|
- nextPhoto = album.json.content[photoID].nextPhoto;
|
|
|
- url = album.json.content[nextPhoto].url;
|
|
|
+ // Never preload on mobile devices with bare RAM and
|
|
|
+ // mostly mobile internet
|
|
|
+ if (mobileBrowser()) return false;
|
|
|
|
|
|
- photo.cache = new Image();
|
|
|
- photo.cache.src = url;
|
|
|
- photo.cache.onload = function() { photo.cache = null };
|
|
|
+ if (album.json &&
|
|
|
+ album.json.content &&
|
|
|
+ album.json.content[photoID] &&
|
|
|
+ album.json.content[photoID].nextPhoto!="") {
|
|
|
|
|
|
- }
|
|
|
+ nextPhoto = album.json.content[photoID].nextPhoto;
|
|
|
+ url = album.json.content[nextPhoto].url;
|
|
|
|
|
|
- },
|
|
|
+ photo.cache = new Image();
|
|
|
+ photo.cache.src = url;
|
|
|
+ photo.cache.onload = function() { photo.cache = null };
|
|
|
|
|
|
- parse: function() {
|
|
|
+ }
|
|
|
|
|
|
- if (!photo.json.title) photo.json.title = "Untitled";
|
|
|
+}
|
|
|
|
|
|
- },
|
|
|
+photo.parse = function() {
|
|
|
|
|
|
- previous: function(animate) {
|
|
|
+ if (!photo.json.title) photo.json.title = "Untitled";
|
|
|
|
|
|
- var delay = 0;
|
|
|
+}
|
|
|
|
|
|
- if (photo.getID()!==false&&
|
|
|
- album.json&&
|
|
|
- album.json.content[photo.getID()]&&
|
|
|
- album.json.content[photo.getID()].previousPhoto!=="") {
|
|
|
+photo.previous = function(animate) {
|
|
|
|
|
|
- if (animate===true) {
|
|
|
+ var delay = 0;
|
|
|
|
|
|
- delay = 200;
|
|
|
+ if (photo.getID()!==false&&
|
|
|
+ album.json&&
|
|
|
+ album.json.content[photo.getID()]&&
|
|
|
+ album.json.content[photo.getID()].previousPhoto!=="") {
|
|
|
|
|
|
- $("#image").css({
|
|
|
- WebkitTransform: 'translateX(100%)',
|
|
|
- MozTransform: 'translateX(100%)',
|
|
|
- transform: 'translateX(100%)',
|
|
|
- opacity: 0
|
|
|
- });
|
|
|
+ if (animate===true) {
|
|
|
|
|
|
- }
|
|
|
+ delay = 200;
|
|
|
|
|
|
- setTimeout(function() {
|
|
|
- if (photo.getID()===false) return false;
|
|
|
- lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].previousPhoto)
|
|
|
- }, delay);
|
|
|
+ $("#image").css({
|
|
|
+ WebkitTransform: 'translateX(100%)',
|
|
|
+ MozTransform: 'translateX(100%)',
|
|
|
+ transform: 'translateX(100%)',
|
|
|
+ opacity: 0
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
+ setTimeout(function() {
|
|
|
+ if (photo.getID()===false) return false;
|
|
|
+ lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].previousPhoto)
|
|
|
+ }, delay);
|
|
|
|
|
|
- next: function(animate) {
|
|
|
+ }
|
|
|
|
|
|
- var delay = 0;
|
|
|
+}
|
|
|
|
|
|
- if (photo.getID()!==false&&
|
|
|
- album.json&&
|
|
|
- album.json.content[photo.getID()]&&
|
|
|
- album.json.content[photo.getID()].nextPhoto!=="") {
|
|
|
+photo.next = function(animate) {
|
|
|
|
|
|
- if (animate===true) {
|
|
|
+ var delay = 0;
|
|
|
|
|
|
- delay = 200;
|
|
|
+ if (photo.getID()!==false&&
|
|
|
+ album.json&&
|
|
|
+ album.json.content[photo.getID()]&&
|
|
|
+ album.json.content[photo.getID()].nextPhoto!=="") {
|
|
|
|
|
|
- $("#image").css({
|
|
|
- WebkitTransform: 'translateX(-100%)',
|
|
|
- MozTransform: 'translateX(-100%)',
|
|
|
- transform: 'translateX(-100%)',
|
|
|
- opacity: 0
|
|
|
- });
|
|
|
+ if (animate===true) {
|
|
|
|
|
|
- }
|
|
|
+ delay = 200;
|
|
|
|
|
|
- setTimeout(function() {
|
|
|
- if (photo.getID()===false) return false;
|
|
|
- lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].nextPhoto);
|
|
|
- }, delay);
|
|
|
+ $("#image").css({
|
|
|
+ WebkitTransform: 'translateX(-100%)',
|
|
|
+ MozTransform: 'translateX(-100%)',
|
|
|
+ transform: 'translateX(-100%)',
|
|
|
+ opacity: 0
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- duplicate: function(photoIDs) {
|
|
|
-
|
|
|
- var params;
|
|
|
-
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
-
|
|
|
- albums.refresh();
|
|
|
-
|
|
|
- params = "duplicatePhoto&photoIDs=" + photoIDs;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ setTimeout(function() {
|
|
|
+ if (photo.getID()===false) return false;
|
|
|
+ lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].nextPhoto);
|
|
|
+ }, delay);
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
- else album.load(album.getID(), false);
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+}
|
|
|
|
|
|
- },
|
|
|
+photo.duplicate = function(photoIDs) {
|
|
|
|
|
|
- delete: function(photoIDs) {
|
|
|
+ var params;
|
|
|
|
|
|
- var params,
|
|
|
- buttons,
|
|
|
- photoTitle;
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+ albums.refresh();
|
|
|
|
|
|
- if (photoIDs.length===1) {
|
|
|
- // Get title if only one photo is selected
|
|
|
- if (visible.photo()) photoTitle = photo.json.title;
|
|
|
- else photoTitle = album.json.content[photoIDs].title;
|
|
|
- if (photoTitle==="") photoTitle = "Untitled";
|
|
|
- }
|
|
|
+ params = "duplicatePhoto&photoIDs=" + photoIDs;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- buttons = [
|
|
|
- ["", function() {
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
+ else album.load(album.getID(), false);
|
|
|
|
|
|
- var nextPhoto = "",
|
|
|
- previousPhoto = "";
|
|
|
+ });
|
|
|
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
+}
|
|
|
|
|
|
- // Change reference for the next and previous photo
|
|
|
- if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
+photo.delete = function(photoIDs) {
|
|
|
|
|
|
- nextPhoto = album.json.content[id].nextPhoto;
|
|
|
- previousPhoto = album.json.content[id].previousPhoto;
|
|
|
+ var params,
|
|
|
+ buttons,
|
|
|
+ photoTitle;
|
|
|
|
|
|
- album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
- album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- }
|
|
|
+ if (photoIDs.length===1) {
|
|
|
+ // Get title if only one photo is selected
|
|
|
+ if (visible.photo()) photoTitle = photo.json.title;
|
|
|
+ else photoTitle = album.json.content[photoIDs].title;
|
|
|
+ if (photoTitle==="") photoTitle = "Untitled";
|
|
|
+ }
|
|
|
|
|
|
- album.json.content[id] = null;
|
|
|
- view.album.content.delete(id);
|
|
|
+ buttons = [
|
|
|
+ ["", function() {
|
|
|
|
|
|
- });
|
|
|
+ var nextPhoto = "",
|
|
|
+ previousPhoto = "";
|
|
|
|
|
|
- albums.refresh();
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
|
|
|
- // Go to next photo if there is a next photo and
|
|
|
- // next photo is not the current one. Show album otherwise.
|
|
|
- if (visible.photo()&&nextPhoto!==""&&nextPhoto!==photo.getID()) lychee.goto(album.getID() + "/" + nextPhoto);
|
|
|
- else if (!visible.albums()) lychee.goto(album.getID());
|
|
|
+ // Change reference for the next and previous photo
|
|
|
+ if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
|
|
|
- params = "deletePhoto&photoIDs=" + photoIDs;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ nextPhoto = album.json.content[id].nextPhoto;
|
|
|
+ previousPhoto = album.json.content[id].previousPhoto;
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
+ album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
- }],
|
|
|
- ["", function() {}]
|
|
|
- ];
|
|
|
+ album.json.content[id] = null;
|
|
|
+ view.album.content.delete(id);
|
|
|
|
|
|
- if (photoIDs.length===1) {
|
|
|
+ });
|
|
|
|
|
|
- buttons[0][0] = "Delete Photo";
|
|
|
- buttons[1][0] = "Keep Photo";
|
|
|
+ albums.refresh();
|
|
|
|
|
|
- modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
|
|
|
+ // Go to next photo if there is a next photo and
|
|
|
+ // next photo is not the current one. Show album otherwise.
|
|
|
+ if (visible.photo()&&nextPhoto!==""&&nextPhoto!==photo.getID()) lychee.goto(album.getID() + "/" + nextPhoto);
|
|
|
+ else if (!visible.albums()) lychee.goto(album.getID());
|
|
|
|
|
|
- } else {
|
|
|
+ params = "deletePhoto&photoIDs=" + photoIDs;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- buttons[0][0] = "Delete Photos";
|
|
|
- buttons[1][0] = "Keep Photos";
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?<br>This action can't be undone!", buttons);
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
+ }],
|
|
|
+ ["", function() {}]
|
|
|
+ ];
|
|
|
|
|
|
- },
|
|
|
+ if (photoIDs.length===1) {
|
|
|
|
|
|
- setTitle: function(photoIDs) {
|
|
|
+ buttons[0][0] = "Delete Photo";
|
|
|
+ buttons[1][0] = "Keep Photo";
|
|
|
|
|
|
- var oldTitle = "",
|
|
|
- newTitle,
|
|
|
- params,
|
|
|
- buttons;
|
|
|
+ modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+ } else {
|
|
|
|
|
|
- if (photoIDs.length===1) {
|
|
|
- // Get old title if only one photo is selected
|
|
|
- if (photo.json) oldTitle = photo.json.title;
|
|
|
- else if (album.json) oldTitle = album.json.content[photoIDs].title;
|
|
|
- oldTitle = oldTitle.replace("'", "'");
|
|
|
- }
|
|
|
+ buttons[0][0] = "Delete Photos";
|
|
|
+ buttons[1][0] = "Keep Photos";
|
|
|
|
|
|
- buttons = [
|
|
|
- ["Set Title", function() {
|
|
|
+ modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?<br>This action can't be undone!", buttons);
|
|
|
|
|
|
- // Get input
|
|
|
- newTitle = $(".message input.text").val();
|
|
|
+ }
|
|
|
|
|
|
- // Remove html from input
|
|
|
- newTitle = lychee.removeHTML(newTitle);
|
|
|
+}
|
|
|
|
|
|
- if (visible.photo()) {
|
|
|
- photo.json.title = (newTitle==="") ? "Untitled" : newTitle;
|
|
|
- view.photo.title();
|
|
|
- }
|
|
|
+photo.setTitle = function(photoIDs) {
|
|
|
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
- album.json.content[id].title = newTitle;
|
|
|
- view.album.content.title(id);
|
|
|
- });
|
|
|
+ var oldTitle = "",
|
|
|
+ newTitle,
|
|
|
+ params,
|
|
|
+ buttons;
|
|
|
|
|
|
- params = "setPhotoTitle&photoIDs=" + photoIDs + "&title=" + escape(encodeURI(newTitle));
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ if (photoIDs.length===1) {
|
|
|
+ // Get old title if only one photo is selected
|
|
|
+ if (photo.json) oldTitle = photo.json.title;
|
|
|
+ else if (album.json) oldTitle = album.json.content[photoIDs].title;
|
|
|
+ oldTitle = oldTitle.replace("'", "'");
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ buttons = [
|
|
|
+ ["Set Title", function() {
|
|
|
|
|
|
- }],
|
|
|
- ["Cancel", function() {}]
|
|
|
- ];
|
|
|
+ // Get input
|
|
|
+ newTitle = $(".message input.text").val();
|
|
|
|
|
|
- if (photoIDs.length===1) modal.show("Set Title", "Enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
|
|
|
- else modal.show("Set Titles", "Enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>", buttons);
|
|
|
+ // Remove html from input
|
|
|
+ newTitle = lychee.removeHTML(newTitle);
|
|
|
|
|
|
- },
|
|
|
+ if (visible.photo()) {
|
|
|
+ photo.json.title = (newTitle==="") ? "Untitled" : newTitle;
|
|
|
+ view.photo.title();
|
|
|
+ }
|
|
|
|
|
|
- setAlbum: function(photoIDs, albumID) {
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
+ album.json.content[id].title = newTitle;
|
|
|
+ view.album.content.title(id);
|
|
|
+ });
|
|
|
|
|
|
- var params,
|
|
|
- nextPhoto,
|
|
|
- previousPhoto;
|
|
|
+ params = "setPhotoTitle&photoIDs=" + photoIDs + "&title=" + escape(encodeURI(newTitle));
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (visible.photo) lychee.goto(album.getID());
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
+ });
|
|
|
|
|
|
- // Change reference for the next and previous photo
|
|
|
- if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
+ }],
|
|
|
+ ["Cancel", function() {}]
|
|
|
+ ];
|
|
|
|
|
|
- nextPhoto = album.json.content[id].nextPhoto;
|
|
|
- previousPhoto = album.json.content[id].previousPhoto;
|
|
|
+ if (photoIDs.length===1) modal.show("Set Title", "Enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
|
|
|
+ else modal.show("Set Titles", "Enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>", buttons);
|
|
|
|
|
|
- album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
- album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
+}
|
|
|
|
|
|
- }
|
|
|
+photo.setAlbum = function(photoIDs, albumID) {
|
|
|
|
|
|
- album.json.content[id] = null;
|
|
|
- view.album.content.delete(id);
|
|
|
+ var params,
|
|
|
+ nextPhoto,
|
|
|
+ previousPhoto;
|
|
|
|
|
|
- });
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (visible.photo) lychee.goto(album.getID());
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- albums.refresh();
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
|
|
|
- params = "setPhotoAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ // Change reference for the next and previous photo
|
|
|
+ if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ nextPhoto = album.json.content[id].nextPhoto;
|
|
|
+ previousPhoto = album.json.content[id].previousPhoto;
|
|
|
|
|
|
- });
|
|
|
+ album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
+ album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setStar: function(photoIDs) {
|
|
|
+ album.json.content[id] = null;
|
|
|
+ view.album.content.delete(id);
|
|
|
|
|
|
- var params;
|
|
|
+ });
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (visible.photo()) {
|
|
|
- photo.json.star = (photo.json.star==0) ? 1 : 0;
|
|
|
- view.photo.star();
|
|
|
- }
|
|
|
+ albums.refresh();
|
|
|
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
- album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0;
|
|
|
- view.album.content.star(id);
|
|
|
- });
|
|
|
+ params = "setPhotoAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- albums.refresh();
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- params = "setPhotoStar&photoIDs=" + photoIDs;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ });
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+}
|
|
|
|
|
|
- });
|
|
|
+photo.setStar = function(photoIDs) {
|
|
|
|
|
|
- },
|
|
|
+ var params;
|
|
|
|
|
|
- setPublic: function(photoID, e) {
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (visible.photo()) {
|
|
|
+ photo.json.star = (photo.json.star==0) ? 1 : 0;
|
|
|
+ view.photo.star();
|
|
|
+ }
|
|
|
|
|
|
- var params;
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
+ album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0;
|
|
|
+ view.album.content.star(id);
|
|
|
+ });
|
|
|
|
|
|
- if (photo.json.public==2) {
|
|
|
+ albums.refresh();
|
|
|
|
|
|
- modal.show("Public Album", "This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.", [["Show Album", function() { lychee.goto(photo.json.original_album) }], ["Close", function() {}]]);
|
|
|
- return false;
|
|
|
+ params = "setPhotoStar&photoIDs=" + photoIDs;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- }
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- if (visible.photo()) {
|
|
|
+ });
|
|
|
|
|
|
- photo.json.public = (photo.json.public==0) ? 1 : 0;
|
|
|
- view.photo.public();
|
|
|
- if (photo.json.public==1) contextMenu.sharePhoto(photoID, e);
|
|
|
+}
|
|
|
|
|
|
- }
|
|
|
+photo.setPublic = function(photoID, e) {
|
|
|
|
|
|
- album.json.content[photoID].public = (album.json.content[photoID].public==0) ? 1 : 0;
|
|
|
- view.album.content.public(photoID);
|
|
|
+ var params;
|
|
|
|
|
|
- albums.refresh();
|
|
|
+ if (photo.json.public==2) {
|
|
|
|
|
|
- params = "setPhotoPublic&photoID=" + photoID;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ modal.show("Public Album", "This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.", [["Show Album", function() { lychee.goto(photo.json.original_album) }], ["Close", function() {}]]);
|
|
|
+ return false;
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ if (visible.photo()) {
|
|
|
|
|
|
- },
|
|
|
+ photo.json.public = (photo.json.public==0) ? 1 : 0;
|
|
|
+ view.photo.public();
|
|
|
+ if (photo.json.public==1) contextMenu.sharePhoto(photoID, e);
|
|
|
|
|
|
- setDescription: function(photoID) {
|
|
|
+ }
|
|
|
|
|
|
- var oldDescription = photo.json.description.replace("'", "'"),
|
|
|
- description,
|
|
|
- params,
|
|
|
- buttons;
|
|
|
+ album.json.content[photoID].public = (album.json.content[photoID].public==0) ? 1 : 0;
|
|
|
+ view.album.content.public(photoID);
|
|
|
|
|
|
- buttons = [
|
|
|
- ["Set Description", function() {
|
|
|
+ albums.refresh();
|
|
|
|
|
|
- // Get input
|
|
|
- description = $(".message input.text").val();
|
|
|
+ params = "setPhotoPublic&photoID=" + photoID;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- // Remove html from input
|
|
|
- description = lychee.removeHTML(description);
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- if (visible.photo()) {
|
|
|
- photo.json.description = description;
|
|
|
- view.photo.description();
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
- params = "setPhotoDescription&photoID=" + photoID + "&description=" + escape(encodeURI(description));
|
|
|
- lychee.api(params, function(data) {
|
|
|
+}
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+photo.setDescription = function(photoID) {
|
|
|
|
|
|
- });
|
|
|
+ var oldDescription = photo.json.description.replace("'", "'"),
|
|
|
+ description,
|
|
|
+ params,
|
|
|
+ buttons;
|
|
|
|
|
|
- }],
|
|
|
- ["Cancel", function() {}]
|
|
|
- ];
|
|
|
+ buttons = [
|
|
|
+ ["Set Description", function() {
|
|
|
|
|
|
- modal.show("Set Description", "Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
|
|
|
+ // Get input
|
|
|
+ description = $(".message input.text").val();
|
|
|
|
|
|
- },
|
|
|
+ // Remove html from input
|
|
|
+ description = lychee.removeHTML(description);
|
|
|
|
|
|
- editTags: function(photoIDs) {
|
|
|
+ if (visible.photo()) {
|
|
|
+ photo.json.description = description;
|
|
|
+ view.photo.description();
|
|
|
+ }
|
|
|
|
|
|
- var oldTags = "",
|
|
|
- tags = "",
|
|
|
- buttons;
|
|
|
+ params = "setPhotoDescription&photoID=" + photoID + "&description=" + escape(encodeURI(description));
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- // Get tags
|
|
|
- if (visible.photo()) oldTags = photo.json.tags;
|
|
|
- if (visible.album()&&photoIDs.length===1) oldTags = album.json.content[photoIDs].tags;
|
|
|
- if (visible.album()&&photoIDs.length>1) {
|
|
|
- var same = true;
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
- if(album.json.content[id].tags===album.json.content[photoIDs[0]].tags&&same===true) same = true;
|
|
|
- else same = false;
|
|
|
});
|
|
|
- if (same) oldTags = album.json.content[photoIDs[0]].tags;
|
|
|
- }
|
|
|
|
|
|
- // Improve tags
|
|
|
- oldTags = oldTags.replace(/,/g, ', ');
|
|
|
+ }],
|
|
|
+ ["Cancel", function() {}]
|
|
|
+ ];
|
|
|
|
|
|
- buttons = [
|
|
|
- ["Set Tags", function() {
|
|
|
+ modal.show("Set Description", "Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
|
|
|
|
|
|
- tags = $(".message input.text").val();
|
|
|
+}
|
|
|
|
|
|
- photo.setTags(photoIDs, tags);
|
|
|
+photo.editTags = function(photoIDs) {
|
|
|
|
|
|
- }],
|
|
|
- ["Cancel", function() {}]
|
|
|
- ];
|
|
|
+ var oldTags = "",
|
|
|
+ tags = "",
|
|
|
+ buttons;
|
|
|
|
|
|
- if (photoIDs.length===1) modal.show("Set Tags", "Enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
|
|
|
- else modal.show("Set Tags", "Enter your tags for all " + photoIDs.length + " selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- },
|
|
|
+ // Get tags
|
|
|
+ if (visible.photo()) oldTags = photo.json.tags;
|
|
|
+ if (visible.album()&&photoIDs.length===1) oldTags = album.json.content[photoIDs].tags;
|
|
|
+ if (visible.album()&&photoIDs.length>1) {
|
|
|
+ var same = true;
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
+ if(album.json.content[id].tags===album.json.content[photoIDs[0]].tags&&same===true) same = true;
|
|
|
+ else same = false;
|
|
|
+ });
|
|
|
+ if (same) oldTags = album.json.content[photoIDs[0]].tags;
|
|
|
+ }
|
|
|
|
|
|
- setTags: function(photoIDs, tags) {
|
|
|
+ // Improve tags
|
|
|
+ oldTags = oldTags.replace(/,/g, ', ');
|
|
|
|
|
|
- var params;
|
|
|
+ buttons = [
|
|
|
+ ["Set Tags", function() {
|
|
|
|
|
|
- if (!photoIDs) return false;
|
|
|
- if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+ tags = $(".message input.text").val();
|
|
|
|
|
|
- // Parse tags
|
|
|
- tags = tags.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g, ',');
|
|
|
- tags = tags.replace(/,$|^,|(\ ){0,}$/g, '');
|
|
|
+ photo.setTags(photoIDs, tags);
|
|
|
|
|
|
- // Remove html from input
|
|
|
- tags = lychee.removeHTML(tags);
|
|
|
+ }],
|
|
|
+ ["Cancel", function() {}]
|
|
|
+ ];
|
|
|
|
|
|
- if (visible.photo()) {
|
|
|
- photo.json.tags = tags;
|
|
|
- view.photo.tags();
|
|
|
- }
|
|
|
+ if (photoIDs.length===1) modal.show("Set Tags", "Enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
|
|
|
+ else modal.show("Set Tags", "Enter your tags for all " + photoIDs.length + " selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
|
|
|
|
|
|
- photoIDs.forEach(function(id, index, array) {
|
|
|
- album.json.content[id].tags = tags;
|
|
|
- });
|
|
|
+}
|
|
|
|
|
|
- params = "setPhotoTags&photoIDs=" + photoIDs + "&tags=" + tags;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+photo.setTags = function(photoIDs, tags) {
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ var params;
|
|
|
|
|
|
- });
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- },
|
|
|
+ // Parse tags
|
|
|
+ tags = tags.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g, ',');
|
|
|
+ tags = tags.replace(/,$|^,|(\ ){0,}$/g, '');
|
|
|
|
|
|
- deleteTag: function(photoID, index) {
|
|
|
+ // Remove html from input
|
|
|
+ tags = lychee.removeHTML(tags);
|
|
|
|
|
|
- var tags;
|
|
|
+ if (visible.photo()) {
|
|
|
+ photo.json.tags = tags;
|
|
|
+ view.photo.tags();
|
|
|
+ }
|
|
|
|
|
|
- // Remove
|
|
|
- tags = photo.json.tags.split(',');
|
|
|
- tags.splice(index, 1);
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
+ album.json.content[id].tags = tags;
|
|
|
+ });
|
|
|
|
|
|
- // Save
|
|
|
- photo.json.tags = tags.toString();
|
|
|
- photo.setTags([photoID], photo.json.tags);
|
|
|
+ params = "setPhotoTags&photoIDs=" + photoIDs + "&tags=" + tags;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- },
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- share: function(photoID, service) {
|
|
|
+ });
|
|
|
|
|
|
- var link = "",
|
|
|
- url = photo.getViewLink(photoID),
|
|
|
- filename = "unknown";
|
|
|
+}
|
|
|
|
|
|
- switch (service) {
|
|
|
- case 0:
|
|
|
- link = "https://twitter.com/share?url=" + encodeURI(url);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(photo.json.title);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- link = "mailto:?subject=" + encodeURI(photo.json.title) + "&body=" + encodeURI(url);
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- lychee.loadDropbox(function() {
|
|
|
- filename = photo.json.title + "." + photo.getDirectLink().split('.').pop();
|
|
|
- Dropbox.save(photo.getDirectLink(), filename);
|
|
|
- });
|
|
|
- break;
|
|
|
- default:
|
|
|
- link = "";
|
|
|
- break;
|
|
|
- }
|
|
|
+photo.deleteTag = function(photoID, index) {
|
|
|
|
|
|
- if (link.length>5) location.href = link;
|
|
|
+ var tags;
|
|
|
|
|
|
- },
|
|
|
+ // Remove
|
|
|
+ tags = photo.json.tags.split(',');
|
|
|
+ tags.splice(index, 1);
|
|
|
|
|
|
- getSize: function() {
|
|
|
+ // Save
|
|
|
+ photo.json.tags = tags.toString();
|
|
|
+ photo.setTags([photoID], photo.json.tags);
|
|
|
|
|
|
- // Size can be 'big, medium, small'
|
|
|
- // Default is big
|
|
|
- // Small is centered in the middle of the screen
|
|
|
- var size = "big",
|
|
|
- scaled = false,
|
|
|
- hasMedium = photo.json.medium!=="",
|
|
|
- pixelRatio = window.devicePixelRatio,
|
|
|
- view = {
|
|
|
- width: $(window).width()-60,
|
|
|
- height: $(window).height()-100
|
|
|
- };
|
|
|
+}
|
|
|
|
|
|
- // Detect if the photo will be shown scaled,
|
|
|
- // because the screen size is smaller than the photo
|
|
|
- if (photo.json.width>view.width||
|
|
|
- photo.json.width>view.height) scaled = true;
|
|
|
+photo.share = function(photoID, service) {
|
|
|
|
|
|
- // Calculate pixel ratio of screen
|
|
|
- if (pixelRatio!==undefined&&pixelRatio>1) {
|
|
|
- view.width = view.width * pixelRatio;
|
|
|
- view.height = view.height * pixelRatio;
|
|
|
- }
|
|
|
+ var link = "",
|
|
|
+ url = photo.getViewLink(photoID),
|
|
|
+ filename = "unknown";
|
|
|
|
|
|
- // Medium available and
|
|
|
- // Medium still bigger than screen
|
|
|
- if (hasMedium===true&&
|
|
|
- (1920>view.width&&1080>view.height)) size = "medium";
|
|
|
+ switch (service) {
|
|
|
+ case 0:
|
|
|
+ link = "https://twitter.com/share?url=" + encodeURI(url);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(photo.json.title);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ link = "mailto:?subject=" + encodeURI(photo.json.title) + "&body=" + encodeURI(url);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ lychee.loadDropbox(function() {
|
|
|
+ filename = photo.json.title + "." + photo.getDirectLink().split('.').pop();
|
|
|
+ Dropbox.save(photo.getDirectLink(), filename);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ link = "";
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- // Photo not scaled
|
|
|
- // Photo smaller then screen
|
|
|
- if (scaled===false&&
|
|
|
- (photo.json.width<view.width&&
|
|
|
- photo.json.width<view.height)) size = "small";
|
|
|
+ if (link.length>5) location.href = link;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+photo.getSize = function() {
|
|
|
+
|
|
|
+ // Size can be 'big, medium, small'
|
|
|
+ // Default is big
|
|
|
+ // Small is centered in the middle of the screen
|
|
|
+ var size = "big",
|
|
|
+ scaled = false,
|
|
|
+ hasMedium = photo.json.medium!=="",
|
|
|
+ pixelRatio = window.devicePixelRatio,
|
|
|
+ view = {
|
|
|
+ width: $(window).width()-60,
|
|
|
+ height: $(window).height()-100
|
|
|
+ };
|
|
|
+
|
|
|
+ // Detect if the photo will be shown scaled,
|
|
|
+ // because the screen size is smaller than the photo
|
|
|
+ if (photo.json.width>view.width||
|
|
|
+ photo.json.width>view.height) scaled = true;
|
|
|
+
|
|
|
+ // Calculate pixel ratio of screen
|
|
|
+ if (pixelRatio!==undefined&&pixelRatio>1) {
|
|
|
+ view.width = view.width * pixelRatio;
|
|
|
+ view.height = view.height * pixelRatio;
|
|
|
+ }
|
|
|
|
|
|
- return size;
|
|
|
+ // Medium available and
|
|
|
+ // Medium still bigger than screen
|
|
|
+ if (hasMedium===true&&
|
|
|
+ (1920>view.width&&1080>view.height)) size = "medium";
|
|
|
|
|
|
- },
|
|
|
+ // Photo not scaled
|
|
|
+ // Photo smaller then screen
|
|
|
+ if (scaled===false&&
|
|
|
+ (photo.json.width<view.width&&
|
|
|
+ photo.json.width<view.height)) size = "small";
|
|
|
|
|
|
- getArchive: function(photoID) {
|
|
|
+ return size;
|
|
|
|
|
|
- var link,
|
|
|
- url = "php/api.php?function=getPhotoArchive&photoID=" + photoID;
|
|
|
+}
|
|
|
|
|
|
- if (location.href.indexOf("index.html")>0) link = location.href.replace(location.hash, "").replace("index.html", url);
|
|
|
- else link = location.href.replace(location.hash, "") + url;
|
|
|
+photo.getArchive = function(photoID) {
|
|
|
|
|
|
- if (lychee.publicMode) link += "&password=" + password.value;
|
|
|
+ var link,
|
|
|
+ url = "php/api.php?function=getPhotoArchive&photoID=" + photoID;
|
|
|
|
|
|
- location.href = link;
|
|
|
+ if (location.href.indexOf("index.html")>0) link = location.href.replace(location.hash, "").replace("index.html", url);
|
|
|
+ else link = location.href.replace(location.hash, "") + url;
|
|
|
|
|
|
- },
|
|
|
+ if (lychee.publicMode) link += "&password=" + password.value;
|
|
|
|
|
|
- getDirectLink: function() {
|
|
|
+ location.href = link;
|
|
|
|
|
|
- var url = "";
|
|
|
+}
|
|
|
|
|
|
- if (photo.json&&
|
|
|
- photo.json.url&&
|
|
|
- photo.json.url!=="") url = photo.json.url;
|
|
|
+photo.getDirectLink = function() {
|
|
|
|
|
|
- return url;
|
|
|
+ var url = "";
|
|
|
|
|
|
- },
|
|
|
+ if (photo.json&&
|
|
|
+ photo.json.url&&
|
|
|
+ photo.json.url!=="") url = photo.json.url;
|
|
|
|
|
|
- getViewLink: function(photoID) {
|
|
|
+ return url;
|
|
|
|
|
|
- var url = "view.php?p=" + photoID;
|
|
|
+}
|
|
|
|
|
|
- if (location.href.indexOf("index.html")>0) return location.href.replace("index.html" + location.hash, url);
|
|
|
- else return location.href.replace(location.hash, url);
|
|
|
+photo.getViewLink = function(photoID) {
|
|
|
|
|
|
- }
|
|
|
+ var url = "view.php?p=" + photoID;
|
|
|
+
|
|
|
+ if (location.href.indexOf("index.html")>0) return location.href.replace("index.html" + location.hash, url);
|
|
|
+ else return location.href.replace(location.hash, url);
|
|
|
|
|
|
-};
|
|
|
+}
|