Add possibility to post a message directly to another Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 22:01:21 +0000 (23:01 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 22:01:21 +0000 (23:01 +0100)
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/viewSone.html

index ad3f4b0..32ff6c6 100644 (file)
@@ -89,6 +89,7 @@ Page.ViewSone.Title=View Sone - Sone
 Page.ViewSone.Page.TitleWithoutSone=View unknown Sone
 Page.ViewSone.NoSone.Description=There is currently no known Sone with the ID {sone}. If you were looking for a specific Sone, make sure that it is visible in your web of trust!
 Page.ViewSone.UnknownSone.Description=This Sone has not yet been retrieved. Please check back in a short time.
+Page.ViewSone.WriteAMessage=You can write a message to this Sone here. Please note that everybody will be able to read this message!
 Page.ViewSone.PostList.Title=Posts by {sone}
 Page.ViewSone.PostList.Text.NoPostYet=This Sone has not yet posted anything.
 
@@ -157,6 +158,7 @@ View.Post.LikeLink=Like
 View.Post.UnlikeLink=Unlike
 
 WebInterface.DefaultText.StatusUpdate=What’s on your mind?
+WebInterface.DefaultText.Message=Write a Message…
 WebInterface.DefaultText.Reply=Write a Reply…
 WebInterface.DefaultText.FirstName=First name
 WebInterface.DefaultText.MiddleName=Middle name(s)
index 608a4e8..2861575 100644 (file)
@@ -177,7 +177,7 @@ textarea {
        min-height: 48px;
 }
 
-#sone .post .author {
+#sone .post .author, #sone .post .recipient {
        display: inline;
        font-weight: bold;
 }
index 8be0282..7f09089 100644 (file)
@@ -742,6 +742,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) {
index 916b110..4d96fab 100644 (file)
                        <%include include/viewSone.html>
                <%/if>
 
+               <p><%= Page.ViewSone.WriteAMessage|l10n|html></p>
+
+               <form action="createPost.html" id="post-message" method="post">
+                       <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+                       <input type="hidden" name="returnPage" value="<% request.uri|html>" />
+                       <input type="hidden" name="recipient" value="<% sone.id|html>" />
+                       <input type="text" name="text" value="" />
+                       <button type="submit"><%= Page.CreatePost.Button.Post|l10n|html></button>
+               </form>
+
                <h1><%= Page.ViewSone.PostList.Title|l10n|insert needle="{sone}" key=sone.niceName|html></h1>
 
                <div id="posts">