Node.js based forum software built for the modern web
closes #1950
barisusaklif49c95c16f29
diff --git a/public/language/en_GB/topic.json b/public/language/en_GB/topic.jsonindex 8c77751419..c6fe5bc4ad 100644--- a/public/language/en_GB/topic.json+++ b/public/language/en_GB/topic.json@@ -105,6 +105,7 @@"more_users_and_guests": "%1 more user(s) and %2 guest(s)","more_users": "%1 more user(s)","more_guests": "%1 more guest(s)",+ "users_and_others": "%1 and %2 others","sort_by": "Sort by","oldest_to_newest": "Oldest to Newest",diff --git a/public/src/forum/topic/postTools.js b/public/src/forum/topic/postTools.jsindex 24d7491fa5..b71263bc75 100644--- a/public/src/forum/topic/postTools.js+++ b/public/src/forum/topic/postTools.js@@ -36,13 +36,26 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com};function addFavouriteHandler() {- $('#post-container').on('mouseenter', '.favourite-tooltip', function(e) {+ $('#post-container').on('mouseenter', '.favourite-tooltip', function() {if (!$(this).data('users-loaded')) {- $(this).data('users-loaded', "true");+ $(this).data('users-loaded', 'true');var pid = $(this).parents('.post-row').attr('data-pid');var el = $(this).attr('title', "Loading...");socket.emit('posts.getFavouritedUsers', pid, function(err, usernames) {- el.attr('title', usernames).tooltip('show');+ if (err) {+ return;+ }+ if (usernames.length > 6) {+ var otherCount = usernames.length - 5;+ usernames = usernames.slice(0, 5).join(', ').replace(/,/g, '|');+ translator.translate('[[topic:users_and_others, ' + usernames + ', ' + otherCount + ']]', function(translated) {+ translated = translated.replace(/\|/g, ',');+ el.attr('title', translated).tooltip('show');+ });+ } else {+ usernames = usernames.join(', ');+ el.attr('title', usernames).tooltip('show');+ }});}});diff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex 9f6156c89f..9364124ff2 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -241,37 +241,18 @@ SocketPosts.getPrivileges = function(socket, pid, callback) {};SocketPosts.getFavouritedUsers = function(socket, pid, callback) {-favourites.getFavouritedUidsByPids([pid], function(err, data) {-if(err) {return callback(err);}if(!Array.isArray(data) || !data.length) {- callback(null, "");+ callback(null, []);}- var max = 5; //hardcoded- var finalText = "";-var pid_uids = data[0];- var rest_amount = 0;-- if (pid_uids.length > max) {- rest_amount = pid_uids.length - max;- pid_uids = pid_uids.slice(0, max);- }- user.getUsernamesByUids(pid_uids, function(err, usernames) {- if(err) {- return callback(err);- }-- finalText = usernames.join(', ') + (rest_amount > 0 ?- (" and " + rest_amount + (rest_amount > 1 ? " others" : " other")) : "");- callback(null, finalText);- });+ user.getUsernamesByUids(pid_uids, callback);});};