Skip to content

Node.js based forum software built for the modern web

user search paginator

barisusaklied714cdf7700
diff --git a/public/src/client/users.js b/public/src/client/users.js
index 6030f415b5..b96f3f5501 100644
--- a/public/src/client/users.js
+++ b/public/src/client/users.js
@@ -100,7 +100,7 @@ define('forum/users', function() {
doSearch();
});
- $('.pagination').on('click', 'a', function() {
+ $('.users').on('click', '.pagination a', function() {
doSearch($(this).attr('data-page'));
return false;
})
@@ -150,9 +150,9 @@ define('forum/users', function() {
return reset();
}
- templates.parse('users', 'pages', data, function(html) {
- $('.pagination').html(html);
- });
+ templates.parse('partials/paginator', {pagination: data.pagination}, function(html) {
+ $('.pagination-container').replaceWith(html);
+ })
templates.parse('users', 'users', data, function(html) {
translator.translate(html, function(translated) {
diff --git a/src/user/search.js b/src/user/search.js
index a95b64bfaa..bad43be25b 100644
--- a/src/user/search.js
+++ b/src/user/search.js
@@ -4,6 +4,7 @@
var async = require('async'),
meta = require('../meta'),
user = require('../user'),
+ pagination = require('../pagination'),
db = require('../database');
module.exports = function(User) {
@@ -49,23 +50,19 @@ module.exports = function(User) {
},
function(userData, next) {
- var pages = [];
- if (matchCount > resultsPerPage) {
- pageCount = Math.ceil(matchCount / resultsPerPage);
- var currentPage = Math.max(1, Math.ceil((start + 1) / resultsPerPage));
- for(var i=1; i<=pageCount; ++i) {
- pages.push({page: i, active: i === currentPage});
- }
- }
-
var diff = process.hrtime(startTime);
var timing = (diff[0] * 1e3 + diff[1] / 1e6).toFixed(1);
- next(null, {
+ var data = {
timing: timing,
users: userData,
- matchCount: matchCount,
- pages: pages
- });
+ matchCount: matchCount
+ };
+
+ var currentPage = Math.max(1, Math.ceil((start + 1) / resultsPerPage));
+ pageCount = Math.ceil(matchCount / resultsPerPage);
+ pagination.create(currentPage, pageCount, data);
+
+ next(null, data);
}
], callback);
};