This commit is contained in:
barisusakli
2014-08-05 18:18:34 -04:00
parent d4dc716acd
commit f49c95c16f
3 changed files with 19 additions and 24 deletions

View File

@@ -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');
}
});
}
});