From cf39c660173a976bbd1f4a883c8a772daac92801 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 24 Jan 2014 13:27:36 -0500 Subject: [PATCH 01/28] some pagination work --- public/src/app.js | 4 ++++ public/src/forum/topic.js | 28 ++++++++++++++++++++-------- public/templates/admin/settings.tpl | 16 ++++++++++++++++ public/templates/topic.tpl | 7 +++++++ src/routes/api.js | 24 +++++++++++++++--------- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index bc583e2b17..c6ad9c7305 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -528,6 +528,10 @@ var socket, }); 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; diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index a48d8c82cf..62ded4c4ce 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -355,15 +355,27 @@ define(['composer'], function(composer) { }); function enableInfiniteLoading() { - $(window).off('scroll').on('scroll', function() { - var bottom = ($(document).height() - $(window).height()) * 0.9; + if(!config.usePagination) { + $(window).off('scroll').on('scroll', function() { + var bottom = ($(document).height() - $(window).height()) * 0.9; - if ($(window).scrollTop() > bottom && !infiniteLoaderActive && $('#post-container').children().length) { - loadMorePosts(tid, function(posts) { - fixDeleteStateForPosts(); - }); - } - }); + if ($(window).scrollTop() > bottom && !infiniteLoaderActive && $('#post-container').children().length) { + loadMorePosts(tid, function(posts) { + fixDeleteStateForPosts(); + }); + } + }); + } else { + $('.pagination .previous').on('click', function() { + + return false; + }); + + $('.pagination .next').on('click', function() { + + return false; + }); + } } $('.topic').on('click', '.post_reply', function() { diff --git a/public/templates/admin/settings.tpl b/public/templates/admin/settings.tpl index 8ddd896da9..3601f7c2ca 100644 --- a/public/templates/admin/settings.tpl +++ b/public/templates/admin/settings.tpl @@ -7,6 +7,7 @@
  • Email
  • User
  • Post
  • +
  • Pagination
  • Web Crawler
  • @@ -133,6 +134,21 @@ + +
    diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index ec72ff958b..1aabe3c8c0 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -201,6 +201,13 @@
    + + + +