Allow sender selection when sending a message on the “view Sone” page.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Jan 2011 06:45:36 +0000 (07:45 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Jan 2011 06:45:36 +0000 (07:45 +0100)
This fixes #99.

src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/viewSone.html

index c5d8e9a..676a9d5 100644 (file)
@@ -164,7 +164,7 @@ textarea {
        margin-bottom: 1em;
 }
 
-#sone #update-status label {
+#sone #update-status label, #sone #post-message label {
        display: none;
 }
 
@@ -180,11 +180,11 @@ textarea {
        float: right;
 }
 
-#sone #update-status .select-sender, #sone .create-reply .select-sender {
+#sone #update-status .select-sender, #sone .create-reply .select-sender, #sone #post-message .select-sender {
        display: none;
 }
 
-#sone #update-status .select-sender button {
+#sone #update-status .select-sender button, #sone #post-message .select-sender button {
        display: inline;
        float: left;
 }
@@ -392,7 +392,7 @@ textarea {
        float: right;
 }
 
-#sone .create-reply .select-sender button {
+#sone .create-reply .select-sender button, #sone #post-message .select-sender button {
        display: inline;
        float: left;
 }
index fb16b97..6c396f8 100644 (file)
@@ -1248,14 +1248,25 @@ $(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 .select-sender").css("display", "inline");
+               $("#sone #post-message .sender").hide();
+               $("#sone #post-message .select-sender button").click(function() {
+                       $("#sone #post-message .sender").show();
+                       $("#sone #post-message .select-sender").hide();
+                       return false;
+               });
                $("#sone #post-message").submit(function() {
-                       text = $(this).find(":input:enabled").val();
-                       $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "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(), "recipient": getShownSoneId(), "sender": sender, "text": text }, function(data, textStatus) {
                                if ((data != null) && data.success) {
                                        loadNewPost(data.postId, getCurrentSoneId());
                                }
                        });
-                       $(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 4b2502a..d2a8f6e 100644 (file)
                                        <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>" />
+                                       <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" name="text" value="" />
                                        <button type="submit"><%= Page.CreatePost.Button.Post|l10n|html></button>
                                </form>