|
|
|
@ -15,6 +15,8 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|
|
|
|
share.addShareHandlers(topicName);
|
|
|
|
|
|
|
|
|
|
addFavouriteHandler();
|
|
|
|
|
|
|
|
|
|
addVoteHandler();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PostTools.toggle = function(pid, isDeleted) {
|
|
|
|
@ -37,30 +39,42 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|
|
|
|
|
|
|
|
|
function addFavouriteHandler() {
|
|
|
|
|
$('#post-container').on('mouseenter', '.favourite-tooltip', function() {
|
|
|
|
|
if (!$(this).data('users-loaded')) {
|
|
|
|
|
$(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) {
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
loadDataAndCreateTooltip($(this), 'posts.getFavouritedUsers');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addVoteHandler() {
|
|
|
|
|
$('#post-container').on('mouseenter', '.post-row .votes', function() {
|
|
|
|
|
loadDataAndCreateTooltip($(this), 'posts.getUpvoters');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadDataAndCreateTooltip(el, method) {
|
|
|
|
|
var pid = el.parents('.post-row').attr('data-pid');
|
|
|
|
|
socket.emit(method, pid, function(err, usernames) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
createTooltip(el, usernames);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createTooltip(el, usernames) {
|
|
|
|
|
if (!usernames.length) {
|
|
|
|
|
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('destroy').tooltip('show');
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
usernames = usernames.join(', ');
|
|
|
|
|
el.attr('title', usernames).tooltip('destroy').tooltip('show');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addPostHandlers(tid, threadState) {
|
|
|
|
|
$('.topic').on('click', '.post_reply', function() {
|
|
|
|
|
if (!threadState.locked) {
|
|
|
|
|