Ajaxify trust controls in replies.
[Sone.git] / src / main / resources / static / javascript / sone.js
index 58917c9..ef34c66 100644 (file)
@@ -460,7 +460,7 @@ function updateTrustControls(soneId, trustValue) {
                        getPostElement(this).find(".post-untrust").toggleClass("hidden", trustValue == null);
                }
        });
-       $(this).find("#sone .reply").each(function() {
+       $("#sone .reply").each(function() {
                if (getReplyAuthor(this) == soneId) {
                        getReplyElement(this).find(".reply-trust").toggleClass("hidden", trustValue != null);
                        getReplyElement(this).find(".reply-distrust").toggleClass("hidden", (trustValue != null) && (trustValue < 0));
@@ -640,6 +640,20 @@ function ajaxifyReply(replyElement) {
        })(replyElement);
        addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time"));
 
+       /* convert trust control buttons to javascript functions. */
+       $(replyElement).find(".reply-trust").submit(function() {
+               trustSone(getReplyAuthor(this));
+               return false;
+       });
+       $(replyElement).find(".reply-distrust").submit(function() {
+               distrustSone(getReplyAuthor(this));
+               return false;
+       });
+       $(replyElement).find(".reply-untrust").submit(function() {
+               untrustSone(getReplyAuthor(this));
+               return false;
+       });
+
        /* mark post and all replies as known on click. */
        $(replyElement).click(function() {
                markPostAsKnown(getPostElement(this));