X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=bfb925b794ec662bc667170622aef71ae7c4d869;hp=f6327e450a5e0e5c72a4d941473ec937acb64099;hb=deb360123df2d04b5745b9bd1d91d5452fe1f745;hpb=346362c492a163b6ed564a590d13ce0430c20009 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. */