mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
closes #2878
This commit is contained in:
@@ -89,8 +89,8 @@ define('forum/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.navigatorCallback = function(element, elementCount) {
|
||||
return parseInt(element.attr('data-index'), 10) + 1;
|
||||
Category.navigatorCallback = function(topIndex, bottomIndex, elementCount) {
|
||||
return bottomIndex;
|
||||
};
|
||||
|
||||
$(window).on('action:popstate', function(ev, data) {
|
||||
|
||||
@@ -148,18 +148,18 @@ define('forum/topic', [
|
||||
return index;
|
||||
};
|
||||
|
||||
Topic.navigatorCallback = function(element, elementCount) {
|
||||
Topic.navigatorCallback = function(topPostIndex, bottomPostIndex, elementCount) {
|
||||
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
||||
if (!path.startsWith('topic')) {
|
||||
return 1;
|
||||
}
|
||||
var postIndex = parseInt(element.attr('data-index'), 10);
|
||||
var index = postIndex + 1;
|
||||
var postIndex = topPostIndex;
|
||||
var index = bottomPostIndex;
|
||||
if (config.topicPostSort !== 'oldest_to_newest') {
|
||||
if (postIndex === 0) {
|
||||
if (bottomPostIndex === 0) {
|
||||
index = 1;
|
||||
} else {
|
||||
index = Math.max(elementCount - postIndex + 1, 1);
|
||||
index = Math.max(elementCount - bottomPostIndex + 2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ define('forum/topic', [
|
||||
var topicId = parts[1],
|
||||
slug = parts[2];
|
||||
var newUrl = 'topic/' + topicId + '/' + (slug ? slug : '');
|
||||
if (postIndex > 0) {
|
||||
newUrl += '/' + (postIndex + 1);
|
||||
if (postIndex > 1) {
|
||||
newUrl += '/' + postIndex;
|
||||
}
|
||||
|
||||
if (newUrl !== currentUrl) {
|
||||
|
||||
@@ -90,18 +90,26 @@ define('navigator', ['forum/pagination'], function(pagination) {
|
||||
navigator.update = function() {
|
||||
toggle(!!count);
|
||||
|
||||
$($(navigator.selector).get().reverse()).each(function() {
|
||||
var topIndex = 0;
|
||||
var bottomIndex = 0;
|
||||
$(navigator.selector).each(function() {
|
||||
var el = $(this);
|
||||
|
||||
if (elementInView(el)) {
|
||||
if (typeof navigator.callback === 'function') {
|
||||
index = navigator.callback(el, count);
|
||||
navigator.updateTextAndProgressBar();
|
||||
if (!topIndex) {
|
||||
topIndex = parseInt(el.attr('data-index'), 10) + 1;
|
||||
} else {
|
||||
bottomIndex = parseInt(el.attr('data-index'), 10) + 1;
|
||||
}
|
||||
|
||||
} else if (topIndex && bottomIndex) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof navigator.callback === 'function' && topIndex && bottomIndex) {
|
||||
index = navigator.callback(topIndex, bottomIndex, count);
|
||||
navigator.updateTextAndProgressBar();
|
||||
}
|
||||
};
|
||||
|
||||
navigator.updateTextAndProgressBar = function() {
|
||||
|
||||
@@ -50,7 +50,7 @@ define('share', function() {
|
||||
|
||||
function getPostUrl(clickedElement) {
|
||||
var parts = window.location.pathname.split('/');
|
||||
var postIndex = parseInt(clickedElement.parents('data-index').attr('data-index'), 10);
|
||||
var postIndex = parseInt(clickedElement.parents('[data-index]').attr('data-index'), 10);
|
||||
return '/' + parts[1] + '/' + parts[2] + (parts[3] ? '/' + parts[3] : '') + (postIndex ? '/' + (postIndex + 1) : '');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user