From deb360123df2d04b5745b9bd1d91d5452fe1f745 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 26 Sep 2011 19:37:40 +0200 Subject: [PATCH] Only show Sone context menus when hovering over the avatar. --- src/main/resources/static/javascript/sone.js | 44 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index f6327e4..bfb925b 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -858,11 +858,20 @@ function ajaxifyPost(postElement) { /* show Sone menu when hovering over the avatar. */ $(postElement).find(".post-avatar").mouseover(function() { - $(".sone-menu:visible").fadeOut(); - $(".sone-post-menu", postElement).mouseleave(function() { - $(this).fadeOut(); - }).fadeIn(); - return false; + if (typeof currentSoneMenuTimeoutHandler != undefined) { + clearTimeout(currentSoneMenuTimeoutHandler); + } + currentSoneMenuId = getPostId(this); + currentSoneMenuTimeoutHandler = setTimeout(function() { + $(".sone-menu:visible").fadeOut(); + $(".sone-post-menu", postElement).mouseleave(function() { + $(this).fadeOut(); + }).fadeIn(); + }, 1000); + }).mouseleave(function() { + if (currentSoneMenuId = getPostId(this)) { + clearTimeout(currentSoneMenuTimeoutHandler); + } }); (function(postElement) { var soneId = $(".sone-menu-id", postElement).text(); @@ -988,11 +997,20 @@ function ajaxifyReply(replyElement) { /* show Sone menu when hovering over the avatar. */ $(replyElement).find(".reply-avatar").mouseover(function() { - $(".sone-menu:visible").fadeOut(); - $(".sone-reply-menu", replyElement).mouseleave(function() { - $(this).fadeOut(); - }).fadeIn(); - return false; + if (typeof currentSoneMenuTimeoutHandler != undefined) { + clearTimeout(currentSoneMenuTimeoutHandler); + } + currentSoneMenuId = getPostId(this) + "-" + getReplyId(this); + currentSoneMenuTimeoutHandler = setTimeout(function() { + $(".sone-menu:visible").fadeOut(); + $(".sone-reply-menu", replyElement).mouseleave(function() { + $(this).fadeOut(); + }).fadeIn(); + }, 1000); + }).mouseleave(function() { + if (currentSoneMenuId = getPostId(this) + "-" + getReplyId(this)) { + clearTimeout(currentSoneMenuTimeoutHandler); + } }); (function(replyElement) { var soneId = $(".sone-menu-id", replyElement).text(); @@ -1828,6 +1846,12 @@ var online = true; var initiallyLoggedIn = $("#sone #loggedIn").text() == "true"; var notLoggedIn = !initiallyLoggedIn; +/** ID of the next-to-show Sone context menu. */ +var currentSoneMenuId; + +/** Timeout handler for the next-to-show Sone context menu. */ +var currentSoneMenuTimeoutHandler; + $(document).ready(function() { /* this initializes the status update input field. */ -- 2.7.4