aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2011-05-09 04:11:31 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2011-05-09 04:11:31 -0400
commit4a7d7ad39f9171c449a60ebff1804ac55266c59f (patch)
tree96840b9351e8d49e9685f8b3256fce53343b5a67
parentChiller arrows. (diff)
downloadPhotoFloat-4a7d7ad39f9171c449a60ebff1804ac55266c59f.tar.xz
PhotoFloat-4a7d7ad39f9171c449a60ebff1804ac55266c59f.zip
Take out scaling function to its own.
-rw-r--r--web/js/010-control.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/web/js/010-control.js b/web/js/010-control.js
index 3fe70f8..ea9550e 100644
--- a/web/js/010-control.js
+++ b/web/js/010-control.js
@@ -128,6 +128,16 @@ $(document).ready(function() {
return fraction[0] + "/" + fraction[1];
return (fraction[0] / fraction[1]).toString();
}
+ function scaleImage() {
+ var image = $("#photo");
+ if (image.get(0) == this)
+ $(window).bind("resize", scaleImage);
+ var container = $("#photo-view");
+ if (image.css("width") != "100%" && container.height() * image.width() / image.height() > container.width())
+ image.css("width", "100%").css("height", "auto");
+ else if (image.css("height") != "100%")
+ image.css("height", "100%").css("width", "auto");
+ }
function showPhoto() {
currentPhoto();
if (current_photo == null) {
@@ -144,12 +154,13 @@ $(document).ready(function() {
width = width / height * maxSize;
height = maxSize;
}
+ $(window).unbind("resize", scaleImage);
$("#photo")
.attr("width", width).attr("height", height)
.attr("src", imagePath(current_photo.name, current_album.path, maxSize, false))
.attr("alt", current_photo.name)
.attr("title", current_photo.date)
- .load(function() { $(this).css("width", "auto").css("height", "100%"); });
+ .load(scaleImage);
var previousPhoto = current_album.photos[
(current_photo_index - 1 < 0) ? (current_album.photos.length - 1) : (current_photo_index - 1)