Merge commit '0.3.1-RC3' into message-recipient
[Sone.git] / src / main / resources / static / javascript / sone.js
index a4ad957..75facb3 100644 (file)
@@ -618,6 +618,7 @@ function loadNewPost(postId) {
                                        return false;
                                }
                        });
+                       newPost = $(data.post.html).addClass("hidden");
                        if (firstOlderPost != null) {
                                newPost.insertBefore(firstOlderPost);
                        } else {
@@ -646,6 +647,7 @@ function loadNewReply(replyId) {
                                                return false;
                                        }
                                });
+                               newReply = $(data.reply.html).addClass("hidden");
                                if (firstNewerReply != null) {
                                        newReply.insertBefore(firstNewerReply);
                                } else {
@@ -751,6 +753,21 @@ $(document).ready(function() {
                });
        });
 
+       /* ajaxify input field on “view Sone” page. */
+       getTranslation("WebInterface.DefaultText.Message", function(defaultText) {
+               registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false);
+               $("#sone #post-message").submit(function() {
+                       text = $(this).find(":input:enabled").val();
+                       $.getJSON("ajax/createPost.ajax", { "formPassword": getFormPassword(), "recipient": $("#sone #sone-id").text(), "text": text }, function(data, textStatus) {
+                               if ((data != null) && data.success) {
+                                       loadNewPost(data.postId);
+                               }
+                       });
+                       $(this).find(":input:enabled").val("").blur();
+                       return false;
+               });
+       });
+
        /* Ajaxifies all posts. */
        /* calling getTranslation here will cache the necessary values. */
        getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {