+<%include include/head.html>
+
+ <script language="javascript">
+ function recheckMoveButtons() {
+ $("#sone .profile-field").each(function() {
+ $(".move-up-field", this).toggleClass("hidden", $(this).prev(".profile-field").length == 0);
+ $(".move-down-field", this).toggleClass("hidden", $(this).next(".profile-field").length == 0);
+ });
+ }
+
+ $(function() {
+ getTranslation("WebInterface.DefaultText.FirstName", function(firstNameDefaultText) {
+ registerInputTextareaSwap("#sone #edit-profile input[name=first-name]", firstNameDefaultText, "first-name", true, true);
+ });
+ getTranslation("WebInterface.DefaultText.MiddleName", function(middleNameDefaultText) {
+ registerInputTextareaSwap("#sone #edit-profile input[name=middle-name]", middleNameDefaultText, "middle-name", true, true);
+ });
+ getTranslation("WebInterface.DefaultText.LastName", function(lastNameDefaultText) {
+ registerInputTextareaSwap("#sone #edit-profile input[name=last-name]", lastNameDefaultText, "last-name", true, true);
+ });
+ getTranslation("WebInterface.DefaultText.BirthDay", function(birthDayDefaultText) {
+ registerInputTextareaSwap("#sone #edit-profile input[name=birth-day]", birthDayDefaultText, "birth-day", true, true);
+ });
+ getTranslation("WebInterface.DefaultText.BirthMonth", function(birthMonthDefaultText) {
+ registerInputTextareaSwap("#sone #edit-profile input[name=birth-month]", birthMonthDefaultText, "birth-month", 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, #sone #add-profile-field label").hide();
+
+ /* ajaxify the delete buttons. */
+ getTranslation("Page.EditProfile.Fields.Button.ReallyDelete", function(reallyDeleteText) {
+ $("#sone #edit-profile .delete-field-name button").each(function() {
+ confirmButton = $(this).clone().addClass("hidden").addClass("confirm").text(reallyDeleteText).insertAfter(this);
+ (function(deleteButton, confirmButton) {
+ deleteButton.click(function() {
+ deleteButton.fadeOut("slow", function() {
+ confirmButton.fadeIn("slow");
+ $(document).one("click", function() {
+ if (this != confirmButton.get(0)) {
+ confirmButton.fadeOut("slow", function() {
+ deleteButton.fadeIn("slow");
+ });
+ }
+ return false;
+ });
+ });
+ return false;
+ });
+ confirmButton.click(function() {
+ confirmButton.fadeOut("slow");
+ buttonName = confirmButton.attr("name");
+ fieldId = buttonName.substring("delete-field-".length);
+ deleteProfileField(fieldId);
+ recheckMoveButtons();
+ return false;
+ });
+ })($(this), confirmButton);
+ });
+ });
+
+ /* ajaxify the edit button. */
+ $("#sone #edit-profile .edit-field-name button").each(function() {
+ profileField = $(this).parents(".profile-field");
+ fieldNameElement = profileField.find(".name");
+ inputField = $("input[type=text].short", profileField);
+ confirmButton = $("button.confirm", profileField);
+ cancelButton = $("button.cancel", profileField);
+ (function(editButton, inputField, confirmButton, cancelButton, fieldNameElement) {
+ cleanUp = function(editButton, inputField, confirmButton, cancelButton, fieldNameElement) {
+ editButton.removeAttr("disabled");
+ inputField.addClass("hidden");
+ confirmButton.addClass("hidden");
+ cancelButton.addClass("hidden");
+ fieldNameElement.removeClass("hidden");
+ };
+ confirmButton.click(function() {
+ inputField.attr("disabled", "disabled");
+ confirmButton.attr("disabled", "disabled");
+ cancelButton.attr("disabled", "disabled");
+ editProfileField(confirmButton.parents(".profile-field").attr("id"), inputField.val(), function() {
+ fieldNameElement.text(inputField.val());
+ cleanUp(editButton, inputField, confirmButton, cancelButton, fieldNameElement);
+ });
+ return false;
+ });
+ cancelButton.click(function() {
+ cleanUp(editButton, inputField, confirmButton, cancelButton, fieldNameElement);
+ return false;
+ });
+ inputField.keypress(function(event) {
+ if (event.which == 13) {
+ confirmButton.click();
+ return false;
+ } else if (event.which == 27) {
+ cancelButton.click();
+ return false;
+ }
+ });
+ editButton.click(function() {
+ editButton.attr("disabled", "disabled");
+ fieldNameElement.addClass("hidden");
+ inputField.removeAttr("disabled").val(fieldNameElement.text()).removeClass("hidden").focus().select();
+ confirmButton.removeAttr("disabled").removeClass("hidden");
+ cancelButton.removeAttr("disabled").removeClass("hidden");
+ return false;
+ });
+ })($(this), inputField, confirmButton, cancelButton, fieldNameElement);
+ });
+
+ /* ajaxify “move up” and “move down” buttons. */
+ $("#sone .profile-field .move-down-field button").click(function() {
+ profileField = $(this).parents(".profile-field");
+ moveProfileFieldDown(profileField.attr("id"), function() {
+ next = profileField.next();
+ current = profileField.insertAfter(next);
+ recheckMoveButtons();
+ });
+ return false;
+ });
+ $("#sone .profile-field .move-up-field button").click(function() {
+ profileField = $(this).parents(".profile-field");
+ moveProfileFieldUp(profileField.attr("id"), function() {
+ previous = profileField.prev();
+ current = profileField.insertBefore(previous);
+ recheckMoveButtons();
+ });
+ return false;
+ });
+ });
+ </script>