From 32878ebfdce943271824891639ab0384053bbadd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Sep 2010 21:04:18 -0700 Subject: Replace the hook function hack I introduced in cbba45fffc7368280e9529f55e108d0080175b6a with a namespaced jQuery custom event. This is way more portable. --- lib/gallery.common.js | 8 +++----- themes/wind/views/photo.html.php | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 69452f39..9fccc602 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -119,11 +119,9 @@ }; // Ajax handler for replacing an image, used in Ajax thumbnail rotation - $.gallery_replace_image = function(data, thumb) { - $(thumb).attr({src: data.src, width: data.width, height: data.height}); - if (typeof gallery_image_replaced_hook == 'function') { - gallery_image_replaced_hook(data, thumb); - } + $.gallery_replace_image = function(data, img_selector) { + $(img_selector).attr({src: data.src, width: data.width, height: data.height}); + $(img_selector).trigger("gallery.change"); }; // Initialize context menus diff --git a/themes/wind/views/photo.html.php b/themes/wind/views/photo.html.php index cb830e23..b42ab987 100644 --- a/themes/wind/views/photo.html.php +++ b/themes/wind/views/photo.html.php @@ -12,7 +12,7 @@ // After the image is rotated or replaced we have to reload the image dimensions // so that the full size view isn't distorted. - gallery_image_replaced_hook = function(data, thumb) { + $("#g-photo").bind("gallery.change", function() { $.ajax({ url: "item()->id) ?>", dataType: "json", @@ -20,7 +20,7 @@ full_dims = data.full; } }); - } + }); }); -- cgit v1.2.3