X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=05aab1d85f9202d4f36e6bf4d25614c320c3c57f;hb=cc3c5cb776fa7913bdb45ce9602dc0e5cb5c8608;hp=0e3df51f5fd4565cf6bb04d8d196a7ccdc7cec82;hpb=61ee54ddb663a3faf4a9c125a07d89dc3940e1f5;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 0e3df51..05aab1d 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -283,6 +283,18 @@ function getSoneElement(element) { } /** + * Returns the ID of the sone of the context menu that contains the given + * element. + * + * @param element + * The element within a context menu to get the Sone ID for + * @return The Sone ID + */ +function getMenuSone(element) { + return $(element).closest(".sone-menu").find(".sone-id").text(); +} + +/** * Generates a list of Sones by concatening the names of the given sones with a * new line character (“\n”). * @@ -804,12 +816,31 @@ function ajaxifyPost(postElement) { $(postElement).find(".create-reply").addClass("hidden"); /* show Sone menu when hovering over the avatar. */ - $(postElement).find(".avatar").mouseover(function() { + $(postElement).find(".post-avatar").mouseover(function() { $(".sone-post-menu", postElement).mouseleave(function() { $(this).fadeOut(); }).fadeIn(); return false; }); + (function(postElement) { + var soneId = $(".sone-id", postElement).text(); + $(".sone-post-menu .follow", postElement).click(function() { + var followElement = this; + ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() { + $(followElement).addClass("hidden"); + $(followElement).parent().find(".unfollow").removeClass("hidden"); + }); + return false; + }); + $(".sone-post-menu .unfollow", postElement).click(function() { + var unfollowElement = this; + ajaxGet("unfollowSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() { + $(unfollowElement).addClass("hidden"); + $(unfollowElement).parent().find(".follow").removeClass("hidden"); + }); + return false; + }); + })(postElement); } /**