This commit is contained in:
Tobias Reich 2014-11-12 17:19:42 +01:00
parent 95b8664ba1
commit 8378fb24d9
4 changed files with 651 additions and 656 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -3,31 +3,30 @@
* @copyright 2014 by Tobias Reich * @copyright 2014 by Tobias Reich
*/ */
modal = { modal = {}
fns: null, modal.fns = null;
show: function(title, text, buttons, marginTop, closeButton) { modal.show = function(title, text, buttons, marginTop, closeButton) {
if (!buttons) { if (!buttons) {
buttons = [ buttons = [
["", function() {}], ['', function() {}],
["", function() {}] ['', function() {}]
]; ];
} }
modal.fns = [buttons[0][1], buttons[1][1]]; modal.fns = [buttons[0][1], buttons[1][1]];
$("body").append(build.modal(title, text, buttons, marginTop, closeButton));
$(".message input:first-child").focus().select();
}, $('body').append(build.modal(title, text, buttons, marginTop, closeButton));
$('.message input:first-child').focus().select();
close: function() {
modal.fns = null;
$(".message_overlay").removeClass("fadeIn").css("opacity", 0);
setTimeout(function() { $(".message_overlay").remove() }, 300);
} }
}; modal.close = function() {
modal.fns = null;
$('.message_overlay').removeClass('fadeIn').css('opacity', 0);
setTimeout(function() { $('.message_overlay').remove() }, 300);
}

View File

@ -3,13 +3,13 @@
* @copyright 2014 by Tobias Reich * @copyright 2014 by Tobias Reich
*/ */
password = { password = {}
value: "", password.value = '';
get: function(albumID, callback) { password.get = function(albumID, callback) {
var passwd = $(".message input.text").val(), var passwd = $('.message input.text').val(),
params; params;
if (!lychee.publicMode) callback(); if (!lychee.publicMode) callback();
@ -19,7 +19,7 @@ password = {
// Continue without password // Continue without password
album.json = {password: true}; album.json = {password: true};
callback(""); callback('');
} else if (passwd==undefined) { } else if (passwd==undefined) {
@ -29,33 +29,31 @@ password = {
} else { } else {
// Check password // Check password
params = "checkAlbumAccess&albumID=" + albumID + "&password=" + md5(passwd); params = 'checkAlbumAccess&albumID=' + albumID + '&password=' + md5(passwd);
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data===true) { if (data===true) {
password.value = md5(passwd); password.value = md5(passwd);
callback(); callback();
} else { } else {
lychee.goto(""); lychee.goto('');
loadingBar.show("error", "Access denied. Wrong password!"); loadingBar.show('error', 'Access denied. Wrong password!');
} }
}); });
} }
}, }
getDialog: function(albumID, callback) { password.getDialog = function(albumID, callback) {
var buttons; var buttons;
buttons = [ buttons = [
["Enter", function() { password.get(albumID, callback) }], ['Enter', function() { password.get(albumID, callback) }],
["Cancel", lychee.goto] ['Cancel', lychee.goto]
]; ];
modal.show("<a class='icon-lock'></a> Enter Password", "This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>", buttons, -110, false); modal.show('<a class="icon-lock"></a> Enter Password', 'This album is protected by a password. Enter the password below to view the photos of this album: <input class="text" type="password" placeholder="password" value="">', buttons, -110, false);
} }
};

View File

