Implement search.
[Sone.git] / src / main / resources / static / javascript / sone.js
index c5296ca..6022655 100644 (file)
@@ -639,6 +639,8 @@ function ajaxifyPost(postElement) {
                return false;
        });
        $(postElement).find(".create-reply button:submit").click(function() {
+               button = $(this);
+               button.attr("disabled", "disabled");
                sender = $(this.form).find(":input[name=sender]").val();
                inputField = $(this.form).find(":input[name=text]:enabled").get(0);
                postId = getPostId(this);
@@ -655,6 +657,7 @@ function ajaxifyPost(postElement) {
                                } else {
                                        alert(error);
                                }
+                               button.removeAttr("disabled");
                        });
                })(sender, postId, text, inputField);
                return false;
@@ -692,6 +695,25 @@ function ajaxifyPost(postElement) {
                return false;
        });
 
+       /* convert bookmark/unbookmark buttons to javascript functions. */
+       $(postElement).find(".bookmark").submit(function() {
+               bookmarkPost(getPostId(this));
+               return false;
+       });
+       $(postElement).find(".unbookmark").submit(function() {
+               unbookmarkPost(getPostId(this));
+               return false;
+       });
+
+       /* convert “show source” link into javascript function. */
+       $(postElement).find(".show-source").each(function() {
+               $("a", this).click(function() {
+                       $(".post-text.text", getPostElement(this)).toggleClass("hidden");
+                       $(".post-text.raw-text", getPostElement(this)).toggleClass("hidden");
+                       return false;
+               });
+       });
+
        /* add “comment” link. */
        addCommentLink(getPostId(postElement), postElement, $(postElement).find(".post-status-line .time"));
 
@@ -752,6 +774,15 @@ function ajaxifyReply(replyElement) {
        })(replyElement);
        addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time"));
 
+       /* convert “show source” link into javascript function. */
+       $(replyElement).find(".show-reply-source").each(function() {
+               $("a", this).click(function() {
+                       $(".reply-text.text", getReplyElement(this)).toggleClass("hidden");
+                       $(".reply-text.raw-text", getReplyElement(this)).toggleClass("hidden");
+                       return false;
+               });
+       });
+
        /* convert trust control buttons to javascript functions. */
        $(replyElement).find(".reply-trust").submit(function() {
                trustSone(getReplyAuthor(this));
@@ -1270,6 +1301,8 @@ $(document).ready(function() {
                        return false;
                });
                $("#sone #update-status").submit(function() {
+                       button = $("button:submit", this);
+                       button.attr("disabled", "disabled");
                        if ($(this).find(":input.default:enabled").length > 0) {
                                return false;
                        }
@@ -1279,6 +1312,7 @@ $(document).ready(function() {
                                if ((data != null) && data.success) {
                                        loadNewPost(data.postId, data.sone, data.recipient);
                                }
+                               button.removeAttr("disabled");
                        });
                        $(this).find(":input[name=sender]").val(getCurrentSoneId());
                        $(this).find(":input[name=text]:enabled").val("").blur();
@@ -1288,6 +1322,11 @@ $(document).ready(function() {
                });
        });
 
+       /* ajaxify the search input field. */
+       getTranslation("WebInterface.DefaultText.Search", function(defaultText) {
+               registerInputTextareaSwap("#sone #search input[name=query]", defaultText, "query", false, true);
+       });
+
        /* ajaxify input field on “view Sone” page. */
        getTranslation("WebInterface.DefaultText.Message", function(defaultText) {
                registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false);