mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
search newer/older than and better pagination
This commit is contained in:
@@ -4,15 +4,14 @@ var qs = require('querystring');
|
||||
|
||||
var pagination = {};
|
||||
|
||||
pagination.create = function(currentPage, pageCount, data, queryObj) {
|
||||
pagination.create = function(currentPage, pageCount, queryObj) {
|
||||
if (pageCount <= 1) {
|
||||
data.pagination = {
|
||||
return {
|
||||
prev: {page: 1, active: currentPage > 1},
|
||||
next: {page: 1, active: currentPage < pageCount},
|
||||
rel: [],
|
||||
pages: []
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
var pagesToShow = [1];
|
||||
@@ -43,7 +42,7 @@ pagination.create = function(currentPage, pageCount, data, queryObj) {
|
||||
return {page: page, active: page === currentPage, qs: qs.stringify(queryObj)};
|
||||
});
|
||||
|
||||
data.pagination = {
|
||||
var data = {
|
||||
prev: {page: previous, active: currentPage > 1},
|
||||
next: {page: next, active: currentPage < pageCount},
|
||||
rel: [],
|
||||
@@ -51,19 +50,19 @@ pagination.create = function(currentPage, pageCount, data, queryObj) {
|
||||
};
|
||||
|
||||
if (currentPage < pageCount) {
|
||||
data.pagination.rel.push({
|
||||
data.rel.push({
|
||||
rel: 'next',
|
||||
href: '?page=' + next
|
||||
});
|
||||
}
|
||||
|
||||
if (currentPage > 1) {
|
||||
data.pagination.rel.push({
|
||||
data.rel.push({
|
||||
rel: 'prev',
|
||||
href: '?page=' + previous
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user