Add function to ajaxify a notification.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 14:48:15 +0000 (15:48 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 14:48:15 +0000 (15:48 +0100)
src/main/resources/static/javascript/sone.js

index 01c04a1..4ab0aab 100644 (file)
@@ -407,3 +407,22 @@ function getReply(replyId, callbackFunction) {
                }
        });
 }
+
+/**
+ * Ajaxifies the given notification by replacing the form with AJAX.
+ *
+ * @param notification
+ *            jQuery object representing the notification.
+ */
+function ajaxifyNotificationArea(notification) {
+       notification.find("form.dismiss").submit(function() {
+               return false;
+       });
+       notification.find("form.dismiss button").click(function() {
+               $.getJSON("ajax/dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) {
+                       if (data.success) {
+                               notification.slideUp();
+                       }
+               });
+       });
+}