From ad54030fb89a0b74a7096e350c5428f884d28ffe Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 4 Nov 2010 11:50:03 +0100 Subject: [PATCH] Update the list of Sones that like a post or reply after liking/unliking. --- src/main/resources/static/javascript/sone.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 1d45493..695503c 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -250,6 +250,25 @@ function getSoneElement(element) { } /** + * Generates a list of Sones by concatening the names of the given sones with a + * new line character (“\n”). + * + * @param sones + * The sones to format + * @returns {String} The created string + */ +function generateSoneList(sones) { + var soneList = ""; + $.each(sones, function() { + if (soneList != "") { + soneList += "\n"; + } + soneList += this.name; + }); + return soneList; +} + +/** * Returns the ID of the Sone that this element belongs to. * * @param element @@ -297,6 +316,7 @@ function updatePostLikes(postId) { if (data.success) { $("#sone .post#" + postId + " > .status-line .likes").toggleClass("hidden", data.likes == 0) $("#sone .post#" + postId + " > .status-line .likes span.like-count").text(data.likes); + $("#sone .post#" + postId + " > .status-line .likes > span").attr("title", generateSoneList(data.sones)); } }); } @@ -322,6 +342,7 @@ function updateReplyLikes(replyId) { if (data.success) { $("#sone .reply#" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0) $("#sone .reply#" + replyId + " .status-line .likes span.like-count").text(data.likes); + $("#sone .reply#" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones)); } }); } -- 2.7.4