Allow sender selection on new posts.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 18 Jan 2011 06:31:55 +0000 (07:31 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 18 Jan 2011 06:31:55 +0000 (07:31 +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/include/updateStatus.html

index 7b8450f..b5c7e24 100644 (file)
@@ -55,6 +55,7 @@ Page.DeleteSone.Button.No=No, do not delete.
 
 Page.Index.Title=Your Sone - Sone
 Page.Index.Label.Text=Post text:
+Page.Index.Label.Sender=Sender:
 Page.Index.Button.Post=Post!
 Page.Index.PostList.Title=Post Feed
 Page.Index.PostList.Text.NoPostYet=Nobody has written any posts yet. You should probably start it right now!
@@ -200,6 +201,8 @@ View.Post.Reply.DeleteLink=Delete
 View.Post.LikeLink=Like
 View.Post.UnlikeLink=Unlike
 
+View.UpdateStatus.Text.ChooseSenderIdentity=Choose the sender identity
+
 View.Trust.Tooltip.Trust=Trust this person
 View.Trust.Tooltip.Distrust=Assign negative trust to this person
 View.Trust.Tooltip.Untrust=Remove your trust assignment for this person
index 5b1d486..530b2e1 100644 (file)
@@ -172,6 +172,15 @@ textarea {
        float: right;
 }
 
+#sone #update-status .select-sender {
+       display: none;
+}
+
+#sone #update-status .select-sender button {
+       display: inline;
+       float: none;
+}
+
 #sone .nice-name {
        font-weight: bold;
 }
index 9d00c5a..c5b3a38 100644 (file)
@@ -1078,17 +1078,28 @@ $(document).ready(function() {
        /* this initializes the status update input field. */
        getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) {
                registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false);
+               $("#sone #update-status .select-sender").show();
+               $("#sone #update-status .sender").hide();
+               $("#sone #update-status .select-sender button").click(function() {
+                       $("#sone #update-status .sender").show();
+                       $("#sone #update-status .select-sender").hide();
+                       return false;
+               });
                $("#sone #update-status").submit(function() {
                        if ($(this).find(":input.default:enabled").length > 0) {
                                return false;
                        }
-                       text = $(this).find(":input:enabled").val();
-                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) {
+                       sender = $(this).find(":input[name=sender]").val();
+                       text = $(this).find(":input[name=text]:enabled").val();
+                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "sender": sender, "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {
-                                       loadNewPost(data.postId, getCurrentSoneId());
+                                       loadNewPost(data.postId, data.sone, data.recipient);
                                }
                        });
-                       $(this).find(":input:enabled").val("").blur();
+                       $(this).find(":input[name=sender]").val(getCurrentSoneId());
+                       $(this).find(":input[name=text]:enabled").val("").blur();
+                       $(this).find(".sender").hide();
+                       $(this).find(".select-sender").show();
                        return false;
                });
        });
index fba951d..43d4d70 100644 (file)
@@ -1,7 +1,15 @@
 <form id="update-status" action="createPost.html" method="post">
        <input type="hidden" name="formPassword" value="<% formPassword|html>" />
        <input type="hidden" name="returnPage" value="<% request.uri|html>" />
-       <label for="text"><%= Page.Index.Label.Text|l10n|html></label>
+       <label for="sender"><%= Page.Index.Label.Sender|l10n|html></label>
+       <div class="sender">
+               <select name="sender" title="<%= View.UpdateStatus.Text.ChooseSenderIdentity|l10n|html>">
+                       <%foreach localSones localSone>
+                               <option value="<% localSone.id|html>"<%if localSone.current> selected="selected"<%/if>><% localSone.niceName|html></option>
+                       <%/foreach>
+               </select>
+       </div>
+       <div class="select-sender"><button type="button" title="<%= View.UpdateStatus.Text.ChooseSenderIdentity|l10n|html>">+</button></div><label for="text"><%= Page.Index.Label.Text|l10n|html></label>
        <input type="text" class="status-input" name="text" value="" />
        <button type="submit"><%= Page.Index.Button.Post|l10n|html></button>
 </form>