mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
fixes to category pagination
This commit is contained in:
@@ -104,7 +104,12 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
|
|
||||||
addActiveUser(data);
|
addActiveUser(data);
|
||||||
|
|
||||||
|
socket.emit('categories.getPageCount', templates.get('category_id'), function(err, newPageCount) {
|
||||||
|
pagination.recreatePaginationLinks('category', newPageCount);
|
||||||
|
});
|
||||||
|
|
||||||
$('#topics-container span.timeago').timeago();
|
$('#topics-container span.timeago').timeago();
|
||||||
|
app.createUserTooltips();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +148,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#topics-container span.timeago').timeago();
|
$('#topics-container span.timeago').timeago();
|
||||||
|
app.createUserTooltips();
|
||||||
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ define(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pagination.recreatePaginationLinks = function(newPageCount) {
|
pagination.recreatePaginationLinks = function(template, newPageCount) {
|
||||||
pagination.pageCount = parseInt(newPageCount);
|
pagination.pageCount = parseInt(newPageCount, 10);
|
||||||
|
|
||||||
var pages = [];
|
var pages = [];
|
||||||
for(var i=1; i<=pagination.page; ++i) {
|
for(var i=1; i<=pagination.pageCount; ++i) {
|
||||||
pages.push({pageNumber: i});
|
pages.push({pageNumber: i});
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = templates.prepare(templates['topic'].blocks['pages']).parse({pages:pages});
|
var html = templates.prepare(templates[template].blocks['pages']).parse({pages:pages});
|
||||||
html = $(html);
|
html = $(html);
|
||||||
$('.pagination li.page').remove();
|
$('.pagination li.page').remove();
|
||||||
html.insertAfter($('.pagination li.previous'));
|
html.insertAfter($('.pagination li.previous'));
|
||||||
@@ -60,6 +60,12 @@ define(function() {
|
|||||||
|
|
||||||
|
|
||||||
function updatePageLinks() {
|
function updatePageLinks() {
|
||||||
|
if(pagination.pageCount === 0) {
|
||||||
|
$('.pagination').addClass('hide');
|
||||||
|
} else {
|
||||||
|
$('.pagination').removeClass('hide');
|
||||||
|
}
|
||||||
|
|
||||||
$('.pagination .next').removeClass('disabled');
|
$('.pagination .next').removeClass('disabled');
|
||||||
$('.pagination .previous').removeClass('disabled');
|
$('.pagination .previous').removeClass('disabled');
|
||||||
|
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
var posts = data.posts;
|
var posts = data.posts;
|
||||||
socket.emit('topics.getPageCount', tid, function(err, newPageCount) {
|
socket.emit('topics.getPageCount', tid, function(err, newPageCount) {
|
||||||
|
|
||||||
pagination.recreatePaginationLinks(newPageCount);
|
pagination.recreatePaginationLinks('topic', newPageCount);
|
||||||
|
|
||||||
if(pagination.currentPage === pagination.newPageCount) {
|
if(pagination.currentPage === pagination.newPageCount) {
|
||||||
createNewPosts(data);
|
createNewPosts(data);
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- ENDIF usePagination -->
|
<!-- ENDIF usePagination -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3 col-xs-12 {show_sidebar} category-sidebar">
|
<div class="col-md-3 col-xs-12 {show_sidebar} category-sidebar">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
|
<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
|
||||||
|
|||||||
@@ -38,14 +38,15 @@ SocketCategories.loadPage = function(socket, data, callback) {
|
|||||||
var start = (data.page - 1) * topicsPerPage,
|
var start = (data.page - 1) * topicsPerPage,
|
||||||
end = start + topicsPerPage - 1;
|
end = start + topicsPerPage - 1;
|
||||||
|
|
||||||
console.log('start to end' ,start, end);
|
|
||||||
|
|
||||||
categories.getCategoryTopics(data.cid, start, end, socket.uid, function(err, topics) {
|
categories.getCategoryTopics(data.cid, start, end, socket.uid, function(err, topics) {
|
||||||
console.log('getting topics', topics.length);
|
|
||||||
callback(err, {
|
callback(err, {
|
||||||
topics: topics
|
topics: topics
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SocketCategories.getPageCount = function(socket, cid, callback) {
|
||||||
|
categories.getPageCount(cid, callback);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = SocketCategories;
|
module.exports = SocketCategories;
|
||||||
Reference in New Issue
Block a user