From: David ‘Bombe’ Roden Date: Sat, 15 Jan 2011 14:48:28 +0000 (+0100) Subject: Merge branch 'profile-fields' into next X-Git-Tag: 0.4^2~9 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=76e7a20f5212d9c202dbe92e958834ce3f99bd0e;hp=-c Merge branch 'profile-fields' into next --- 76e7a20f5212d9c202dbe92e958834ce3f99bd0e diff --combined src/main/resources/static/javascript/sone.js index 41a2054,8029ccc..2d6c8ec --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@@ -500,10 -500,7 +500,10 @@@ function ajaxifyPost(postElement) }); /* mark everything as known on click. */ - $(postElement).click(function() { + $(postElement).click(function(event) { + if ($(event.target).hasClass("click-to-show")) { + return false; + } markPostAsKnown(this); }); @@@ -796,7 -793,6 +796,7 @@@ function markPostAsKnown(postElements) (function(postElement) { $.getJSON("markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) { $(postElement).removeClass("new"); + $(".click-to-show", postElement).removeClass("new"); }); })(postElement); } @@@ -866,6 -862,80 +866,80 @@@ function showNotificationDetails(notifi $("#sone .notification#" + notificationId + " .short-text").hide(); } + /** + * Deletes the field with the given ID from the profile. + * + * @param fieldId + * The ID of the field to delete + */ + function deleteProfileField(fieldId) { + $.getJSON("deleteProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId}, function(data, textStatus) { + if (data && data.success) { + $("#sone .profile-field#" + data.field.id).slideUp(); + } + }); + } + + /** + * Renames a profile field. + * + * @param fieldId + * The ID of the field to rename + * @param newName + * The new name of the field + * @param successFunction + * Called when the renaming was successful + */ + function editProfileField(fieldId, newName, successFunction) { + $.getJSON("editProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId, "name": newName}, function(data, textStatus) { + if (data && data.success) { + 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 //