From: David ‘Bombe’ Roden Date: Fri, 14 Jan 2011 21:14:50 +0000 (+0100) Subject: Ajaxify the profile field delete button. X-Git-Tag: 0.4^2~9^2~9 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=746ba11c985b19825b4bc82ded044a13586c88d1;p=Sone.git Ajaxify the profile field delete button. --- diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 86270b8..ccedff0 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -76,6 +76,7 @@ Page.EditProfile.Fields.Button.Edit=edit Page.EditProfile.Fields.Button.MoveUp=move up Page.EditProfile.Fields.Button.MoveDown=move down Page.EditProfile.Fields.Button.Delete=delete +Page.EditProfile.Fields.Button.ReallyDelete=really delete Page.EditProfile.Fields.AddField.Title=Add Field Page.EditProfile.Fields.AddField.Label.Name=Name: Page.EditProfile.Fields.AddField.Button.AddField=Add Field diff --git a/src/main/resources/templates/editProfile.html b/src/main/resources/templates/editProfile.html index 189488e..2ad1faa 100644 --- a/src/main/resources/templates/editProfile.html +++ b/src/main/resources/templates/editProfile.html @@ -30,6 +30,35 @@ /* hide all the labels. */ $("#sone #edit-profile label, #sone #add-profile-field label").hide(); + + 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); + return false; + }); + })($(this), confirmButton); + }); + }); });