mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
closes #1950
This commit is contained in:
@@ -105,6 +105,7 @@
|
|||||||
"more_users_and_guests": "%1 more user(s) and %2 guest(s)",
|
"more_users_and_guests": "%1 more user(s) and %2 guest(s)",
|
||||||
"more_users": "%1 more user(s)",
|
"more_users": "%1 more user(s)",
|
||||||
"more_guests": "%1 more guest(s)",
|
"more_guests": "%1 more guest(s)",
|
||||||
|
"users_and_others": "%1 and %2 others",
|
||||||
|
|
||||||
"sort_by": "Sort by",
|
"sort_by": "Sort by",
|
||||||
"oldest_to_newest": "Oldest to Newest",
|
"oldest_to_newest": "Oldest to Newest",
|
||||||
|
|||||||
@@ -36,13 +36,26 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
};
|
};
|
||||||
|
|
||||||
function addFavouriteHandler() {
|
function addFavouriteHandler() {
|
||||||
$('#post-container').on('mouseenter', '.favourite-tooltip', function(e) {
|
$('#post-container').on('mouseenter', '.favourite-tooltip', function() {
|
||||||
if (!$(this).data('users-loaded')) {
|
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 pid = $(this).parents('.post-row').attr('data-pid');
|
||||||
var el = $(this).attr('title', "Loading...");
|
var el = $(this).attr('title', "Loading...");
|
||||||
socket.emit('posts.getFavouritedUsers', pid, function(err, usernames) {
|
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');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -241,37 +241,18 @@ SocketPosts.getPrivileges = function(socket, pid, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
|
SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
|
||||||
|
|
||||||
favourites.getFavouritedUidsByPids([pid], function(err, data) {
|
favourites.getFavouritedUidsByPids([pid], function(err, data) {
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Array.isArray(data) || !data.length) {
|
if(!Array.isArray(data) || !data.length) {
|
||||||
callback(null, "");
|
callback(null, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
var max = 5; //hardcoded
|
|
||||||
var finalText = "";
|
|
||||||
|
|
||||||
var pid_uids = data[0];
|
var pid_uids = data[0];
|
||||||
var rest_amount = 0;
|
|
||||||
|
|
||||||
if (pid_uids.length > max) {
|
user.getUsernamesByUids(pid_uids, callback);
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user