Turn profile fields into their own container classes.
[Sone.git] / src / main / resources / templates / editProfile.html
index d2dc61a..189488e 100644 (file)
@@ -1,7 +1,7 @@
 <%include include/head.html>
 
        <script language="javascript">
-               $(document).ready(function() {
+               $(function() {
                        getTranslation("WebInterface.DefaultText.FirstName", function(firstNameDefaultText) {
                                registerInputTextareaSwap("#sone #edit-profile input[name=first-name]", firstNameDefaultText, "first-name", true, true);
                        });
                        getTranslation("WebInterface.DefaultText.BirthYear", function(birthYearDefaultText) {
                                registerInputTextareaSwap("#sone #edit-profile input[name=birth-year]", birthYearDefaultText, "birth-year", true, true);
                        });
+                       getTranslation("WebInterface.DefaultText.FieldName", function(fieldNameDefaultText) {
+                               registerInputTextareaSwap("#sone #add-profile-field input[name=field-name]", fieldNameDefaultText, "field-name", true, true);
+                       });
+
+                       <%foreach fields field>
+                               registerInputTextareaSwap("#sone #edit-profile input[name=field-<% loop.count>]", <% field.key|js>, "field-<% loop.count>", true, true);
+                       <%/foreach>
 
                        /* hide all the labels. */
-                       $("#sone #edit-profile label").hide();
+                       $("#sone #edit-profile label, #sone #add-profile-field label").hide();
                });
        </script>
 
        <p><%= Page.EditProfile.Page.Description|l10n|html></p>
        <p><%= Page.EditProfile.Page.Hint.Optionality|l10n|html></p>
 
-       <%if changed>
-               <p><%= Page.EditProfile.Page.Status.Changed|l10n|html></p>
-       <%/if>
-
        <form id="edit-profile" method="post">
                <input type="hidden" name="formPassword" value="<% formPassword|html>" />
 
                </div>
 
                <div>
-                       <button type="submit" name="saveProfile" value="true"><%= Page.EditProfile.Button.Save|l10n|html></button>
+                       <button type="submit" name="save-profile" value="true"><%= Page.EditProfile.Button.Save|l10n|html></button>
+               </div>
+
+               <h1><%= Page.EditProfile.Fields.Title|l10n|html></h1>
+
+               <p><%= Page.EditProfile.Fields.Description|l10n|html></p>
+
+               <%foreach fields field fieldLoop>
+                       <div class="profile-field" id="<% field.id|html>">
+                               <div class="name"><% field.name|html></div>
+                               <div class="edit-field-name"><button type="submit" name="edit-field-<% field.id|html>" value="true"><%= Page.EditProfile.Fields.Button.Edit|l10n|html></button></div>
+                               <div class="delete-field-name"><button type="submit" name="delete-field-<% field.id|html>" value="true"><%= Page.EditProfile.Fields.Button.Delete|l10n|html></button></div>
+                               <div class="<%if fieldLoop.last>hidden <%/if>move-down-field"><button type="submit" name="move-down-field-<% field.id|html>" value="true"><%= Page.EditProfile.Fields.Button.MoveDown|l10n|html></button></div>
+                               <div class="<%if fieldLoop.first>hidden <%/if>move-up-field"><button type="submit" name="move-up-field-<% field.id|html>" value="true"><%= Page.EditProfile.Fields.Button.MoveUp|l10n|html></button></div>
+                               <div class="value"><input type="text" name="field-<% field.id|html>" value="<% field.value|html>" /></div>
+                       </div>
+
+                       <%if fieldLoop.last>
+                               <div>
+                                       <button type="submit" name="save-profile" value="true"><%= Page.EditProfile.Button.Save|l10n|html></button>
+                               </div>
+                       <%/if>
+               <%/foreach>
+
+       </form>
+
+       <form id="add-profile-field" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+
+               <a name="profile-fields"></a>
+               <h2><%= Page.EditProfile.Fields.AddField.Title|l10n|html></h2>
+
+               <%if duplicateFieldName>
+                       <p><%= Page.EditProfile.Error.DuplicateFieldName|l10n|replace needle="{fieldName}" replacementKey="fieldName"|html></p>
+               <%/if>
+
+               <div id="new-field">
+                       <label for="new-field"><%= Page.EditProfile.Fields.AddField.Label.Name|l10n|html></label>
+                       <input type="text" name="field-name" value="" />
+                       <button type="submit" name="add-field" value="true"><%= Page.EditProfile.Fields.AddField.Button.AddField|l10n|html></button>
                </div>
 
        </form>