Implement following/unfollowing from context menu.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jun 2011 18:47:19 +0000 (20:47 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 22 Jun 2011 19:33:38 +0000 (21:33 +0200)
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/soneMenu.html [new file with mode: 0644]
src/main/resources/templates/include/viewPost.html

index bf09065..9bdf10a 100644 (file)
@@ -274,6 +274,10 @@ textarea {
        min-height: 64px;
 }
 
+#sone .sone-menu .follow, #sone .sone-menu .unfollow {
+       cursor: pointer;
+}
+
 #sone .post > .avatar {
        position: absolute;
 }
index 0e3df51..1df8d42 100644 (file)
@@ -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 (file)
index 0000000..60f1245
--- /dev/null
@@ -0,0 +1,14 @@
+<div class="sone-menu <% class|css|html>">
+       <div class="sone-id hidden"><%sone.id|html></div>
+       <img class="avatar" src="/WebOfTrust/GetIdenticon?identity=<%sone.id|html>&amp;width=64&height=64" width="64" height="64" alt="Avatar Image" />
+       <div class="inner-menu">
+               <div>
+                       <a class="author" href="viewSone.html?sone=<%sone.id|html>"><%sone.niceName|html></a>
+                       <span class="author-wot-link">(<a href="/WebOfTrust/ShowIdentity?id=<%sone.id|html>"><% =View.Post.WebOfTrustLink|l10n|html></a>)</span>
+               </div>
+               <div>
+                       <a class="follow<%if sone.friend> hidden<%/if>"><%= View.Sone.Button.FollowSone|l10n|html></a>
+                       <a class="unfollow<%if !sone.friend> hidden<%/if>"><%= View.Sone.Button.UnfollowSone|l10n|html></a>
+               </div>
+       </div>
+</div>
index d0005c9..43f9981 100644 (file)
@@ -3,17 +3,8 @@
        <div class="post-time hidden"><% post.time|html></div>
        <div class="post-author hidden"><% post.sone.id|html></div>
        <div class="post-author-local hidden"><% post.sone.local></div>
-       <div class="sone-post-menu">
-               <div class="sone-id hidden"><%post.sone.id|html></div>
-               <img class="avatar" src="/WebOfTrust/GetIdenticon?identity=<% post.sone.id|html>&amp;width=64&height=64" width="64" height="64" alt="Avatar Image" />
-               <div class="inner-menu">
-                       <div>
-                               <a class="author" href="viewSone.html?sone=<% post.sone.id|html>"><% post.sone.niceName|html></a>
-                               <span class="author-wot-link">(<a href="/WebOfTrust/ShowIdentity?id=<% post.sone.id|html>"><% =View.Post.WebOfTrustLink|l10n|html></a>)</span>
-                       </div>
-               </div>
-       </div>
-       <div class="avatar">
+       <%include include/soneMenu.html class=="sone-post-menu" sone=post.sone>
+       <div class="avatar post-avatar" >
                <%if post.loaded>
                        <img src="/WebOfTrust/GetIdenticon?identity=<% post.sone.id|html>&amp;width=48&height=48" width="48" height="48" alt="Avatar Image" />
                <%else>