From 2f4c4a3f706d98be7dd41f8fa7c9124314c515c8 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 9 Aug 2009 11:31:31 -0600 Subject: Rename resizeImage gallery_fit_image to follow convention. Move the function to gallery.common.js. --- lib/gallery.common.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/gallery.common.js') diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 7e6acad9..08656a83 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -12,7 +12,7 @@ if (container == null) { container = 'div'; } - $(this).html("<" + container + ">" + $(this).html() + ""); + $(this).html("<" + container + " class=\"gValign\">" + $(this).html() + ""); var el = $(this).children(container + ":first"); var elh = $(el).height(); var ph = $(this).height(); @@ -52,4 +52,23 @@ $(this).toggleClass("gLoading" + size); }); }; + + /** + * Reduce the width of an image if it's wider than its parent container + * @param elementID The image's container + */ + $.fn.gallery_fit_image = function() { + var photo = $(this).find("img").filter(function() { + return this.id.match(/gPhotoId-\d+/); + }); + var cont_width = $(this).width(); + var photo_width = photo.width(); + if (cont_width < photo_width) { + var proportion = cont_width / photo_width; + photo.width(cont_width); + photo.height(proportion * photo.height()); + } + }; + })(jQuery); + -- cgit v1.2.3