From: David ‘Bombe’ Roden Date: Sat, 15 Jan 2011 14:39:01 +0000 (+0100) Subject: Add Javascript methods to add profile fields. X-Git-Tag: 0.4^2~9^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b8aa22ff7725d69f126c4dfe838c7ce4b5ea3e2d;p=Sone.git Add Javascript methods to add profile fields. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 2decb69..8029ccc 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -894,6 +894,48 @@ function editProfileField(fieldId, newName, successFunction) { }); } +/** + * Moves the profile field with the given ID one slot in the given direction. + * + * @param fieldId + * The ID of the field to move + * @param direction + * The direction to move in (“up” or “down”) + * @param successFunction + * Function to call on success + */ +function moveProfileField(fieldId, direction, successFunction) { + $.getJSON("moveProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId, "direction": direction}, function(data, textStatus) { + if (data && data.success) { + successFunction(); + } + }); +} + +/** + * Moves the profile field with the given ID up one slot. + * + * @param fieldId + * The ID of the field to move + * @param successFunction + * Function to call on success + */ +function moveProfileFieldUp(fieldId, successFunction) { + moveProfileField(fieldId, "up", successFunction); +} + +/** + * Moves the profile field with the given ID down one slot. + * + * @param fieldId + * The ID of the field to move + * @param successFunction + * Function to call on success + */ +function moveProfileFieldDown(fieldId, successFunction) { + moveProfileField(fieldId, "down", successFunction); +} + // // EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE //