From abd909d23bdf7b403ed4648459252d0a6ae7b22f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 4 Sep 2013 04:50:45 +0800 Subject: [PATCH 1/5] pagination - scroll to top / bottom arrows --- public/css/header.less | 2 +- public/src/ajaxify.js | 2 +- public/src/app.js | 12 ++++++++++++ public/src/forum/topic.js | 14 ++++++++------ public/templates/header.tpl | 6 +++++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/public/css/header.less b/public/css/header.less index 055de41461..36ca50ca74 100644 --- a/public/css/header.less +++ b/public/css/header.less @@ -18,7 +18,7 @@ -#pagination { +.pagination-block { position: absolute; background: rgb(34, 34, 34); right: 0px; diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 370894927b..e25ceab420 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -33,7 +33,7 @@ var ajaxify = {}; app.enter_room('global'); pagination = pagination || document.getElementById('pagination'); - if (pagination) pagination.style.display = 'none'; + if (pagination) pagination.parentNode.style.display = 'none'; window.onscroll = null; // end diff --git a/public/src/app.js b/public/src/app.js index 2604f78608..3130e1cbe2 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -374,6 +374,18 @@ var socket, }); } + app.scrollToTop = function() { + $('body,html').animate({ + scrollTop: 0 + }); + }; + + app.scrollToBottom = function() { + $('body,html').animate({ + scrollTop: $('html').height() - 100 + }); + } + app.scrollToPost = function(pid) { if(!pid) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 752d703f87..7d9719fd9a 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -620,16 +620,16 @@ postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info'); pagination = pagination || document.getElementById('pagination'); - pagination.style.display = 'block'; + pagination.parentNode.style.display = 'block'; var windowHeight = jQuery(window).height(); var scrollTop = jQuery(window).scrollTop(); var scrollBottom = scrollTop + windowHeight; - if (scrollTop < 50) { + if (scrollTop < 50 && postcount > 1) { postAuthorImage.src = (jQuery('.main-avatar img').attr('src')); postAuthorInfo.innerHTML = 'Posted by ' + jQuery('.main-post').attr('data-username') + ', ' + jQuery('.main-post').find('.relativeTimeAgo').html(); - pagination.innerHTML = '0 / ' + postcount; + pagination.innerHTML = '0 out of ' + postcount; return; } @@ -657,9 +657,11 @@ } }); - if(scrollTop + windowHeight == jQuery(document).height()) { - pagination.innerHTML = postcount + ' / ' + postcount; - } + setTimeout(function() { + if(scrollTop + windowHeight == jQuery(document).height()) { + pagination.innerHTML = postcount + ' / ' + postcount; + } + }, 100); } window.onscroll = updateHeader; diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 710f943560..5b9a0d328d 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -82,7 +82,11 @@ - +
+ + + +
From 45e24c54cebf799955beafd30a5f849c01fcc0ba Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 4 Sep 2013 06:01:23 +0800 Subject: [PATCH 2/5] pagination scroll block fix + cleanup --- public/src/forum/topic.js | 13 +++++++++++-- public/templates/header.tpl | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 7d9719fd9a..5d66ae74bc 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -615,6 +615,15 @@ var postcount = templates.get('postcount'); function updateHeader() { + if (pagination == null) { + jQuery('.pagination-block i:first').on('click', function() { + app.scrollToTop(); + }); + jQuery('.pagination-block i:last').on('click', function() { + app.scrollToBottom(); + }); + } + jQuery('.post-author-info').css('bottom', '0px'); postAuthorImage = postAuthorImage || document.getElementById('post-author-image'); postAuthorInfo = postAuthorInfo || document.getElementById('post-author-info'); @@ -651,7 +660,7 @@ if (inView) { - pagination.innerHTML = this.postnumber + ' / ' + postcount; + pagination.innerHTML = this.postnumber + ' out of ' + postcount; postAuthorImage.src = (jQuery(this).find('.profile-image-block img').attr('src')); postAuthorInfo.innerHTML = 'Posted by ' + jQuery(this).attr('data-username') + ', ' + jQuery(this).find('.relativeTimeAgo').html(); } @@ -659,7 +668,7 @@ setTimeout(function() { if(scrollTop + windowHeight == jQuery(document).height()) { - pagination.innerHTML = postcount + ' / ' + postcount; + pagination.innerHTML = postcount + ' out of ' + postcount; } }, 100); } diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 5b9a0d328d..4f979af747 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -83,9 +83,9 @@
- + - +
From 1d52557562a72f7d56058c69c748fe805d5e2537 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 3 Sep 2013 22:03:04 -0400 Subject: [PATCH 3/5] removing hook ordering message from non-development runs --- src/plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins.js b/src/plugins.js index 839c58bb85..c5f9e1fffd 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -33,7 +33,7 @@ var fs = require('fs'), } else next(); }, function(next) { - winston.info('[plugins] Sorting hooks to fire in priority sequence'); + if (global.env === 'development') winston.info('[plugins] Sorting hooks to fire in priority sequence'); Object.keys(_self.loadedHooks).forEach(function(hook) { var hooks = _self.loadedHooks[hook]; hooks = hooks.sort(function(a, b) { From 418700ce3f8e397ae4d9448fb055ed69d1b09770 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 3 Sep 2013 22:21:56 -0400 Subject: [PATCH 4/5] changing info to warn when config file not found --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index eade1bbb3c..eb241c8170 100644 --- a/app.js +++ b/app.js @@ -134,7 +134,7 @@ if(nconf.get('upgrade')) { } else { // New install, ask setup questions if (nconf.get('setup')) winston.info('NodeBB Setup Triggered via Command Line'); - else winston.info('Configuration not found, starting NodeBB setup'); + else winston.warn('Configuration not found, starting NodeBB setup'); var install = require('./src/install'); From ca72a4b0fc2ab77fb90b9ca258a5437f5e8efd27 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 4 Sep 2013 12:13:36 -0400 Subject: [PATCH 5/5] fixed comma to semicolon --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index eb241c8170..a6cfa0e264 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,7 @@ var fs = require('fs'), meta = require('./src/meta.js'); // Runtime environment -global.env = process.env.NODE_ENV || 'production', +global.env = process.env.NODE_ENV || 'production'; @@ -39,7 +39,7 @@ winston.add(winston.transports.Console, { winston.add(winston.transports.File, { filename:'error.log', level:'error' -}) +}); // TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed winston.err = function(err) {