diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-05 15:45:43 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-05 15:45:43 +0000 |
commit | 54b01954f02adbb17df1cf44e2b215ddfb54b587 (patch) | |
tree | 28589721a552551df1dcf1bd4efe4c0fd14af80e /js | |
parent | ea3951a035e38e96435db20f820c9da566ed373b (diff) | |
download | elgg-54b01954f02adbb17df1cf44e2b215ddfb54b587.tar.gz elgg-54b01954f02adbb17df1cf44e2b215ddfb54b587.tar.bz2 |
cleaned up hover menu
git-svn-id: http://code.elgg.org/elgg/trunk@8027 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'js')
-rw-r--r-- | js/lib/ui.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/lib/ui.js b/js/lib/ui.js index 9a2f892f3..bf918cbf4 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -1,6 +1,9 @@ elgg.provide('elgg.ui'); elgg.ui.init = function () { + + elgg.ui.initHoverMenu(); + //if the user clicks a system message, make it disappear $('.elgg-system-messages li').live('click', function() { $(this).stop().fadeOut('fast'); @@ -79,4 +82,51 @@ elgg.ui.toggleLikes = function(event) { event.preventDefault(); } +/** + * Initialize the hover menu + * + * @param {Object} parent + * @return void + */ +elgg.ui.initHoverMenu = function(parent) { + if (!parent) { + parent = document; + } + + // avatar image menu link + $(parent).find(".elgg-user-icon").mouseover(function() { + $(this).children(".elgg-icon-hover-menu").show(); + }) + .mouseout(function() { + $(this).children(".elgg-icon-hover-menu").hide(); + }); + + + // avatar contextual menu + $(".elgg-user-icon > .elgg-icon-hover-menu").click(function(e) { + + var $hovermenu = $(this).parent().find(".elgg-hover-menu"); + + // close hovermenu if arrow is clicked & menu already open + if ($hovermenu.css('display') == "block") { + $hovermenu.fadeOut(); + } else { + $avatar = $(this).closest(".elgg-user-icon"); + $hovermenu.css("top", ($avatar.height()) + "px") + .css("left", ($avatar.width()-15) + "px") + .fadeIn('normal'); + } + + // hide any other open hover menus + $(".elgg-hover-menu:visible").not($hovermenu).fadeOut(); + }); + + // hide avatar menu when user clicks elsewhere + $(document).click(function(event) { + if ($(event.target).parents(".elgg-user-icon").length == 0) { + $(".elgg-hover-menu").fadeOut(); + } + }); +} + elgg.register_event_handler('init', 'system', elgg.ui.init);
\ No newline at end of file |