Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bharat committed Sep 11, 2010
1 parent 304dd9c commit b35886c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/gallery.common.js
Expand Up @@ -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; });
}
);
}
Expand Down

0 comments on commit b35886c

Please sign in to comment.