From acad4aaa7ddf0104d57654e5b272353d8799adeb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 22 Jun 2011 20:47:19 +0200 Subject: [PATCH] Implement following/unfollowing from context menu. --- src/main/resources/static/css/sone.css | 4 ++++ src/main/resources/static/javascript/sone.js | 20 +++++++++++++++++++- src/main/resources/templates/include/soneMenu.html | 14 ++++++++++++++ src/main/resources/templates/include/viewPost.html | 13 ++----------- 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/templates/include/soneMenu.html diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index bf09065..9bdf10a 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -274,6 +274,10 @@ textarea { min-height: 64px; } +#sone .sone-menu .follow, #sone .sone-menu .unfollow { + cursor: pointer; +} + #sone .post > .avatar { position: absolute; } diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 0e3df51..1df8d42 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -804,12 +804,30 @@ 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) { + $(".sone-post-menu .follow", postElement).click(function() { + var followElement = this; + ajaxGet("followSone.ajax", { "sone": $(".sone-id", postElement).text(), "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": $(".sone-id", postElement).text(), "formPassword": getFormPassword() }, function() { + $(unfollowElement).addClass("hidden"); + $(unfollowElement).parent().find(".follow").removeClass("hidden"); + }); + return false; + }); + })(postElement); } /** diff --git a/src/main/resources/templates/include/soneMenu.html b/src/main/resources/templates/include/soneMenu.html new file mode 100644 index 0000000..60f1245 --- /dev/null +++ b/src/main/resources/templates/include/soneMenu.html @@ -0,0 +1,14 @@ +
+ + Avatar Image + +
diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index d0005c9..43f9981 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -3,17 +3,8 @@ -
- - Avatar Image - -
-
+ <%include include/soneMenu.html class=="sone-post-menu" sone=post.sone> +
<%if post.loaded> Avatar Image <%else> -- 2.7.4