From: David ‘Bombe’ Roden Date: Mon, 26 Sep 2011 17:37:40 +0000 (+0200) Subject: Only show Sone context menus when hovering over the avatar. X-Git-Tag: 0.7^2~2^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=deb360123df2d04b5745b9bd1d91d5452fe1f745;p=Sone.git Only show Sone context menus when hovering over the avatar. --- 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. */