Load texts for input fields only once.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Nov 2010 10:36:10 +0000 (11:36 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 12 Nov 2010 10:36:10 +0000 (11:36 +0100)
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/head.html

index 7b971bb..01f13e3 100644 (file)
@@ -11,11 +11,7 @@ function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName, o
                                $(this).hide();
                                inputField = $(this).data("inputField");
                                inputField.show().removeAttr("disabled").addClass("default");
-                               (function(inputField) {
-                                       getTranslation(defaultText, function(translation) {
-                                               inputField.val(translation);
-                                       });
-                               })(inputField);
+                               inputField.val(defaultText);
                        }
                }).hide().data("inputField", $(this)).val($(this).val());
                $(this).after(textarea);
@@ -26,11 +22,7 @@ function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName, o
                        });
                        if (inputField.val() == "") {
                                inputField.addClass("default");
-                               (function(inputField) {
-                                       getTranslation(defaultText, function(translation) {
-                                               inputField.val(translation);
-                                       });
-                               })(inputField);
+                               inputField.val(defaultText);
                        } else {
                                inputField.hide().attr("disabled", "disabled");
                                textarea.show();
index 9330e14..e6038d7 100644 (file)
@@ -8,7 +8,9 @@
        <script language="javascript">
                /* this initializes the status update input field. */
                $(document).ready(function() {
-                       registerInputTextareaSwap("#sone #update-status .status-input", "WebInterface.DefaultText.StatusUpdate", "text", false, false);
+                       getTranslation("WebInterface.DefaultText.StatusUpdate", function(text) {
+                               registerInputTextareaSwap("#sone #update-status .status-input", text, "text", false, false);
+                       })
                });
        </script>
 
        <script language="javascript">
                /* this initializes all reply input fields. */
                $(document).ready(function() {
-                       registerInputTextareaSwap("#sone input.reply-input", "WebInterface.DefaultText.Reply", "text", false, false);
-                       addCommentLinks();
+                       getTranslation("WebInterface.DefaultText.Reply", function(text) {
+                               registerInputTextareaSwap("#sone input.reply-input", text, "text", false, false);
+                               addCommentLinks();
+                       })
                });
        </script>