@ -3,29 +3,29 @@
* @copyright 2014 by Tobias Reich * @copyright 2014 by Tobias Reich
*/ */
photo = { photo = {}
json: null, photo.json = null;
cache: null, photo.cache = null;
getID: function() { photo.getID = function() {
var id; var id;
if (photo.json) id = photo.json.id; if (photo.json) id = photo.json.id;
else id = $(".photo:hover, .photo.active").attr("data-id"); else id = $('.photo:hover, .photo.active').attr('data-id');
if (id) return id; if (id) return id;
else return false; else return false;
}, }
load: function(photoID, albumID) { photo.load = function(photoID, albumID) {
var params, var params,
checkPasswd; checkPasswd;
params = "getPhoto&photoID=" + photoID + "&albumID=" + albumID + "&password=" + password.value; params = 'getPhoto&photoID=' + photoID + '&albumID=' + albumID + '&password=' + password.value;
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data==="Warning: Wrong password!") { if (data==="Warning: Wrong password!") {
@ -49,10 +49,10 @@ photo = {
}); });
}, }
// Preload the next photo for better response time // Preload the next photo for better response time
preloadNext: function(photoID) { photo.preloadNext = function(photoID) {
var nextPhoto, var nextPhoto,
url; url;
@ -75,15 +75,15 @@ photo = {
} }
}, }
parse: function() { photo.parse = function() {
if (!photo.json.title) photo.json.title = "Untitled"; if (!photo.json.title) photo.json.title = "Untitled";
}, }
previous: function(animate) { photo.previous = function(animate) {
var delay = 0; var delay = 0;
@ -112,9 +112,9 @@ photo = {
} }
}, }
next: function(animate) { photo.next = function(animate) {
var delay = 0; var delay = 0;
@ -143,9 +143,9 @@ photo = {
} }
}, }
duplicate: function(photoIDs) { photo.duplicate = function(photoIDs) {
var params; var params;
@ -162,9 +162,9 @@ photo = {
}); });
}, }
delete: function(photoIDs) { photo.delete = function(photoIDs) {
var params, var params,
buttons, buttons,
@ -238,9 +238,9 @@ photo = {
} }
}, }
setTitle: function(photoIDs) { photo.setTitle = function(photoIDs) {
var oldTitle = "", var oldTitle = "",
newTitle, newTitle,
@ -290,9 +290,9 @@ photo = {
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); 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); 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);
}, }
setAlbum: function(photoIDs, albumID) { photo.setAlbum = function(photoIDs, albumID) {
var params, var params,
nextPhoto, nextPhoto,
@ -329,9 +329,9 @@ photo = {
}); });
}, }
setStar: function(photoIDs) { photo.setStar = function(photoIDs) {
var params; var params;
@ -355,9 +355,9 @@ photo = {
}); });
}, }
setPublic: function(photoID, e) { photo.setPublic = function(photoID, e) {
var params; var params;
@ -388,9 +388,9 @@ photo = {
}); });
}, }
setDescription: function(photoID) { photo.setDescription = function(photoID) {
var oldDescription = photo.json.description.replace("'", "&apos;"), var oldDescription = photo.json.description.replace("'", "&apos;"),
description, description,
@ -424,9 +424,9 @@ photo = {
modal.show("Set Description", "Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons); modal.show("Set Description", "Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
}, }
editTags: function(photoIDs) { photo.editTags = function(photoIDs) {
var oldTags = "", var oldTags = "",
tags = "", tags = "",
@ -464,9 +464,9 @@ photo = {
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); 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); 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);
}, }
setTags: function(photoIDs, tags) { photo.setTags = function(photoIDs, tags) {
var params; var params;
@ -496,9 +496,9 @@ photo = {
}); });
}, }
deleteTag: function(photoID, index) { photo.deleteTag = function(photoID, index) {
var tags; var tags;
@ -510,9 +510,9 @@ photo = {
photo.json.tags = tags.toString(); photo.json.tags = tags.toString();
photo.setTags([photoID], photo.json.tags); photo.setTags([photoID], photo.json.tags);
}, }
share: function(photoID, service) { photo.share = function(photoID, service) {
var link = "", var link = "",
url = photo.getViewLink(photoID), url = photo.getViewLink(photoID),
@ -541,9 +541,9 @@ photo = {
if (link.length>5) location.href = link; if (link.length>5) location.href = link;
}, }
getSize: function() { photo.getSize = function() {
// Size can be 'big, medium, small' // Size can be 'big, medium, small'
// Default is big // Default is big
@ -581,9 +581,9 @@ photo = {
return size; return size;
}, }
getArchive: function(photoID) { photo.getArchive = function(photoID) {
var link, var link,
url = "php/api.php?function=getPhotoArchive&photoID=" + photoID; url = "php/api.php?function=getPhotoArchive&photoID=" + photoID;
@ -595,9 +595,9 @@ photo = {
location.href = link; location.href = link;
}, }
getDirectLink: function() { photo.getDirectLink = function() {
var url = ""; var url = "";
@ -607,9 +607,9 @@ photo = {
return url; return url;
}, }
getViewLink: function(photoID) { photo.getViewLink = function(photoID) {
var url = "view.php?p=" + photoID; var url = "view.php?p=" + photoID;
@ -617,5 +617,3 @@ photo = {
else return location.href.replace(location.hash, url); else return location.href.replace(location.hash, url);
} }
};