v1.18.x
barisusakli 10 years ago
parent c305cd8220
commit fbcc7c4bc3

@ -20,16 +20,14 @@ define('forum/pagination', function() {
}; };
pagination.loadPage = function(page, callback) { pagination.loadPage = function(page, callback) {
callback = callback || function() {};
page = parseInt(page, 10); page = parseInt(page, 10);
if(!utils.isNumber(page) || page < 1 || page > pagination.pageCount) { if (!utils.isNumber(page) || page < 1 || page > pagination.pageCount) {
callback(false);
return false; return false;
} }
var url = window.location.pathname.slice(1).split('/').slice(0, 3).join('/') + '?page=' + page;
ajaxify.go(window.location.pathname.slice(1) + '?page=' + page, function() { ajaxify.go(url, callback);
if (typeof callback === 'function') {
callback();
}
});
return true; return true;
}; };

@ -31,11 +31,18 @@ define('forum/topic/posts', [
}; };
function onNewPostPagination(data) { function onNewPostPagination(data) {
function scrollToPost() {
navigator.scrollBottom(data.posts[0].index);
}
var posts = data.posts; var posts = data.posts;
pagination.pageCount = Math.max(1, Math.ceil((posts[0].topic.postcount - 1) / config.postsPerPage));
if (pagination.currentPage === pagination.pageCount) { if (pagination.currentPage === pagination.pageCount) {
createNewPosts(data); createNewPosts(data, scrollToPost);
} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.user.uid, 10)) { } else if (parseInt(posts[0].uid, 10) === parseInt(app.user.uid, 10)) {
pagination.loadPage(pagination.pageCount); pagination.loadPage(pagination.pageCount, scrollToPost);
} }
} }

@ -243,7 +243,7 @@ module.exports = function(Topics) {
posts.getUserInfoForPosts([postData.uid], uid, next); posts.getUserInfoForPosts([postData.uid], uid, next);
}, },
topicInfo: function(next) { topicInfo: function(next) {
Topics.getTopicFields(tid, ['tid', 'title', 'slug', 'cid'], next); Topics.getTopicFields(tid, ['tid', 'title', 'slug', 'cid', 'postcount'], next);
}, },
settings: function(next) { settings: function(next) {
user.getSettings(uid, next); user.getSettings(uid, next);

Loading…
Cancel
Save