diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-08-28 13:47:35 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-08-28 13:47:35 -0600 |
commit | f1e008a14f2dfb51d1204dad3deb19e2e3df16c8 (patch) | |
tree | 69606bc130dd484d8c7bccfb3850b57c50b6a5f6 /themes/default/js | |
parent | 94b5749d4604dc0d6b7a057d48a0f9d733e035ea (diff) |
Don't clone hover item, apply styles to the original container. Contextual menu rotates are now immediately visible. Fixes ticket 667.
Diffstat (limited to 'themes/default/js')
-rw-r--r-- | themes/default/js/ui.init.js | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 2391f638..006d74bb 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -62,39 +62,41 @@ $(document).ready(function() { // Initialize context menus $(".gItem").hover( function(){ + // Insert invisible placeholder to hold the item's position in the grid + var placeHolder = $(this).clone(); + $(placeHolder).attr("id", "gPlaceHolder"); + $(placeHolder).css("visibility", "hidden"); + $(this).after($(placeHolder)); + // Style and position the item + $(this).addClass("gHoverItem"); var position = $(this).position(); - var item_classes = $(this).attr("class"); - var bg_color = $(this).css("background-color"); - var container = $(this).parent(); - $("#gHoverItem").remove(); - container.append("<div id=\"gHoverItem\"><div class=\"" + item_classes + "\">" - + $(this).html() + "</div></div>"); - $("#gHoverItem").css("top", position.top); - $("#gHoverItem").css("left", position.left); - $("#gHoverItem").css("background-color", bg_color); - $.fn.gallery_hover_init(); - var v_align = $(this).find(".gValign"); + $(this).css("position", "absolute"); + $(this).css("top", position.top); + $(this).css("left", position.left); + $(this).css("z-index", "1000"); + // Initialize the contextual menu + $(this).gallery_context_menu(); + // Set height based on height of descendents var title = $(this).find("h2"); var meta = $(this).find(".gMetadata"); - var context = $(this).find(".gContextMenu"); var context_label = $(this).find(".gContextMenu li:first"); - $("#gHoverItem .gItem").height( - $(v_align).gallery_height() - + $(title).gallery_height() - + $(meta).gallery_height() - + parseInt($(context).css("margin-top").replace("px","")) - + $(context_label).gallery_height() - ); - - $("#gHoverItem").fadeIn("fast"); - $("#gHoverItem").hover( - function(){ - $(this).gallery_context_menu(); - }, - function() { - $(this).hide(); - } - ); + var item_ht = $(this).height(); + var title_ht = $(title).gallery_height(); + var meta_ht = $(meta).gallery_height(); + var context_label_ht = $(context_label).gallery_height(); + $(this).height(item_ht + title_ht + meta_ht + context_label_ht); + }, + function() { + // Reset item height, position, and z-index + var sib_height = $(this).next().height(); + $(this).css("height", sib_height); + $(this).css("position", "relative"); + $(this).css("top", null); + $(this).css("left", null); + $(this).css("z-index", null); + // Remove the placeholder and hover class from the item + $("#gPlaceHolder").remove(); + $(this).removeClass("gHoverItem"); } ); } |