From e2d6419c38cd8258fa08cf15eb68c37b79ac3388 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 7 Apr 2011 11:13:53 +0200 Subject: [PATCH] Add method to access notification elements. --- src/main/resources/static/javascript/sone.js | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 908faf5..f6a91e4 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -380,6 +380,39 @@ function getReplyAuthor(element) { return getReplyElement(element).find(".reply-author").text(); } +/** + * Returns the notification with the given ID. + * + * @param notificationId + * The ID of the notification + * @returns The notification element + */ +function getNotification(notificationId) { + return $("#sone #notification-area .notification#" + notificationId); +} + +/** + * Returns the notification element closest to the given element. + * + * @param element + * The element to get the closest notification of + * @return The closest notification element + */ +function getNotificationElement(element) { + return $(element).closest(".notification"); +} + +/** + * Returns the ID of the notification element. + * + * @param notificationElement + * The notification element + * @returns The ID of the notification + */ +function getNotificationId(notificationElement) { + return $(notificationElement).attr("id"); +} + function likePost(postId) { $.getJSON("like.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) { if ((data == null) || !data.success) { -- 2.7.4