Merge branch 'profile-fields' into next
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 14:48:28 +0000 (15:48 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 15 Jan 2011 14:48:28 +0000 (15:48 +0100)
1  2 
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
  //