Show multiline-capable input boxes on focus, single-line inputs on blur.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 20:26:07 +0000 (22:26 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 20:26:07 +0000 (22:26 +0200)
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/updateStatus.html

index bd57f26..90c2183 100644 (file)
@@ -1,9 +1,12 @@
 /* Sone Main CSS File */
 
 /* first, override some fproxy rules. */
-#sone .post .reply div,#sone .post .time,#sone .post .delete,#sone .post .show-reply-form
-       {
-       font-size: inherit;
+#sone .post .reply div,#sone .post .time,#sone .post .delete,#sone .post .show-reply-form, input[type=text], textarea {
+       font: inherit;
+}
+
+input[type=text], textarea {
+       font-size: 90%;
 }
 
 #sone form {
 }
 
 #sone #home-sone {
+       margin-top: 1ex;
        margin-left: 80px;
        padding-left: 1ex;
 }
 
+#sone #update-status label {
+       display: none;
+}
+
+#sone #update-status input[type=text] {
+       width: 45em;
+} 
+
+#sone #update-status textarea {
+       border: solid 1px #ccc;
+       width: 45em;
+       height: 4em;
+}
+
+#sone #update-status button {
+       float: right;
+}
+
 #sone .nice-name {
        font-weight: bold;
 }
        padding: 0.5ex;
 }
 
-#sone .post .create-reply.light button {
-       display: none;
+#sone .post .create-reply input[type=text] {
+       width: 50em;
+}
+
+#sone .post .create-reply textarea {
+       width: 50em;
+       height: 4em;
+}
+
+#sone .post .create-reply button {
+       float: right;
 }
 
 #sone .sone {
index 502413a..66f12af 100644 (file)
@@ -2,21 +2,25 @@
 
 function registerInputTextareaSwap(inputSelector, defaultText) {
        $(inputSelector).each(function() {
-               $(this).focus(function() {
-                       if ($(this).hasClass("default")) {
-                               $(this).removeClass("default").val("");
-                       }
-               }).blur(function() {
+               textarea = $("<textarea name=\"text\"></textarea>").blur(function() {
                        if ($(this).val() == "") {
-                               $(this).val(defaultText).addClass("default");
-                       }
-               }).addClass("default").val(defaultText);
-               var inputField = $(this);
-               $(this.form).submit(function() {
-                       if (inputField.hasClass("default")) {
-                               inputField.val("");
+                               $(this).hide();
+                               $(this).data("inputField").show().removeAttr("disabled");
                        }
-               });
+               }).hide().data("inputField", $(this));
+               $(this).after(textarea);
+               (function(inputField, textarea) {
+                       $(inputField).focus(function() {
+                               $(this).hide().attr("disabled", "disabled");
+                               textarea.show().focus();
+                       }).addClass("default").val(defaultText);
+                       $(inputField.form).submit(function() {
+                               if (textarea.val() == "") {
+                                       return false;
+                               }
+                               $(inputField).val(textarea.val());
+                       });
+               })(this, textarea);
        });
 }
 
index 63b4b8f..fba951d 100644 (file)
@@ -1,9 +1,7 @@
-<div id="update-status">
-       <form 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>
-               <input class="status-input" name="text" value="" />
-               <button type="submit"><%= Page.Index.Button.Post|l10n|html></button>
-       </form>
-</div>
+<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>
+       <input type="text" class="status-input" name="text" value="" />
+       <button type="submit"><%= Page.Index.Button.Post|l10n|html></button>
+</form>