summaryrefslogtreecommitdiff
path: root/lib/gallery.common.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gallery.common.js')
-rw-r--r--lib/gallery.common.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js
index 69452f39..2dbd7c7c 100644
--- a/lib/gallery.common.js
+++ b/lib/gallery.common.js
@@ -24,8 +24,12 @@
if (container == null) {
container = 'div';
}
- $(this).html("<" + container + " class=\"g-valign\">" + $(this).html() + "</" + container + ">");
- var el = $(this).children(container + ".g-valign");
+ var el = $(this).find(".g-valign");
+ if (!el.length) {
+ $(this).html("<" + container + " class=\"g-valign\">" + $(this).html() +
+ "</" + container + ">");
+ el = $(this).children(container + ".g-valign");
+ }
var elh = $(el).height();
var ph = $(this).height();
var nh = (ph - elh) / 2;
@@ -119,32 +123,32 @@
};
// 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
$.fn.gallery_context_menu = function() {
if ($(".g-context-menu li").length) {
- var hover_target = ".g-context-menu";
- var in_progress = 0;
- $(hover_target + " *").removeAttr('title');
- $(hover_target + " ul").hide();
- $(hover_target).hover(
+ var hover_target = $(this).find(".g-context-menu");
+ if (hover_target.attr("context_menu_initialized")) {
+ return;
+ }
+ var list = $(hover_target).find("ul");
+ hover_target.find("*").removeAttr('title');
+ list.hide();
+ hover_target.hover(
function() {
- if (in_progress == 0) {
- $(this).find("ul").slideDown("fast", function() { in_progress = 1; });
- $(this).find(".g-dialog-link").gallery_dialog();
- $(this).find(".g-ajax-link").gallery_ajax();
- }
+ list.stop(true, true).slideDown("fast");
+ $(this).find(".g-dialog-link").gallery_dialog();
+ $(this).find(".g-ajax-link").gallery_ajax();
},
function() {
- $(this).find("ul").slideUp("slow", function() { in_progress = 0; });
+ list.stop(true, true).slideUp("slow");
}
);
+ hover_target.attr("context_menu_initialized", 1);
}
};