mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #3677
This commit is contained in:
@@ -48,9 +48,9 @@
|
|||||||
"nodebb-plugin-soundpack-default": "0.1.4",
|
"nodebb-plugin-soundpack-default": "0.1.4",
|
||||||
"nodebb-plugin-spam-be-gone": "0.4.2",
|
"nodebb-plugin-spam-be-gone": "0.4.2",
|
||||||
"nodebb-rewards-essentials": "0.0.5",
|
"nodebb-rewards-essentials": "0.0.5",
|
||||||
"nodebb-theme-lavender": "2.0.2",
|
"nodebb-theme-lavender": "2.0.3",
|
||||||
"nodebb-theme-persona": "3.0.22",
|
"nodebb-theme-persona": "3.0.23",
|
||||||
"nodebb-theme-vanilla": "4.0.14",
|
"nodebb-theme-vanilla": "4.0.15",
|
||||||
"nodebb-widget-essentials": "2.0.1",
|
"nodebb-widget-essentials": "2.0.1",
|
||||||
"npm": "^2.1.4",
|
"npm": "^2.1.4",
|
||||||
"passport": "^0.3.0",
|
"passport": "^0.3.0",
|
||||||
|
|||||||
@@ -17,13 +17,14 @@ define('forum/infinitescroll', ['translator'], function(translator) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onScroll() {
|
function onScroll() {
|
||||||
var top = $(window).height() * 0.3 + topOffset,
|
var currentScrollTop = $(window).scrollTop();
|
||||||
bottom = ($(document).height() - $(window).height()) * 0.85,
|
var scrollPercent = 100 * currentScrollTop / ($(document).height() - $(window).height());
|
||||||
currentScrollTop = $(window).scrollTop();
|
|
||||||
|
|
||||||
if (currentScrollTop < top && currentScrollTop < previousScrollTop) {
|
var top = 20, bottom = 80;
|
||||||
|
|
||||||
|
if (scrollPercent < top && currentScrollTop < previousScrollTop) {
|
||||||
callback(-1);
|
callback(-1);
|
||||||
} else if (currentScrollTop > bottom && currentScrollTop > previousScrollTop) {
|
} else if (scrollPercent > bottom && currentScrollTop > previousScrollTop) {
|
||||||
callback(1);
|
callback(1);
|
||||||
}
|
}
|
||||||
previousScrollTop = currentScrollTop;
|
previousScrollTop = currentScrollTop;
|
||||||
|
|||||||
@@ -246,7 +246,9 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
|||||||
function getUserName(button) {
|
function getUserName(button) {
|
||||||
var username = '',
|
var username = '',
|
||||||
post = button.parents('[data-pid]');
|
post = button.parents('[data-pid]');
|
||||||
|
if (button.attr('component') === 'topic/reply') {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
if (post.length) {
|
if (post.length) {
|
||||||
username = post.attr('data-username').replace(/\s/g, '-');
|
username = post.attr('data-username').replace(/\s/g, '-');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,16 @@ define('forum/topic/posts', [
|
|||||||
data.posts.forEach(function(post) {
|
data.posts.forEach(function(post) {
|
||||||
var p = components.get('post', 'pid', post.pid);
|
var p = components.get('post', 'pid', post.pid);
|
||||||
if (p.hasClass('new')) {
|
if (p.hasClass('new')) {
|
||||||
p.remove()
|
p.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
data.posts = data.posts.filter(function(post) {
|
data.posts = data.posts.filter(function(post) {
|
||||||
|
if (components.get('post', 'pid', post.pid).length !== 0) {
|
||||||
|
console.log('removed', post.pid)
|
||||||
|
}
|
||||||
|
|
||||||
return components.get('post', 'pid', post.pid).length === 0;
|
return components.get('post', 'pid', post.pid).length === 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -141,17 +146,18 @@ define('forum/topic/posts', [
|
|||||||
} else if (before) {
|
} else if (before) {
|
||||||
// Save document height and position for future reference (about 5 lines down)
|
// Save document height and position for future reference (about 5 lines down)
|
||||||
var height = $(document).height(),
|
var height = $(document).height(),
|
||||||
scrollTop = $(document).scrollTop();
|
scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
// Insert the new post
|
|
||||||
html.insertBefore(before);
|
html.insertBefore(before);
|
||||||
|
|
||||||
// Now restore the relative position the user was on prior to new post insertion
|
// Now restore the relative position the user was on prior to new post insertion
|
||||||
$(document).scrollTop(scrollTop + ($(document).height() - height));
|
$(window).scrollTop(scrollTop + ($(document).height() - height));
|
||||||
} else {
|
} else {
|
||||||
components.get('topic').append(html);
|
components.get('topic').append(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeExtraPosts(direction);
|
||||||
|
|
||||||
html.hide().fadeIn('slow');
|
html.hide().fadeIn('slow');
|
||||||
|
|
||||||
var pids = [];
|
var pids = [];
|
||||||
@@ -165,6 +171,23 @@ define('forum/topic/posts', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeExtraPosts(direction) {
|
||||||
|
var posts = components.get('post');
|
||||||
|
if (posts.length > 40) {
|
||||||
|
var removeCount = posts.length - 40;
|
||||||
|
if (direction > 0) {
|
||||||
|
var height = $(document).height(),
|
||||||
|
scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
|
posts.slice(0, removeCount).remove();
|
||||||
|
|
||||||
|
$(window).scrollTop(scrollTop + ($(document).height() - height));
|
||||||
|
} else {
|
||||||
|
posts.slice(posts.length - removeCount).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onNewPostsLoaded(html, pids) {
|
function onNewPostsLoaded(html, pids) {
|
||||||
if (app.user.uid) {
|
if (app.user.uid) {
|
||||||
socket.emit('posts.getPrivileges', pids, function(err, privileges) {
|
socket.emit('posts.getPrivileges', pids, function(err, privileges) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ define('components', function() {
|
|||||||
|
|
||||||
components.core = {
|
components.core = {
|
||||||
'post': function(name, value) {
|
'post': function(name, value) {
|
||||||
return $('[data-' + name + '="' + value + '"]');
|
return $('[component="post"][data-' + name + '="' + value + '"]');
|
||||||
},
|
},
|
||||||
'post/content': function(pid) {
|
'post/content': function(pid) {
|
||||||
return components.core.post('pid', pid).find('[component="post/content"]');
|
return components.core.post('pid', pid).find('[component="post/content"]');
|
||||||
|
|||||||
@@ -34,19 +34,23 @@ module.exports = function(SocketTopics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var set = 'tid:' + data.tid + ':posts';
|
var set = 'tid:' + data.tid + ':posts';
|
||||||
|
if (results.settings.topicPostSort === 'most_votes') {
|
||||||
|
set = 'tid:' + data.tid + ':posts:votes';
|
||||||
|
}
|
||||||
var reverse = results.settings.topicPostSort === 'newest_to_oldest' || results.settings.topicPostSort === 'most_votes';
|
var reverse = results.settings.topicPostSort === 'newest_to_oldest' || results.settings.topicPostSort === 'most_votes';
|
||||||
var start = Math.max(0, parseInt(data.after, 10));
|
var start = Math.max(0, parseInt(data.after, 10));
|
||||||
|
|
||||||
var infScrollPostsPerPage = 10;
|
var infScrollPostsPerPage = 10;
|
||||||
|
|
||||||
if (data.direction === -1) {
|
if (data.direction > 0) {
|
||||||
start = start - (reverse ? -infScrollPostsPerPage : infScrollPostsPerPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
start = results.topic.postcount - 1 - start;
|
start = results.topic.postcount - start;
|
||||||
if (results.settings.topicPostSort === 'most_votes') {
|
}
|
||||||
set = 'tid:' + data.tid + ':posts:votes';
|
} else {
|
||||||
|
if (reverse) {
|
||||||
|
start = results.topic.postcount - start - infScrollPostsPerPage - 1;
|
||||||
|
} else {
|
||||||
|
start = start - infScrollPostsPerPage - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user