From b35886c0fc6f2d37ee1974a35b0cad50e6729757 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Sep 2010 00:08:38 -0700 Subject: Refactor $.fn.gallery_context_menu() to store some variables instead of using CSS selector lookups for every operation. I assume (but have not verified) that this is more efficient. --- lib/gallery.common.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 548b2e7c..81e26e1b 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -131,20 +131,21 @@ // Initialize context menus $.fn.gallery_context_menu = function() { if ($(".g-context-menu li").length) { - var hover_target = ".g-context-menu"; + var hover_target = $(this).find(".g-context-menu"); + var list = $(hover_target).find("ul"); var in_progress = 0; - $(hover_target + " *").removeAttr('title'); - $(hover_target + " ul").hide(); - $(hover_target).hover( + hover_target.find("*").removeAttr('title'); + list.hide(); + hover_target.hover( function() { if (in_progress == 0) { - $(this).find("ul").slideDown("fast", function() { in_progress = 1; }); + list.slideDown("fast", function() { in_progress = 1; }); $(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.slideUp("slow", function() { in_progress = 0; }); } ); } -- cgit v1.2.3