Pass jshint.
This commit is contained in:
parent
264738009b
commit
7566bce879
@ -29,80 +29,86 @@ $(document).ready(function() {
|
|||||||
var photoFloat = new PhotoFloat();
|
var photoFloat = new PhotoFloat();
|
||||||
|
|
||||||
|
|
||||||
/* Entry point for most events */
|
|
||||||
|
|
||||||
function hashParsed(album, photo, photoIndex) {
|
|
||||||
undie();
|
|
||||||
$("#loading").hide();
|
|
||||||
if (album == currentAlbum && photo == currentPhoto)
|
|
||||||
return;
|
|
||||||
previousAlbum = currentAlbum;
|
|
||||||
previousPhoto = currentPhoto;
|
|
||||||
currentAlbum = album;
|
|
||||||
currentPhoto = photo;
|
|
||||||
currentPhotoIndex = photoIndex;
|
|
||||||
setTitle();
|
|
||||||
showAlbum(previousAlbum != currentAlbum);
|
|
||||||
if (photo != null)
|
|
||||||
showPhoto();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Displays */
|
/* Displays */
|
||||||
|
|
||||||
function setTitle() {
|
function setTitle() {
|
||||||
var title = "";
|
var title = "", documentTitle = "", last = "", components, i;
|
||||||
var documentTitle = "";
|
if (!currentAlbum.path.length)
|
||||||
var components;
|
|
||||||
if (currentAlbum.path.length == 0)
|
|
||||||
components = [originalTitle];
|
components = [originalTitle];
|
||||||
else {
|
else {
|
||||||
components = currentAlbum.path.split("/");
|
components = currentAlbum.path.split("/");
|
||||||
components.unshift(originalTitle);
|
components.unshift(originalTitle);
|
||||||
}
|
}
|
||||||
if (currentPhoto != null)
|
if (currentPhoto !== null)
|
||||||
documentTitle += photoFloat.trimExtension(currentPhoto.name);
|
documentTitle += photoFloat.trimExtension(currentPhoto.name);
|
||||||
var last = "";
|
for (i = 0; i < components.length; ++i) {
|
||||||
for (var i = 0; i < components.length; ++i) {
|
if (i || currentPhoto !== null)
|
||||||
if (i || currentPhoto != null)
|
|
||||||
documentTitle += " \u00ab ";
|
documentTitle += " \u00ab ";
|
||||||
if (i)
|
if (i)
|
||||||
last += "/" + components[i];
|
last += "/" + components[i];
|
||||||
if (i < components.length - 1 || currentPhoto != null)
|
if (i < components.length - 1 || currentPhoto !== null)
|
||||||
title += "<a href=\"#!/" + (i == 0 ? "" : photoFloat.cachePath(last.substring(1))) + "\">";
|
title += "<a href=\"#!/" + (i ? photoFloat.cachePath(last.substring(1)) : "") + "\">";
|
||||||
title += components[i];
|
title += components[i];
|
||||||
documentTitle += components[components.length - 1 - i];
|
documentTitle += components[components.length - 1 - i];
|
||||||
if (i < components.length - 1 || currentPhoto != null) {
|
if (i < components.length - 1 || currentPhoto !== null) {
|
||||||
title += "</a>";
|
title += "</a>";
|
||||||
title += " » ";
|
title += " » ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentPhoto != null)
|
if (currentPhoto !== null)
|
||||||
title += photoFloat.trimExtension(currentPhoto.name);
|
title += photoFloat.trimExtension(currentPhoto.name);
|
||||||
$("#title").html(title);
|
$("#title").html(title);
|
||||||
document.title = documentTitle;
|
document.title = documentTitle;
|
||||||
}
|
}
|
||||||
|
function scrollToThumb() {
|
||||||
|
var photo, thumb;
|
||||||
|
photo = currentPhoto;
|
||||||
|
if (photo === null) {
|
||||||
|
photo = previousPhoto;
|
||||||
|
if (photo === null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$("#thumbs img").each(function() {
|
||||||
|
if (this.photo === photo) {
|
||||||
|
thumb = $(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (typeof thumb === "undefined")
|
||||||
|
return;
|
||||||
|
if (currentPhoto !== null) {
|
||||||
|
var scroller = $("#album-view");
|
||||||
|
scroller.stop().animate({ scrollLeft: thumb.position().left + scroller.scrollLeft() - scroller.width() / 2 + thumb.width() / 2 }, "slow");
|
||||||
|
} else
|
||||||
|
$("html, body").stop().animate({ scrollTop: thumb.offset().top - $(window).height() / 2 + thumb.height() }, "slow");
|
||||||
|
|
||||||
|
if (currentPhoto !== null) {
|
||||||
|
$("#thumbs img").removeClass("current-thumb");
|
||||||
|
thumb.addClass("current-thumb");
|
||||||
|
}
|
||||||
|
}
|
||||||
function showAlbum(populate) {
|
function showAlbum(populate) {
|
||||||
if (currentPhoto == null && previousPhoto == null)
|
var i, link, image, photos, thumbsElement, subalbums, subalbumsElement;
|
||||||
|
if (currentPhoto === null && previousPhoto === null)
|
||||||
$("html, body").stop().animate({ scrollTop: 0 }, "slow");
|
$("html, body").stop().animate({ scrollTop: 0 }, "slow");
|
||||||
|
|
||||||
if (populate) {
|
if (populate) {
|
||||||
var photos = [];
|
photos = [];
|
||||||
for (var i = 0; i < currentAlbum.photos.length; ++i) {
|
for (i = 0; i < currentAlbum.photos.length; ++i) {
|
||||||
var link = $("<a href=\"#!/" + photoFloat.photoHash(currentAlbum, currentAlbum.photos[i]) + "\"></a>");
|
link = $("<a href=\"#!/" + photoFloat.photoHash(currentAlbum, currentAlbum.photos[i]) + "\"></a>");
|
||||||
var image = $("<img title=\"" + photoFloat.trimExtension(currentAlbum.photos[i].name) + "\" alt=\"" + photoFloat.trimExtension(currentAlbum.photos[i].name) + "\" src=\"" + photoFloat.photoPath(currentAlbum, currentAlbum.photos[i], 150, true) + "\" height=\"150\" width=\"150\" />");
|
image = $("<img title=\"" + photoFloat.trimExtension(currentAlbum.photos[i].name) + "\" alt=\"" + photoFloat.trimExtension(currentAlbum.photos[i].name) + "\" src=\"" + photoFloat.photoPath(currentAlbum, currentAlbum.photos[i], 150, true) + "\" height=\"150\" width=\"150\" />");
|
||||||
link.append(image);
|
link.append(image);
|
||||||
image.get(0).photo = currentAlbum.photos[i];
|
image.get(0).photo = currentAlbum.photos[i];
|
||||||
photos.push(link);
|
photos.push(link);
|
||||||
}
|
}
|
||||||
var thumbsElement = $("#thumbs");
|
thumbsElement = $("#thumbs");
|
||||||
thumbsElement.empty();
|
thumbsElement.empty();
|
||||||
thumbsElement.append.apply(thumbsElement, photos);
|
thumbsElement.append.apply(thumbsElement, photos);
|
||||||
|
|
||||||
var subalbums = [];
|
subalbums = [];
|
||||||
for (var i = currentAlbum.albums.length - 1; i >= 0; --i) {
|
for (i = currentAlbum.albums.length - 1; i >= 0; --i) {
|
||||||
var link = $("<a href=\"#!/" + photoFloat.albumHash(currentAlbum.albums[i]) + "\"></a>");
|
link = $("<a href=\"#!/" + photoFloat.albumHash(currentAlbum.albums[i]) + "\"></a>");
|
||||||
var image = $("<div title=\"" + currentAlbum.albums[i].date + "\" class=\"album-button\">" + currentAlbum.albums[i].path + "</div>");
|
image = $("<div title=\"" + currentAlbum.albums[i].date + "\" class=\"album-button\">" + currentAlbum.albums[i].path + "</div>");
|
||||||
link.append(image);
|
link.append(image);
|
||||||
subalbums.push(link);
|
subalbums.push(link);
|
||||||
(function(theAlbum, theImage) {
|
(function(theAlbum, theImage) {
|
||||||
@ -111,12 +117,12 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
})(currentAlbum.albums[i], image);
|
})(currentAlbum.albums[i], image);
|
||||||
}
|
}
|
||||||
var subalbumsElement = $("#subalbums");
|
subalbumsElement = $("#subalbums");
|
||||||
subalbumsElement.empty();
|
subalbumsElement.empty();
|
||||||
subalbumsElement.append.apply(subalbumsElement, subalbums);
|
subalbumsElement.append.apply(subalbumsElement, subalbums);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPhoto == null) {
|
if (currentPhoto === null) {
|
||||||
$("#thumbs img").removeClass("current-thumb");
|
$("#thumbs img").removeClass("current-thumb");
|
||||||
$("#album-view").removeClass("photo-view-container");
|
$("#album-view").removeClass("photo-view-container");
|
||||||
$("#subalbums").show();
|
$("#subalbums").show();
|
||||||
@ -130,19 +136,21 @@ $(document).ready(function() {
|
|||||||
return (fraction[0] / fraction[1]).toString();
|
return (fraction[0] / fraction[1]).toString();
|
||||||
}
|
}
|
||||||
function scaleImage() {
|
function scaleImage() {
|
||||||
var image = $("#photo");
|
var image, container;
|
||||||
if (image.get(0) == this)
|
image = $("#photo");
|
||||||
|
if (image.get(0) === this)
|
||||||
$(window).bind("resize", scaleImage);
|
$(window).bind("resize", scaleImage);
|
||||||
var container = $("#photo-view");
|
container = $("#photo-view");
|
||||||
if (image.css("width") != "100%" && container.height() * image.width() / image.height() > container.width())
|
if (image.css("width") !== "100%" && container.height() * image.width() / image.height() > container.width())
|
||||||
image.css("width", "100%").css("height", "auto").css("position", "absolute").css("bottom", 0);
|
image.css("width", "100%").css("height", "auto").css("position", "absolute").css("bottom", 0);
|
||||||
else if (image.css("height") != "100%")
|
else if (image.css("height") !== "100%")
|
||||||
image.css("height", "100%").css("width", "auto").css("position", "").css("bottom", "");
|
image.css("height", "100%").css("width", "auto").css("position", "").css("bottom", "");
|
||||||
}
|
}
|
||||||
function showPhoto() {
|
function showPhoto() {
|
||||||
var maxSize = 800;
|
var maxSize, width, height, photoSrc, previousPhoto, nextPhoto, nextLink, text;
|
||||||
var width = currentPhoto.size[0];
|
maxSize = 800;
|
||||||
var height = currentPhoto.size[1];
|
width = currentPhoto.size[0];
|
||||||
|
height = currentPhoto.size[1];
|
||||||
if (width > height) {
|
if (width > height) {
|
||||||
height = height / width * maxSize;
|
height = height / width * maxSize;
|
||||||
width = maxSize;
|
width = maxSize;
|
||||||
@ -151,7 +159,7 @@ $(document).ready(function() {
|
|||||||
height = maxSize;
|
height = maxSize;
|
||||||
}
|
}
|
||||||
$(window).unbind("resize", scaleImage);
|
$(window).unbind("resize", scaleImage);
|
||||||
var photoSrc = photoFloat.photoPath(currentAlbum, currentPhoto, maxSize, false);
|
photoSrc = photoFloat.photoPath(currentAlbum, currentPhoto, maxSize, false);
|
||||||
$("#photo")
|
$("#photo")
|
||||||
.attr("width", width).attr("height", height)
|
.attr("width", width).attr("height", height)
|
||||||
.attr("src", photoSrc)
|
.attr("src", photoSrc)
|
||||||
@ -160,34 +168,34 @@ $(document).ready(function() {
|
|||||||
.load(scaleImage);
|
.load(scaleImage);
|
||||||
$("head").append("<link rel=\"image_src\" href=\"" + photoSrc + "\" />");
|
$("head").append("<link rel=\"image_src\" href=\"" + photoSrc + "\" />");
|
||||||
|
|
||||||
var previousPhoto = currentAlbum.photos[
|
previousPhoto = currentAlbum.photos[
|
||||||
(currentPhotoIndex - 1 < 0) ? (currentAlbum.photos.length - 1) : (currentPhotoIndex - 1)
|
(currentPhotoIndex - 1 < 0) ? (currentAlbum.photos.length - 1) : (currentPhotoIndex - 1)
|
||||||
];
|
];
|
||||||
var nextPhoto = currentAlbum.photos[
|
nextPhoto = currentAlbum.photos[
|
||||||
(currentPhotoIndex + 1 >= currentAlbum.photos.length) ? 0 : (currentPhotoIndex + 1)
|
(currentPhotoIndex + 1 >= currentAlbum.photos.length) ? 0 : (currentPhotoIndex + 1)
|
||||||
];
|
];
|
||||||
$.preloadImages(photoFloat.photoPath(currentAlbum, nextPhoto, maxSize, false), photoFloat.photoPath(currentAlbum, previousPhoto, maxSize, false));
|
$.preloadImages(photoFloat.photoPath(currentAlbum, nextPhoto, maxSize, false), photoFloat.photoPath(currentAlbum, previousPhoto, maxSize, false));
|
||||||
|
|
||||||
var nextLink = "#!/" + photoFloat.photoHash(currentAlbum, nextPhoto);
|
nextLink = "#!/" + photoFloat.photoHash(currentAlbum, nextPhoto);
|
||||||
$("#next-photo").attr("href", nextLink);
|
$("#next-photo").attr("href", nextLink);
|
||||||
$("#next").attr("href", nextLink);
|
$("#next").attr("href", nextLink);
|
||||||
$("#back").attr("href", "#!/" + photoFloat.photoHash(currentAlbum, previousPhoto));
|
$("#back").attr("href", "#!/" + photoFloat.photoHash(currentAlbum, previousPhoto));
|
||||||
$("#original-link").attr("target", "_blank").attr("href", photoFloat.originalPhotoPath(currentAlbum, currentPhoto));
|
$("#original-link").attr("target", "_blank").attr("href", photoFloat.originalPhotoPath(currentAlbum, currentPhoto));
|
||||||
|
|
||||||
var text = "<table>";
|
text = "<table>";
|
||||||
if (currentPhoto.make != undefined) text += "<tr><td>Camera Maker</td><td>" + currentPhoto.make + "</td></tr>";
|
if (typeof currentPhoto.make !== "undefined") text += "<tr><td>Camera Maker</td><td>" + currentPhoto.make + "</td></tr>";
|
||||||
if (currentPhoto.model != undefined) text += "<tr><td>Camera Model</td><td>" + currentPhoto.model + "</td></tr>";
|
if (typeof currentPhoto.model !== "undefined") text += "<tr><td>Camera Model</td><td>" + currentPhoto.model + "</td></tr>";
|
||||||
if (currentPhoto.date != undefined) text += "<tr><td>Time Taken</td><td>" + currentPhoto.date + "</td></tr>";
|
if (typeof currentPhoto.date !== "undefined") text += "<tr><td>Time Taken</td><td>" + currentPhoto.date + "</td></tr>";
|
||||||
if (currentPhoto.size != undefined) text += "<tr><td>Resolution</td><td>" + currentPhoto.size[0] + " x " + currentPhoto.size[1] + "</td></tr>";
|
if (typeof currentPhoto.size !== "undefined") text += "<tr><td>Resolution</td><td>" + currentPhoto.size[0] + " x " + currentPhoto.size[1] + "</td></tr>";
|
||||||
if (currentPhoto.aperture != undefined) text += "<tr><td>Aperture</td><td> f/" + getDecimal(currentPhoto.aperture) + "</td></tr>";
|
if (typeof currentPhoto.aperture !== "undefined") text += "<tr><td>Aperture</td><td> f/" + getDecimal(currentPhoto.aperture) + "</td></tr>";
|
||||||
if (currentPhoto.focalLength != undefined) text += "<tr><td>Focal Length</td><td>" + getDecimal(currentPhoto.focalLength) + " mm</td></tr>";
|
if (typeof currentPhoto.focalLength !== "undefined") text += "<tr><td>Focal Length</td><td>" + getDecimal(currentPhoto.focalLength) + " mm</td></tr>";
|
||||||
if (currentPhoto.iso != undefined) text += "<tr><td>ISO</td><td>" + currentPhoto.iso + "</td></tr>";
|
if (typeof currentPhoto.iso !== "undefined") text += "<tr><td>ISO</td><td>" + currentPhoto.iso + "</td></tr>";
|
||||||
if (currentPhoto.exposureTime != undefined) text += "<tr><td>Exposure Time</td><td>" + getDecimal(currentPhoto.exposureTime) + " sec</td></tr>";
|
if (typeof currentPhoto.exposureTime !== "undefined") text += "<tr><td>Exposure Time</td><td>" + getDecimal(currentPhoto.exposureTime) + " sec</td></tr>";
|
||||||
if (currentPhoto.exposureProgram != undefined) text += "<tr><td>Exposure Program</td><td>" + currentPhoto.exposureProgram + "</td></tr>";
|
if (typeof currentPhoto.exposureProgram !== "undefined") text += "<tr><td>Exposure Program</td><td>" + currentPhoto.exposureProgram + "</td></tr>";
|
||||||
if (currentPhoto.exposureCompensation != undefined) text += "<tr><td>Exposure Compensation</td><td>" + getDecimal(currentPhoto.exposureCompensation) + "</td></tr>";
|
if (typeof currentPhoto.exposureCompensation !== "undefined") text += "<tr><td>Exposure Compensation</td><td>" + getDecimal(currentPhoto.exposureCompensation) + "</td></tr>";
|
||||||
if (currentPhoto.spectralSensitivity != undefined) text += "<tr><td>Spectral Sensitivity</td><td>" + currentPhoto.spectralSensitivity + "</td></tr>";
|
if (typeof currentPhoto.spectralSensitivity !== "undefined") text += "<tr><td>Spectral Sensitivity</td><td>" + currentPhoto.spectralSensitivity + "</td></tr>";
|
||||||
if (currentPhoto.flash != undefined) text += "<tr><td>Flash</td><td>" + currentPhoto.flash + "</td></tr>";
|
if (typeof currentPhoto.flash !== "undefined") text += "<tr><td>Flash</td><td>" + currentPhoto.flash + "</td></tr>";
|
||||||
if (currentPhoto.orientation != undefined) text += "<tr><td>Orientation</td><td>" + currentPhoto.orientation + "</td></tr>";
|
if (typeof currentPhoto.orientation !== "undefined") text += "<tr><td>Orientation</td><td>" + currentPhoto.orientation + "</td></tr>";
|
||||||
text += "</table>";
|
text += "</table>";
|
||||||
$("#metadata").html(text);
|
$("#metadata").html(text);
|
||||||
|
|
||||||
@ -195,33 +203,6 @@ $(document).ready(function() {
|
|||||||
$("#subalbums").hide();
|
$("#subalbums").hide();
|
||||||
$("#photo-view").show();
|
$("#photo-view").show();
|
||||||
}
|
}
|
||||||
function scrollToThumb() {
|
|
||||||
var photo = currentPhoto
|
|
||||||
if (photo == null) {
|
|
||||||
photo = previousPhoto;
|
|
||||||
if (photo == null)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var thumb;
|
|
||||||
$("#thumbs img").each(function() {
|
|
||||||
if (this.photo == photo) {
|
|
||||||
thumb = $(this);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (typeof thumb === "undefined")
|
|
||||||
return;
|
|
||||||
if (currentPhoto != null) {
|
|
||||||
var scroller = $("#album-view");
|
|
||||||
scroller.stop().animate({ scrollLeft: thumb.position().left + scroller.scrollLeft() - scroller.width() / 2 + thumb.width() / 2 }, "slow");
|
|
||||||
} else
|
|
||||||
$("html, body").stop().animate({ scrollTop: thumb.offset().top - $(window).height() / 2 + thumb.height() }, "slow");
|
|
||||||
|
|
||||||
if (currentPhoto != null) {
|
|
||||||
$("#thumbs img").removeClass("current-thumb");
|
|
||||||
thumb.addClass("current-thumb");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Error displays */
|
/* Error displays */
|
||||||
@ -235,7 +216,26 @@ $(document).ready(function() {
|
|||||||
$("#error-text, #error-overlay").fadeOut(500);
|
$("#error-text, #error-overlay").fadeOut(500);
|
||||||
$("body, html").css("overflow", "auto");
|
$("body, html").css("overflow", "auto");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Entry point for most events */
|
||||||
|
|
||||||
|
function hashParsed(album, photo, photoIndex) {
|
||||||
|
undie();
|
||||||
|
$("#loading").hide();
|
||||||
|
if (album === currentAlbum && photo === currentPhoto)
|
||||||
|
return;
|
||||||
|
previousAlbum = currentAlbum;
|
||||||
|
previousPhoto = currentPhoto;
|
||||||
|
currentAlbum = album;
|
||||||
|
currentPhoto = photo;
|
||||||
|
currentPhotoIndex = photoIndex;
|
||||||
|
setTitle();
|
||||||
|
showAlbum(previousAlbum !== currentAlbum);
|
||||||
|
if (photo !== null)
|
||||||
|
showPhoto();
|
||||||
|
}
|
||||||
|
|
||||||
/* Event listeners */
|
/* Event listeners */
|
||||||
|
|
||||||
@ -246,19 +246,19 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
$(window).hashchange();
|
$(window).hashchange();
|
||||||
$(document).keydown(function(e){
|
$(document).keydown(function(e){
|
||||||
if (currentPhoto == null)
|
if (currentPhoto === null)
|
||||||
return true;
|
return true;
|
||||||
if (e.keyCode == 39) {
|
if (e.keyCode === 39) {
|
||||||
window.location.href = $("#next").attr("href");
|
window.location.href = $("#next").attr("href");
|
||||||
return false;
|
return false;
|
||||||
} else if (e.keyCode == 37) {
|
} else if (e.keyCode === 37) {
|
||||||
window.location.href = $("#back").attr("href");
|
window.location.href = $("#back").attr("href");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
$(document).mousewheel(function(event, delta) {
|
$(document).mousewheel(function(event, delta) {
|
||||||
if (currentPhoto == null)
|
if (currentPhoto === null)
|
||||||
return true;
|
return true;
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
window.location.href = $("#next").attr("href");
|
window.location.href = $("#next").attr("href");
|
||||||
|
Loading…
Reference in New Issue
Block a user