Hide advanced settings.
[Sone.git] / src / main / resources / templates / include / createSone.html
index 318effe..9666b27 100644 (file)
@@ -1,3 +1,33 @@
+<script language="javascript">
+       $(document).ready(function() {
+               registerInputTextareaSwap("#sone #create-sone input[name=name]", "The name of your Sone", "name");
+               registerInputTextareaSwap("#sone #create-sone input[name=document-name]", "The document name of your Sone", "document-name");
+               registerInputTextareaSwap("#sone #create-sone input[name=insert-uri]", "The insert URI of your Sone", "insert-uri");
+               registerInputTextareaSwap("#sone #create-sone input[name=request-uri]", "The request URI of your Sone", "request-uri");
+
+               /* hide all the labels. */
+               $("#sone #create-sone label").hide();
+
+               /* now hide the “advanced” section. */
+               advancedSection = $("#sone #create-sone .advanced");
+               advancedSection.hide();
+
+               /* show a checkbox instead. */
+               checkboxSection = $("<div></div>");
+               checkbox = $("<input type=\"checkbox\" />").click(function() {
+                       if (this.checked) {
+                               advancedSection.show();
+                               $("#sone #create-sone button[name=create-random]").hide();
+                       } else {
+                               advancedSection.hide();
+                               $("#sone #create-sone button[name=create-random]").show();
+                       }
+               })
+               checkboxSection.append(checkbox).append("Show advanced settings");
+               advancedSection.before(checkboxSection);
+       });
+</script>
+
 <form id="create-sone" action="createSone.html" method="post">
        <input type="hidden" name="formPassword" value="<% formPassword|html>" />
        <div<%if errorName> class="error"<%/if>>
        <div>
                <button type="submit" name="create-random" value="1"><%= Page.Login.CreateSone.Button.CreateRandom|l10n|html></button>
        </div>
-       <div<%if errorUri> class="error"<%/if>>
-               <label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
-               <input type="text" name="insert-uri" value="<% insertUri|html>" />
-       </div>
-       <div<%if errorUri> class="error"<%/if>>
-               <label for="insert-uri"><%= Page.Login.CreateSone.Label.InsertURI|l10n|html></label>
-               <input type="text" name="insert-uri" value="<% requestUri|html>" />
-       </div>
-       <div>
-               <button type="submit" name="create-from-uri" value="1"><%= Page.Login.CreateSone.Button.CreateFromURI|l10n|html></button>
+       <div class="advanced">
+               <div<%if errorUri> class="error"<%/if>>
+                       <label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
+                       <input type="text" name="insert-uri" value="<% insertUri|html>" />
+               </div>
+               <div<%if errorUri> class="error"<%/if>>
+                       <label for="insert-uri"><%= Page.Login.CreateSone.Label.InsertURI|l10n|html></label>
+                       <input type="text" name="insert-uri" value="<% requestUri|html>" />
+               </div>
+               <div>
+                       <button type="submit" name="create-from-uri" value="1"><%= Page.Login.CreateSone.Button.CreateFromURI|l10n|html></button>
+               </div>
        </div>
 </form>