mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
some pagination work
This commit is contained in:
@@ -528,6 +528,10 @@ var socket,
|
|||||||
});
|
});
|
||||||
|
|
||||||
templates.setGlobal('relative_path', RELATIVE_PATH);
|
templates.setGlobal('relative_path', RELATIVE_PATH);
|
||||||
|
templates.setGlobal('usePagination', config.usePagination);
|
||||||
|
templates.setGlobal('topicsPerPage', config.topicsPerPage);
|
||||||
|
templates.setGlobal('postsPerPage', config.postsPerPage);
|
||||||
|
console.log(templates.globals);
|
||||||
});
|
});
|
||||||
|
|
||||||
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
|
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ define(['composer'], function(composer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function enableInfiniteLoading() {
|
function enableInfiniteLoading() {
|
||||||
|
if(!config.usePagination) {
|
||||||
$(window).off('scroll').on('scroll', function() {
|
$(window).off('scroll').on('scroll', function() {
|
||||||
var bottom = ($(document).height() - $(window).height()) * 0.9;
|
var bottom = ($(document).height() - $(window).height()) * 0.9;
|
||||||
|
|
||||||
@@ -364,6 +365,17 @@ define(['composer'], function(composer) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
$('.pagination .previous').on('click', function() {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.pagination .next').on('click', function() {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.topic').on('click', '.post_reply', function() {
|
$('.topic').on('click', '.post_reply', function() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<li><a href="#email" data-toggle="tab">Email</a></li>
|
<li><a href="#email" data-toggle="tab">Email</a></li>
|
||||||
<li><a href="#user" data-toggle="tab">User</a></li>
|
<li><a href="#user" data-toggle="tab">User</a></li>
|
||||||
<li><a href="#post" data-toggle="tab">Post</a></li>
|
<li><a href="#post" data-toggle="tab">Post</a></li>
|
||||||
|
<li><a href="#pagination" data-toggle="tab">Pagination</a></li>
|
||||||
<li><a href="#web-crawler" data-toggle="tab">Web Crawler</a></li>
|
<li><a href="#web-crawler" data-toggle="tab">Web Crawler</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -133,6 +134,21 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="pagination">
|
||||||
|
<form>
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" data-field="usePagination"> <strong>Paginate topics and posts instead of using infinite scroll.</strong>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<strong>Topics per Page</strong><br /> <input type="text" class="form-control" value="20" data-field="topicsPerPage"><br />
|
||||||
|
<strong>Posts per Page</strong><br /> <input type="text" class="form-control" value="20" data-field="postsPerPage"><br />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane" id="web-crawler">
|
<div class="tab-pane" id="web-crawler">
|
||||||
<form>
|
<form>
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
|
|||||||
@@ -201,6 +201,13 @@
|
|||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- {usePagination} -->
|
||||||
|
<ul class="pager">
|
||||||
|
<li class="previous"><a href="#">← Older</a></li>
|
||||||
|
<li class="next"><a href="#">Newer →</a></li>
|
||||||
|
</ul>
|
||||||
|
<!-- {usePagination} -->
|
||||||
|
|
||||||
<div id="move_thread_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="Move Topic" aria-hidden="true">
|
<div id="move_thread_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="Move Topic" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ var path = require('path'),
|
|||||||
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
|
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
|
||||||
config.allowGuestPosting = parseInt(meta.config.allowGuestPosting, 10) === 1;
|
config.allowGuestPosting = parseInt(meta.config.allowGuestPosting, 10) === 1;
|
||||||
config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1;
|
config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1;
|
||||||
|
config.usePagination = parseInt(meta.config.usePagination, 10) === 1;
|
||||||
|
config.topicsPerPage = meta.config.topicsPerPage || 20;
|
||||||
|
config.postsPerPage = meta.config.postsPerPage || 20;
|
||||||
config.maximumFileSize = meta.config.maximumFileSize;
|
config.maximumFileSize = meta.config.maximumFileSize;
|
||||||
config.emailSetup = !!meta.config['email:from'];
|
config.emailSetup = !!meta.config['email:from'];
|
||||||
config.defaultLang = meta.config.defaultLang || 'en';
|
config.defaultLang = meta.config.defaultLang || 'en';
|
||||||
@@ -161,12 +164,16 @@ var path = require('path'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/topic/:id/:slug?', function (req, res, next) {
|
app.get('/topic/:id/:slug?', function (req, res, next) {
|
||||||
|
console.log(req.query);
|
||||||
var uid = (req.user) ? req.user.uid : 0;
|
var uid = (req.user) ? req.user.uid : 0;
|
||||||
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
||||||
if (privileges.read) {
|
if (privileges.read) {
|
||||||
topics.getTopicWithPosts(req.params.id, uid, 0, 10, false, function (err, data) {
|
var postsPerPage = meta.config.postsPerPage ? (meta.config.postsPerPage - 1) : 20;
|
||||||
if (!err) {
|
topics.getTopicWithPosts(req.params.id, uid, 0, postsPerPage, false, function (err, data) {
|
||||||
// Send in privilege data as well
|
if(err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
data.privileges = privileges;
|
data.privileges = privileges;
|
||||||
|
|
||||||
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
||||||
@@ -174,7 +181,6 @@ var path = require('path'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.json(data);
|
res.json(data);
|
||||||
} else next();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.send(403);
|
res.send(403);
|
||||||
|
|||||||
Reference in New Issue
Block a user