diff options
author | Nathan Kinkade <nath@nkinka.de> | 2013-03-19 16:41:42 +0000 |
---|---|---|
committer | Nathan Kinkade <nath@nkinka.de> | 2013-03-19 16:41:42 +0000 |
commit | 3908e37d965fa76ea774e76ddf42365a872a5f27 (patch) | |
tree | 457e1a1e465f83855eee96ba287cd91f1623395c /themes/wind/js/ui.init.js | |
parent | 711651f727e093cc7357a6bbff6bd992fd6dfd80 (diff) | |
parent | 1eab94f6062b5f54ea5d9db01d968e7195f3de9d (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'themes/wind/js/ui.init.js')
-rw-r--r-- | themes/wind/js/ui.init.js | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js index 3ee3e32e..4f901778 100644 --- a/themes/wind/js/ui.init.js +++ b/themes/wind/js/ui.init.js @@ -49,56 +49,43 @@ $(document).ready(function() { // Album and search results views if ($("#g-album-grid").length) { // Set equal height for album items and vertically align thumbnails/metadata - $('.g-item').equal_heights().gallery_valign(); + $(".g-item").equal_heights().gallery_valign(); + // Store the resulting item height. Storing this here for the whole grid as opposed to in the + // hover event as an attr for each item is more efficient and ensures IE6-8 compatibility. + var item_height = $(".g-item").height(); // Initialize thumbnail hover effect $(".g-item").hover( function() { // Insert a placeholder to hold the item's position in the grid - var placeHolder = $(this).clone().attr("id", "g-place-holder"); - $(this).after($(placeHolder)); + var place_holder = $(this).clone().attr("id", "g-place-holder"); + $(this).after($(place_holder)); // Style and position the hover item var position = $(this).position(); $(this).css("top", position.top).css("left", position.left); $(this).addClass("g-hover-item"); - // Initialize the contextual menu + // Initialize the contextual menu. Note that putting it here delays execution until needed. $(this).gallery_context_menu(); - // Set the hover item's height + // Set the hover item's height. Use "li a" on the context menu so we get the height of the + // collapsed menu and avoid problems with incomplete slideUp/Down animations. $(this).height("auto"); - var context_menu = $(this).find(".g-context-menu"); - var adj_height = $(this).height() + context_menu.height(); - if ($(this).next().height() > $(this).height()) { - $(this).height($(this).next().height()); - } else if ($(this).prev().height() > $(this).height()) { - $(this).height($(this).prev().height()); - } else { - $(this).height(adj_height); - } + $(this).height(Math.max($(this).height(), item_height) + + $(this).find(".g-context-menu li a").height()); }, function() { // Reset item height and position - if ($(this).next().height()) { - var sib_height = $(this).next().height(); - } else { - var sib_height = $(this).prev().height(); - } - if ($.browser.msie && $.browser.version <= 8) { - sib_height = sib_height + 1; - } - $(this).css("height", sib_height); - $(this).css("position", "relative"); - $(this).css("top", 0).css("left", 0); + $(this).height(item_height); + $(this).css("top", "").css("left", ""); // Remove the placeholder and hover class from the item $(this).removeClass("g-hover-item"); - $(this).gallery_valign(); $("#g-place-holder").remove(); } ); // Realign any thumbnails that change so that when we rotate a thumb it stays centered. - $(".g-item").bind("gallery.change", function() { + $(".g-item").on("gallery.change", function() { $(".g-item").each(function() { - $(this).height($(this).find("img").height() + 2); + $(this).height($(this).find("img").height() + 2); }); $(".g-item").equal_heights().gallery_valign(); }); |