From e610b6fecf5d9fc6cc58c8a2b44cbe2bb37c22fe Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 20 Feb 2011 02:27:43 +0000 Subject: Fixes #2947: User hover menu attached to body and shows regardless of overflow. git-svn-id: http://code.elgg.org/elgg/trunk@8353 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/ui.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'js/lib') diff --git a/js/lib/ui.js b/js/lib/ui.js index f61e2faea..bd2541ec9 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -111,17 +111,31 @@ elgg.ui.initHoverMenu = function(parent) { // avatar contextual menu $(".elgg-avatar > .elgg-icon-hover-menu").live('click', function(e) { + // check if we've attached the menu to this element already + var $hovermenu = $(this).data('hovermenu') || null; - var $hovermenu = $(this).parent().find(".elgg-menu-hover"); + if (!$hovermenu) { + var $hovermenu = $(this).parent().find(".elgg-menu-hover"); + $(this).data('hovermenu', $hovermenu); + } // close hovermenu if arrow is clicked & menu already open if ($hovermenu.css('display') == "block") { $hovermenu.fadeOut(); } else { $avatar = $(this).closest(".elgg-avatar"); - $hovermenu.css("top", ($avatar.height()) + "px") - .css("left", ($avatar.width()-15) + "px") + + var offset = $avatar.offset(); + var top = $avatar.height() + offset.top + 'px'; + var left = $avatar.width() - 15 + offset.left + 'px'; + + $hovermenu.appendTo('body') + .css('position', 'absolute') + .css("top", top) + .css("left", left) .fadeIn('normal'); + hoverIt = $hovermenu; + console.log($hovermenu); } // hide any other open hover menus -- cgit v1.2.3