v1.18.x
barisusakli 10 years ago
commit 6d77215f80

@ -49,7 +49,7 @@
"nodebb-plugin-spam-be-gone": "0.4.2", "nodebb-plugin-spam-be-gone": "0.4.2",
"nodebb-rewards-essentials": "0.0.5", "nodebb-rewards-essentials": "0.0.5",
"nodebb-theme-lavender": "2.0.5", "nodebb-theme-lavender": "2.0.5",
"nodebb-theme-persona": "3.0.24", "nodebb-theme-persona": "3.0.25",
"nodebb-theme-vanilla": "4.0.16", "nodebb-theme-vanilla": "4.0.16",
"nodebb-widget-essentials": "2.0.2", "nodebb-widget-essentials": "2.0.2",
"npm": "^2.1.4", "npm": "^2.1.4",

@ -57,6 +57,8 @@ define('forum/topic', [
addBlockQuoteHandler(); addBlockQuoteHandler();
addParentHandler();
handleBookmark(tid); handleBookmark(tid);
handleKeys(); handleKeys();
@ -191,6 +193,11 @@ define('forum/topic', [
}); });
} }
function addParentHandler() {
components.get('topic').on('click', '[component="post/parent"]', function() {
navigator.scrollToPost(parseInt(this.getAttribute('data-index'), 10), true);
});
}
function enableInfiniteLoadingOrPagination() { function enableInfiniteLoadingOrPagination() {
if (!config.usePagination) { if (!config.usePagination) {

@ -95,18 +95,17 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
index = parseInt($(navigator.selector).first().attr('data-index'), 10); index = parseInt($(navigator.selector).first().attr('data-index'), 10);
$(navigator.selector).each(function() { $(navigator.selector).each(function() {
var el = $(this);
index++; index++;
if (el.offset().top > middleOfViewport) { if ($(this).offset().top > middleOfViewport) {
return false; return false;
} }
}); });
if (typeof navigator.callback === 'function') { if (typeof navigator.callback === 'function') {
navigator.callback(index, count); navigator.callback(index, count);
navigator.updateTextAndProgressBar();
} }
navigator.updateTextAndProgressBar();
}; };
navigator.updateTextAndProgressBar = function() { navigator.updateTextAndProgressBar = function() {

@ -112,6 +112,45 @@ module.exports = function(Topics) {
}, },
privileges: function(next) { privileges: function(next) {
privileges.posts.get(pids, uid, next); privileges.posts.get(pids, uid, next);
},
parents: function(next) {
var parentPids = postData.map(function(postObj) {
return postObj.hasOwnProperty('toPid') ? parseInt(postObj.toPid, 10) : null
}).filter(Boolean),
parentUids;
if (parentPids) {
async.waterfall([
async.apply(posts.getPostsFields, parentPids, ['pid', 'tid', 'uid']),
function(postsArr, next) {
// To use Posts.getUserInfoForPosts would be overkill here...
parentUids = postsArr.map(function(postObj) { return parseInt(postObj.uid, 10); }).filter(function(uid, idx, users) {
return users.indexOf(uid) === idx;
});
user.getUsersFields(parentUids, ['username'], function(err, userDataArr) {
var userData = {};
userDataArr.forEach(function(user) {
userData[user.uid] = user;
});
next(err, postsArr, userData);
});
},
function(postsArr, userData, next) {
var returnData = {};
posts.getPostIndices(postsArr, uid, function(err, indices) {
postsArr.forEach(function(post, idx) {
var pid = parseInt(post.pid, 10);
returnData[pid] = _.clone(userData[parseInt(post.uid, 10)]);
returnData[pid].index = indices[idx]+0;
});
next(err, returnData);
});
}
], next);
} else {
next();
}
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
@ -130,6 +169,7 @@ module.exports = function(Topics) {
postObj.display_moderator_tools = results.privileges[i].editable; postObj.display_moderator_tools = results.privileges[i].editable;
postObj.display_move_tools = results.privileges[i].move && postObj.index !== 0; postObj.display_move_tools = results.privileges[i].move && postObj.index !== 0;
postObj.selfPost = parseInt(uid, 10) === parseInt(postObj.uid, 10); postObj.selfPost = parseInt(uid, 10) === parseInt(postObj.uid, 10);
postObj.parent = results.parents[parseInt(postObj.toPid, 10)];
if(postObj.deleted && !results.privileges[i].view_deleted) { if(postObj.deleted && !results.privileges[i].view_deleted) {
postObj.content = '[[topic:post_is_deleted]]'; postObj.content = '[[topic:post_is_deleted]]';

Loading…
Cancel
Save