From: David ‘Bombe’ Roden Date: Thu, 21 Oct 2010 10:24:26 +0000 (+0200) Subject: Add default texts for input fields with AJAX. X-Git-Tag: 0.1-RC1~125 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=bc67a0f3537a40197fac4f99a9e9ec970a686fdb;p=Sone.git Add default texts for input fields with AJAX. --- diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 9d819a7..bdb95f4 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -158,3 +158,11 @@ View.Sone.Status.Inserting=This Sone is currently being inserted. View.Post.DeleteLink=Delete View.Post.SendReply=Post Reply! View.Post.Reply.DeleteLink=Delete + +WebInterface.DefaultText.StatusUpdate=What’s on your mind? +WebInterface.DefaultText.CreateSoneName=The name of your Sone +WebInterface.DefaultText.CreateSoneDocumentName=The document name of your Sone (e.g. the “foo” in USK@…/foo/0) +WebInterface.DefaultText.CreateSoneInsertURI=The Insert Key of your Sone +WebInterface.DefaultText.CreateSoneRequestURI=The Request Key of your Sone +WebInterface.DefaultText.Reply=Write a Reply… +WebInterface.DefaultText.SoneRequestURI=Sone Request Key diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 200c870..5d75952 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -1,6 +1,6 @@ /* Sone JavaScript functions. */ -function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName) { +function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName, optional) { $(inputSelector).each(function() { textarea = $("").blur(function() { if ($(this).val() == "") { @@ -13,9 +13,14 @@ function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName) { $(inputField).focus(function() { $(this).hide().attr("disabled", "disabled"); textarea.show().focus(); - }).addClass("default").val(defaultText); + }).addClass("default"); + (function(inputField) { + $.getJSON("ajax/getTranslation.ajax", {"key": defaultText}, function(data, textStatus) { + $(inputField).val(data.value); + }); + })(inputField); $(inputField.form).submit(function() { - if (textarea.val() == "") { + if (!optional && (textarea.val() == "")) { return false; } }); diff --git a/src/main/resources/templates/include/createSone.html b/src/main/resources/templates/include/createSone.html index 9666b27..f2777c3 100644 --- a/src/main/resources/templates/include/createSone.html +++ b/src/main/resources/templates/include/createSone.html @@ -1,9 +1,9 @@ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 5dcda5a..8f18974 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -3,7 +3,7 @@ diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html index 3f55a58..862c01e 100644 --- a/src/main/resources/templates/knownSones.html +++ b/src/main/resources/templates/knownSones.html @@ -2,7 +2,7 @@