|
@@ -56,40 +56,47 @@ photo = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- delete: function(photoID) {
|
|
|
+ delete: function(photoIDs) {
|
|
|
|
|
|
var params,
|
|
|
buttons,
|
|
|
photoTitle;
|
|
|
|
|
|
- if (!photoID) return false;
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- if (visible.photo()) photoTitle = photo.json.title;
|
|
|
- else photoTitle = album.json.content[photoID].title;
|
|
|
- if (photoTitle=="") photoTitle = "Untitled";
|
|
|
+ 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";
|
|
|
+ }
|
|
|
|
|
|
buttons = [
|
|
|
- ["Delete Photo", function() {
|
|
|
+ ["", function() {
|
|
|
|
|
|
- // Change reference for the next and previous photo
|
|
|
- if (album.json.content[photoID].nextPhoto!==""||album.json.content[photoID].previousPhoto!=="") {
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
|
|
|
- nextPhoto = album.json.content[photoID].nextPhoto;
|
|
|
- previousPhoto = album.json.content[photoID].previousPhoto;
|
|
|
+ // Change reference for the next and previous photo
|
|
|
+ if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
|
|
|
- album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
- album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
+ nextPhoto = album.json.content[id].nextPhoto;
|
|
|
+ previousPhoto = album.json.content[id].previousPhoto;
|
|
|
|
|
|
- }
|
|
|
+ album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
+ album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
|
|
|
- album.json.content[photoID] = null;
|
|
|
+ }
|
|
|
|
|
|
- view.album.content.delete(photoID);
|
|
|
+ album.json.content[id] = null;
|
|
|
+ view.album.content.delete(id);
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
// Only when search is not active
|
|
|
if (!visible.albums()) lychee.goto(album.getID());
|
|
|
|
|
|
- params = "deletePhoto&photoID=" + photoID;
|
|
|
+ params = "deletePhoto&photoIDs=" + photoIDs;
|
|
|
lychee.api(params, function(data) {
|
|
|
|
|
|
if (data!==true) lychee.error(null, params, data);
|
|
@@ -97,99 +104,131 @@ photo = {
|
|
|
});
|
|
|
|
|
|
}],
|
|
|
- ["Keep Photo", function() {}]
|
|
|
+ ["", function() {}]
|
|
|
];
|
|
|
- modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
|
|
|
+
|
|
|
+ if (photoIDs.length===1) {
|
|
|
+
|
|
|
+ buttons[0][0] = "Delete Photo";
|
|
|
+ buttons[1][0] = "Keep Photo";
|
|
|
+
|
|
|
+ modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ buttons[0][0] = "Delete Photos";
|
|
|
+ buttons[1][0] = "Keep Photos";
|
|
|
+
|
|
|
+ modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?<br>This action can't be undone!", buttons);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
|
|
|
- setTitle: function(photoID) {
|
|
|
+ setTitle: function(photoIDs) {
|
|
|
|
|
|
var oldTitle = "",
|
|
|
newTitle,
|
|
|
params,
|
|
|
buttons;
|
|
|
|
|
|
- if (!photoID) return false;
|
|
|
- if (photo.json) oldTitle = photo.json.title;
|
|
|
- else if (album.json) oldTitle = album.json.content[photoID].title;
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
buttons = [
|
|
|
["Set Title", function() {
|
|
|
|
|
|
newTitle = $(".message input.text").val();
|
|
|
|
|
|
- if (photoID!=null&&photoID&&newTitle.length<31) {
|
|
|
+ if (newTitle.length<31) {
|
|
|
|
|
|
if (visible.photo()) {
|
|
|
photo.json.title = (newTitle==="") ? "Untitled" : newTitle;
|
|
|
- view.photo.title(oldTitle);
|
|
|
+ view.photo.title();
|
|
|
}
|
|
|
|
|
|
- album.json.content[photoID].title = newTitle;
|
|
|
- view.album.content.title(photoID);
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
+ album.json.content[id].title = newTitle;
|
|
|
+ view.album.content.title(id);
|
|
|
+ });
|
|
|
|
|
|
- params = "setPhotoTitle&photoID=" + photoID + "&title=" + escape(encodeURI(newTitle));
|
|
|
+ params = "setPhotoTitle&photoIDs=" + photoIDs + "&title=" + escape(encodeURI(newTitle));
|
|
|
lychee.api(params, function(data) {
|
|
|
|
|
|
if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
});
|
|
|
|
|
|
- } else if (newTitle.length>0) loadingBar.show("error", "New title to short or too long. Please try another one!");
|
|
|
+ } else if (newTitle.length>30) loadingBar.show("error", "New title too long. Please try another one!");
|
|
|
|
|
|
}],
|
|
|
["Cancel", function() {}]
|
|
|
];
|
|
|
- modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons);
|
|
|
+
|
|
|
+ if (photoIDs.length===1) modal.show("Set Title", "Please enter a new title for this photo: <input class='text' type='text' placeholder='Title' value='" + oldTitle + "'>", buttons);
|
|
|
+ else modal.show("Set Titles", "Please enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' placeholder='Title' value=''>", buttons);
|
|
|
|
|
|
},
|
|
|
|
|
|
- setAlbum: function(albumID, photoID) {
|
|
|
+ setAlbum: function(photoIDs, albumID) {
|
|
|
|
|
|
- var params;
|
|
|
+ var params,
|
|
|
+ nextPhoto,
|
|
|
+ previousPhoto;
|
|
|
+
|
|
|
+ if (!photoIDs) return false;
|
|
|
+ if (visible.photo) lychee.goto(album.getID());
|
|
|
+ if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
|
|
|
|
|
|
- if (albumID>=0) {
|
|
|
+ photoIDs.forEach(function(id, index, array) {
|
|
|
|
|
|
// Change reference for the next and previous photo
|
|
|
- if (album.json.content[photoID].nextPhoto!==""||album.json.content[photoID].previousPhoto!=="") {
|
|
|
+ if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
|
|
|
|
|
|
- nextPhoto = album.json.content[photoID].nextPhoto;
|
|
|
- previousPhoto = album.json.content[photoID].previousPhoto;
|
|
|
+ nextPhoto = album.json.content[id].nextPhoto;
|
|
|
+ previousPhoto = album.json.content[id].previousPhoto;
|
|
|
|
|
|
album.json.content[previousPhoto].nextPhoto = nextPhoto;
|
|
|
album.json.content[nextPhoto].previousPhoto = previousPhoto;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (visible.photo) lychee.goto(album.getID());
|
|
|
- album.json.content[photoID] = null;
|
|
|
- view.album.content.delete(photoID);
|
|
|
+ album.json.content[id] = null;
|
|
|
+ view.album.content.delete(id);
|
|
|
|
|
|
- params = "setAlbum&photoID=" + photoID + "&albumID=" + albumID;
|
|
|
- lychee.api(params, function(data) {
|
|
|
+ });
|
|
|
|
|
|
- if (data!==true) lychee.error(null, params, data);
|
|
|
+ params = "setAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
|
|
|
+ lychee.api(params, function(data) {
|
|
|
|
|
|
- });
|
|
|
+ if (data!==true) lychee.error(null, params, data);
|
|
|
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
},
|
|
|
|
|
|
- setStar: function(photoID) {
|
|
|
+ setStar: function(photoIDs) {
|
|
|
|
|
|
var params;
|
|
|
|
|
|
+ if (!photoIDs) return false;
|
|
|
if (visible.photo()) {
|
|
|
photo.json.star = (photo.json.star==0) ? 1 : 0;
|
|
|
view.photo.star();
|
|
|
}
|
|
|
|
|
|
- album.json.content[photoID].star = (album.json.content[photoID].star==0) ? 1 : 0;
|
|
|
- view.album.content.star(photoID);
|
|
|
+ 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 = "setPhotoStar&photoID=" + photoID;
|
|
|
+ params = "setPhotoStar&photoIDs=" + photoIDs;
|
|
|
lychee.api(params, function(data) {
|
|
|
|
|
|
if (data!==true) lychee.error(null, params, data);
|