Browse Source

Front-end rewrite #275

Tobias Reich 9 years ago
parent
commit
752d094775
5 changed files with 328 additions and 325 deletions
  1. 0 0
      dist/main.js
  2. 266 265
      src/scripts/album.js
  3. 54 56
      src/scripts/loadingBar.js
  4. 1 1
      src/scripts/password.js
  5. 7 3
      src/scripts/photo.js

File diff suppressed because it is too large
+ 0 - 0
dist/main.js


+ 266 - 265
src/scripts/album.js

@@ -3,402 +3,403 @@
  * @copyright	2014 by Tobias Reich
  */
 
-album = {
+album = {}
 
-	json: null,
+album.json = null;
 
-	getID: function() {
+album.getID = function() {
 
-		var id;
+	var id;
 
-		if (photo.json) id = photo.json.album;
-		else if (album.json) id = album.json.id;
-		else id = $(".album:hover, .album.active").attr("data-id");
+	if (photo.json)			id = photo.json.album;
+	else if (album.json)	id = album.json.id;
+	else					id = $('.album:hover, .album.active').attr('data-id');
 
-		// Search
-		if (!id) id = $(".album:hover, .album.active").attr("data-id");
-		if (!id) id = $(".photo:hover, .photo.active").attr("data-album-id");
+	// Search
+	if (!id) id = $('.album:hover, .album.active').attr('data-id');
+	if (!id) id = $('.photo:hover, .photo.active').attr('data-album-id');
 
-		if (id) return id;
-		else return false;
+	if (id)	return id;
+	else	return false;
 
-	},
+}
 
-	load: function(albumID, refresh) {
+album.load = function(albumID, refresh) {
 
-		var startTime,
-			params,
-			durationTime,
-			waitTime;
+	var startTime,
+		params,
+		durationTime,
+		waitTime;
 
-		password.get(albumID, function() {
+	password.get(albumID, function() {
 
-			if (!refresh) {
-				loadingBar.show();
-				lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomOut");
-				lychee.animate(".divider", "fadeOut");
-			}
-
-			startTime = new Date().getTime();
+		if (!refresh) {
+			lychee.animate('.album:nth-child(-n+50), .photo:nth-child(-n+50)', 'contentZoomOut');
+			lychee.animate('.divider', 'fadeOut');
+		}
 
-			params = "getAlbum&albumID=" + albumID + "&password=" + password.value;
-			lychee.api(params, function(data) {
+		startTime = new Date().getTime();
 
-				if (data==="Warning: Album private!") {
-					if (document.location.hash.replace("#", "").split("/")[1]!=undefined) {
-						// Display photo only
-						lychee.setMode("view");
-					} else {
-						// Album not public
-						lychee.content.show();
-						lychee.goto("");
-					}
-					return false;
-				}
+		params = 'getAlbum&albumID=' + albumID + '&password=' + password.value;
+		lychee.api(params, function(data) {
 
-				if (data==="Warning: Wrong password!") {
-					album.load(albumID, refresh);
-					return false;
+			if (data==='Warning: Album private!') {
+				if (document.location.hash.replace('#', '').split('/')[1]!=undefined) {
+					// Display photo only
+					lychee.setMode('view');
+				} else {
+					// Album not public
+					lychee.content.show();
+					lychee.goto('');
 				}
+				return false;
+			}
 
-				album.json = data;
+			if (data==='Warning: Wrong password!') {
+				album.load(albumID, refresh);
+				return false;
+			}
 
-				// Calculate delay
-				durationTime = (new Date().getTime() - startTime);
-				if (durationTime>300)	waitTime = 0;
-				else					waitTime = 300 - durationTime;
+			album.json = data;
 
-				// Skip delay when refresh is true
-				// Skip delay when opening a blank Lychee
-				if (refresh===true)											waitTime = 0;
-				if (!visible.albums()&&!visible.photo()&&!visible.album())	waitTime = 0;
+			// Calculate delay
+			durationTime = (new Date().getTime() - startTime);
+			if (durationTime>300)	waitTime = 0;
+			else					waitTime = 300 - durationTime;
 
-				setTimeout(function() {
+			// Skip delay when refresh is true
+			// Skip delay when opening a blank Lychee
+			if (refresh===true)											waitTime = 0;
+			if (!visible.albums()&&!visible.photo()&&!visible.album())	waitTime = 0;
 
-					view.album.init();
+			setTimeout(function() {
 
-					if (!refresh) {
-						lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
-						view.header.mode("album");
-					}
+				view.album.init();
 
-				}, waitTime);
+				if (!refresh) {
+					lychee.animate('.album:nth-child(-n+50), .photo:nth-child(-n+50)', 'contentZoomIn');
+					view.header.mode('album');
+				}
 
-			});
+			}, waitTime);
 
 		});
 
-	},
+	});
 
-	parse: function() {
+}
 
-		if (!album.json.title) album.json.title = "Untitled";
+album.parse = function() {
 
-	},
+	if (!album.json.title) album.json.title = 'Untitled';
 
-	add: function() {
+}
 
-		var title,
-			params,
-			buttons,
-			isNumber = function(n) { return !isNaN(parseFloat(n)) && isFinite(n) };
+album.add = function() {
 
-		buttons = [
-			["Create Album", function() {
+	var title,
+		params,
+		buttons,
+		isNumber = function(n) { return !isNaN(parseFloat(n)) && isFinite(n) };
 
-				title = $(".message input.text").val();
+	buttons = [
+		['Create Album', function() {
 
-				if (title.length===0) title = "Untitled";
+			title = $('.message input.text').val();
 
-				modal.close();
+			if (title.length===0) title = 'Untitled';
 
-				params = "addAlbum&title=" + escape(encodeURI(title));
-				lychee.api(params, function(data) {
+			modal.close();
 
-					if (data===true) data = 1; // Avoid first album to be true
+			params = 'addAlbum&title=' + escape(encodeURI(title));
+			lychee.api(params, function(data) {
 
-					if (data!==false&&isNumber(data)) {
-						albums.refresh();
-						lychee.goto(data);
-					} else {
-						lychee.error(null, params, data);
-					}
+				// Avoid first album to be true
+				if (data===true) data = 1;
 
-				});
+				if (data!==false&&isNumber(data)) {
+					albums.refresh();
+					lychee.goto(data);
+				} else {
+					lychee.error(null, params, data);
+				}
 
-			}],
-			["Cancel", function() {}]
-		];
+			});
 
-		modal.show("New Album", "Enter a title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='Untitled'>", buttons);
+		}],
+		['Cancel', function() {}]
+	];
 
-	},
+	modal.show('New Album', "Enter a title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='Untitled'>", buttons);
 
-	delete: function(albumIDs) {
+}
 
-		var params,
-			buttons,
-			albumTitle;
+album.delete = function(albumIDs) {
 
-		if (!albumIDs) return false;
-		if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
+	var params,
+		buttons,
+		albumTitle;
 
-		buttons = [
-			["", function() {
+	if (!albumIDs) return false;
+	if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
 
-				params = "deleteAlbum&albumIDs=" + albumIDs;
-				lychee.api(params, function(data) {
+	buttons = [
+		['', function() {
 
-					if (visible.albums()) {
+			params = 'deleteAlbum&albumIDs=' + albumIDs;
+			lychee.api(params, function(data) {
 
-						albumIDs.forEach(function(id) {
-							albums.json.num--;
-							view.albums.content.delete(id);
-							delete albums.json.content[id];
-						});
+				if (visible.albums()) {
 
-					} else {
+					albumIDs.forEach(function(id) {
+						albums.json.num--;
+						view.albums.content.delete(id);
+						delete albums.json.content[id];
+					});
 
-						albums.refresh();
-						lychee.goto("");
+				} else {
 
-					}
+					albums.refresh();
+					lychee.goto('');
 
-					if (data!==true) lychee.error(null, params, data);
+				}
 
-				});
+				if (data!==true) lychee.error(null, params, data);
 
-			}],
-			["", function() {}]
-		];
+			});
 
-		if (albumIDs.toString()==="0") {
+		}],
+		['', function() {}]
+	];
 
-			buttons[0][0] = "Clear Unsorted";
-			buttons[1][0] = "Keep Unsorted";
+	if (albumIDs.toString()==='0') {
 
-			modal.show("Clear Unsorted", "Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!", buttons);
+		buttons[0][0] = 'Clear Unsorted';
+		buttons[1][0] = 'Keep Unsorted';
 
-		} else if (albumIDs.length===1) {
+		modal.show('Clear Unsorted', "Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!", buttons);
 
-			buttons[0][0] = "Delete Album and Photos";
-			buttons[1][0] = "Keep Album";
+	} else if (albumIDs.length===1) {
 
-			// Get title
-			if (album.json) albumTitle = album.json.title;
-			else if (albums.json) albumTitle = albums.json.content[albumIDs].title;
+		buttons[0][0] = 'Delete Album and Photos';
+		buttons[1][0] = 'Keep Album';
 
-			modal.show("Delete Album", "Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!", buttons);
+		// Get title
+		if (album.json)			albumTitle = album.json.title;
+		else if (albums.json)	albumTitle = albums.json.content[albumIDs].title;
 
-		} else {
+		modal.show('Delete Album', "Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!", buttons);
 
-			buttons[0][0] = "Delete Albums and Photos";
-			buttons[1][0] = "Keep Albums";
+	} else {
 
-			modal.show("Delete Albums", "Are you sure you want to delete all " + albumIDs.length + " selected albums and all of the photos they contain? This action can't be undone!", buttons);
+		buttons[0][0] = 'Delete Albums and Photos';
+		buttons[1][0] = 'Keep Albums';
 
-		}
+		modal.show('Delete Albums', "Are you sure you want to delete all " + albumIDs.length + " selected albums and all of the photos they contain? This action can't be undone!", buttons);
 
-	},
+	}
 
-	setTitle: function(albumIDs) {
+}
 
-		var oldTitle = "",
-			newTitle,
-			params,
-			buttons;
+album.setTitle = function(albumIDs) {
 
-		if (!albumIDs) return false;
-		if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
+	var oldTitle = '',
+		newTitle,
+		params,
+		buttons;
 
-		if (albumIDs.length===1) {
-			// Get old title if only one album is selected
-			if (album.json) oldTitle = album.json.title;
-			else if (albums.json) oldTitle = albums.json.content[albumIDs].title;
-			if (!oldTitle) oldTitle = "";
-			oldTitle = oldTitle.replace("'", "&apos;");
-		}
+	if (!albumIDs) return false;
+	if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
 
-		buttons = [
-			["Set Title", function() {
+	if (albumIDs.length===1) {
 
-				// Get input
-				newTitle = $(".message input.text").val();
+		// Get old title if only one album is selected
+		if (album.json)			oldTitle = album.json.title;
+		else if (albums.json)	oldTitle = albums.json.content[albumIDs].title;
 
-				// Remove html from input
-				newTitle = lychee.removeHTML(newTitle);
+		if (!oldTitle) oldTitle = '';
+		oldTitle = oldTitle.replace("'", '&apos;');
 
-				// Set to Untitled when empty
-				newTitle = (newTitle==="") ? "Untitled" : newTitle;
+	}
 
-				if (visible.album()) {
+	buttons = [
+		['Set Title', function() {
 
-					album.json.title = newTitle;
-					view.album.title();
+			// Get input
+			newTitle = $('.message input.text').val();
 
-					if (albums.json) {
-						var id = albumIDs[0];
-						albums.json.content[id].title = newTitle;
-					}
+			// Remove html from input
+			newTitle = lychee.removeHTML(newTitle);
 
-				} else if (visible.albums()) {
+			// Set to Untitled when empty
+			newTitle = (newTitle==='') ? 'Untitled' : newTitle;
 
-					albumIDs.forEach(function(id) {
-						albums.json.content[id].title = newTitle;
-						view.albums.content.title(id);
-					});
+			if (visible.album()) {
 
-				}
+				album.json.title = newTitle;
+				view.album.title();
 
-				params = "setAlbumTitle&albumIDs=" + albumIDs + "&title=" + escape(encodeURI(newTitle));
-				lychee.api(params, function(data) {
+				if (albums.json) {
+					var id = albumIDs[0];
+					albums.json.content[id].title = newTitle;
+				}
 
-					if (data!==true) lychee.error(null, params, data);
+			} else if (visible.albums()) {
 
+				albumIDs.forEach(function(id) {
+					albums.json.content[id].title = newTitle;
+					view.albums.content.title(id);
 				});
 
-			}],
-			["Cancel", function() {}]
-		];
+			}
 
-		if (albumIDs.length===1) modal.show("Set Title", "Enter a new title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
-		else modal.show("Set Titles", "Enter a title for all " + albumIDs.length + " selected album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
+			params = 'setAlbumTitle&albumIDs=' + albumIDs + '&title=' + escape(encodeURI(newTitle));
+			lychee.api(params, function(data) {
 
-	},
+				if (data!==true) lychee.error(null, params, data);
 
-	setDescription: function(photoID) {
+			});
 
-		var oldDescription = album.json.description.replace("'", "&apos;"),
-			description,
-			params,
-			buttons;
+		}],
+		['Cancel', function() {}]
+	];
 
-		buttons = [
-			["Set Description", function() {
+	if (albumIDs.length===1) modal.show('Set Title', "Enter a new title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
+	else modal.show('Set Titles', "Enter a title for all " + albumIDs.length + " selected album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
 
-				// Get input
-				description = $(".message input.text").val();
+}
 
-				// Remove html from input
-				description = lychee.removeHTML(description);
+album.setDescription = function(photoID) {
 
-				if (visible.album()) {
-					album.json.description = description;
-					view.album.description();
-				}
+	var oldDescription = album.json.description.replace("'", '&apos;'),
+		description,
+		params,
+		buttons;
 
-				params = "setAlbumDescription&albumID=" + photoID + "&description=" + escape(encodeURI(description));
-				lychee.api(params, function(data) {
+	buttons = [
+		['Set Description', function() {
 
-					if (data!==true) lychee.error(null, params, data);
+			// Get input
+			description = $('.message input.text').val();
 
-				});
+			// Remove html from input
+			description = lychee.removeHTML(description);
+
+			if (visible.album()) {
+				album.json.description = description;
+				view.album.description();
+			}
 
-			}],
-			["Cancel", function() {}]
-		];
+			params = 'setAlbumDescription&albumID=' + photoID + '&description=' + escape(encodeURI(description));
+			lychee.api(params, function(data) {
 
-		modal.show("Set Description", "Please enter a description for this album: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
+				if (data!==true) lychee.error(null, params, data);
 
-	},
+			});
 
-	setPublic: function(albumID, e) {
+		}],
+		['Cancel', function() {}]
+	];
 
-		var params,
-			password = "",
-			listed = false,
-			downloadable = false;
+	modal.show('Set Description', "Please enter a description for this album: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
 
-		albums.refresh();
+}
 
-		if (!visible.message()&&album.json.public==0) {
+album.setPublic = function(albumID, e) {
 
-			modal.show("Share Album", "This album will be shared with the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='downloadable' value='downloadable'><h2>Downloadable</h2><p>Visitors of your Lychee can download this album.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]], -170);
+	var params,
+		password		= '',
+		listed			= false,
+		downloadable	= false;
 
-			$(".message .choice input[name='password']").on("change", function() {
+	albums.refresh();
 
-				if ($(this).prop('checked')===true) $(".message .choice input.text").show();
-				else $(".message .choice input.text").hide();
+	if (!visible.message()&&album.json.public==0) {
 
-			});
+		modal.show('Share Album', "This album will be shared with the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='downloadable' value='downloadable'><h2>Downloadable</h2><p>Visitors of your Lychee can download this album.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>", [['Share Album', function() { album.setPublic(album.getID(), e) }], ['Cancel', function() {}]], -170);
 
-			return true;
+		$('.message .choice input[name="password"]').on('change', function() {
 
-		}
+			if ($(this).prop('checked')===true)	$('.message .choice input.text').show();
+			else								$('.message .choice input.text').hide();
 
-		if (visible.message()) {
+		});
 
-			if ($(".message .choice input[name='password']:checked").val()==="password") {
-				password = md5($(".message input.text").val());
-				album.json.password = 1;
-			} else {
-				password = "";
-				album.json.password = 0;
-			}
+		return true;
+
+	}
 
-			if ($(".message .choice input[name='listed']:checked").val()==="listed") listed = true;
-			if ($(".message .choice input[name='downloadable']:checked").val()==="downloadable") downloadable = true;
+	if (visible.message()) {
 
+		if ($('.message .choice input[name="password"]:checked').val()==='password') {
+			password			= md5($('.message input.text').val());
+			album.json.password	= 1;
+		} else {
+			password			= '';
+			album.json.password	= 0;
 		}
 
-		params = "setAlbumPublic&albumID=" + albumID + "&password=" + password + "&visible=" + listed + "&downloadable=" + downloadable;
+		if ($('.message .choice input[name="listed"]:checked').val()==='listed')				listed = true;
+		if ($('.message .choice input[name="downloadable"]:checked').val()==='downloadable')	downloadable = true;
 
-		if (visible.album()) {
+	}
 
-			album.json.public = (album.json.public==0) ? 1 : 0;
-			album.json.password = (album.json.public==0) ? 0 : album.json.password;
+	params = 'setAlbumPublic&albumID=' + albumID + '&password=' + password + '&visible=' + listed + '&downloadable=' + downloadable;
 
-			view.album.public();
-			view.album.password();
+	if (visible.album()) {
 
-			if (album.json.public==1) contextMenu.shareAlbum(albumID, e);
+		album.json.public	= (album.json.public==0) ? 1 : 0;
+		album.json.password	= (album.json.public==0) ? 0 : album.json.password;
 
-		}
+		view.album.public();
+		view.album.password();
 
-		lychee.api(params, function(data) {
+		if (album.json.public==1) contextMenu.shareAlbum(albumID, e);
 
-			if (data!==true) lychee.error(null, params, data);
+	}
 
-		});
+	lychee.api(params, function(data) {
 
-	},
-
-	share: function(service) {
-
-		var link = "",
-			url = location.href;
-
-		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(album.json.title);
-				break;
-			case 2:
-				link = "mailto:?subject=" + encodeURI(album.json.title) + "&body=" + encodeURI(url);
-				break;
-			default:
-				link = "";
-				break;
-		}
+		if (data!==true) lychee.error(null, params, data);
+
+	});
 
-		if (link.length>5) location.href = link;
+}
 
-	},
+album.share = function(service) {
 
-	getArchive: function(albumID) {
+	var link = '',
+		url = location.href;
 
-		var link,
-			url = "php/api.php?function=getAlbumArchive&albumID=" + albumID;
+	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(album.json.title);
+			break;
+		case 2:
+			link = 'mailto:?subject=' + encodeURI(album.json.title) + '&body=' + encodeURI(url);
+			break;
+		default:
+			link = '';
+			break;
+	}
 
-		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 (link.length>5) location.href = link;
 
-		if (lychee.publicMode) link += "&password=" + password.value;
+}
 
-		location.href = link;
+album.getArchive = function(albumID) {
 
-	}
+	var link,
+		url = 'php/api.php?function=getAlbumArchive&albumID=' + albumID;
+
+	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;
+
+	location.href = link;
 
-};
+}

+ 54 - 56
src/scripts/loadingBar.js

@@ -3,87 +3,85 @@
  * @copyright	2014 by Tobias Reich
  */
 
-loadingBar = {
+loadingBar = {}
 
-	status: null,
+loadingBar.status = null;
 
-	show: function(status, errorText) {
+loadingBar.show = function(status, errorText) {
 
-		if (status==='error') {
+	if (status==='error') {
 
-			// Set status
-			loadingBar.status = 'error';
+		// Set status
+		loadingBar.status = 'error';
 
-			// Parse text
-			if (errorText) errorText = errorText.replace('<br>', '');
-			if (!errorText) errorText = 'Whoops, it looks like something went wrong. Please reload the site and try again!';
+		// Parse text
+		if (errorText)	errorText = errorText.replace('<br>', '');
+		if (!errorText)	errorText = 'Whoops, it looks like something went wrong. Please reload the site and try again!';
 
-			// Move header down
-			if (visible.controls()) lychee.header.addClass('error');
+		// Move header down
+		if (visible.controls()) lychee.header.addClass('error');
 
-			// Modify loading
-			lychee.loadingBar
-				.removeClass('loading uploading error')
-				.addClass(status)
-				.html('<h1>Error: <span>' + errorText + '</span></h1>')
-				.show()
-				.css('height', '40px');
+		// Modify loading
+		lychee.loadingBar
+			.removeClass('loading uploading error')
+			.addClass(status)
+			.html('<h1>Error: <span>' + errorText + '</span></h1>')
+			.show()
+			.css('height', '40px');
 
-			// Set timeout
-			clearTimeout(lychee.loadingBar.data('timeout'));
-			lychee.loadingBar.data('timeout', setTimeout(function() { loadingBar.hide(true) }, 3000));
+		// Set timeout
+		clearTimeout(lychee.loadingBar.data('timeout'));
+		lychee.loadingBar.data('timeout', setTimeout(function() { loadingBar.hide(true) }, 3000));
 
-			return true;
+		return true;
 
-		}
-
-		if (loadingBar.status===null) {
+	}
 
-			// Set status
-			loadingBar.status = 'loading';
+	if (loadingBar.status===null) {
 
-			// Set timeout
-			clearTimeout(lychee.loadingBar.data('timeout'));
-			lychee.loadingBar.data('timeout', setTimeout(function() {
+		// Set status
+		loadingBar.status = 'loading';
 
-				// Move header down
-				if (visible.controls()) lychee.header.addClass('loading');
+		// Set timeout
+		clearTimeout(lychee.loadingBar.data('timeout'));
+		lychee.loadingBar.data('timeout', setTimeout(function() {
 
-				// Modify loading
-				lychee.loadingBar
-					.removeClass('loading uploading error')
-					.addClass('loading')
-					.show();
+			// Move header down
+			if (visible.controls()) lychee.header.addClass('loading');
 
-			}, 1000));
+			// Modify loading
+			lychee.loadingBar
+				.removeClass('loading uploading error')
+				.addClass('loading')
+				.show();
 
-			return true;
+		}, 1000));
 
-		}
+		return true;
 
-	},
+	}
 
-	hide: function(force) {
+}
 
-		if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
+loadingBar.hide = function(force) {
 
-			// Remove status
-			loadingBar.status = null;
+	if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
 
-			// Move header up
-			if (visible.controls()) lychee.header.removeClass('error loading');
+		// Remove status
+		loadingBar.status = null;
 
-			// Modify loading
-			lychee.loadingBar
-				.html('')
-				.css('height', '3px');
+		// Move header up
+		if (visible.controls()) lychee.header.removeClass('error loading');
 
-			// Set timeout
-			clearTimeout(lychee.loadingBar.data('timeout'));
-			setTimeout(function() { lychee.loadingBar.hide() }, 300);
+		// Modify loading
+		lychee.loadingBar
+			.html('')
+			.css('height', '3px');
 
-		}
+		// Set timeout
+		clearTimeout(lychee.loadingBar.data('timeout'));
+		setTimeout(function() { lychee.loadingBar.hide() }, 300);
 
 	}
 
-};
+}

+ 1 - 1
src/scripts/password.js

@@ -54,6 +54,6 @@ password.getDialog = function(albumID, callback) {
 		['Enter', function() { password.get(albumID, callback) }],
 		['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);
 
 }

+ 7 - 3
src/scripts/photo.js

@@ -174,10 +174,14 @@ photo.delete = function(photoIDs) {
 	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;
+
+		// Fallback for photos without a title
 		if (photoTitle==='')	photoTitle = 'Untitled';
+
 	}
 
 	buttons = [
@@ -552,7 +556,7 @@ photo.getSize = function() {
 		scaled		= false,
 		hasMedium	= photo.json.medium!=='',
 		pixelRatio	= window.devicePixelRatio,
-		view = {
+		view		= {
 			width:	$(window).width()-60,
 			height:	$(window).height()-100
 		};
@@ -613,7 +617,7 @@ 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);
+	if (location.href.indexOf('index.html')>0)	return location.href.replace('index.html' + location.hash, url);
+	else										return location.href.replace(location.hash, url);
 
 }

Some files were not shown because too many files changed in this diff