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) {
|
Category.navigatorCallback = function(topIndex, bottomIndex, elementCount) {
|
||||||
return parseInt(element.attr('data-index'), 10) + 1;
|
return bottomIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
$(window).on('action:popstate', function(ev, data) {
|
$(window).on('action:popstate', function(ev, data) {
|
||||||
|
|||||||
@@ -148,18 +148,18 @@ define('forum/topic', [
|
|||||||
return index;
|
return index;
|
||||||
};
|
};
|
||||||
|
|
||||||
Topic.navigatorCallback = function(element, elementCount) {
|
Topic.navigatorCallback = function(topPostIndex, bottomPostIndex, elementCount) {
|
||||||
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
||||||
if (!path.startsWith('topic')) {
|
if (!path.startsWith('topic')) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
var postIndex = parseInt(element.attr('data-index'), 10);
|
var postIndex = topPostIndex;
|
||||||
var index = postIndex + 1;
|
var index = bottomPostIndex;
|
||||||
if (config.topicPostSort !== 'oldest_to_newest') {
|
if (config.topicPostSort !== 'oldest_to_newest') {
|
||||||
if (postIndex === 0) {
|
if (bottomPostIndex === 0) {
|
||||||
index = 1;
|
index = 1;
|
||||||
} else {
|
} 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],
|
var topicId = parts[1],
|
||||||
slug = parts[2];
|
slug = parts[2];
|
||||||
var newUrl = 'topic/' + topicId + '/' + (slug ? slug : '');
|
var newUrl = 'topic/' + topicId + '/' + (slug ? slug : '');
|
||||||
if (postIndex > 0) {
|
if (postIndex > 1) {
|
||||||
newUrl += '/' + (postIndex + 1);
|
newUrl += '/' + postIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newUrl !== currentUrl) {
|
if (newUrl !== currentUrl) {
|
||||||
|
|||||||
@@ -90,18 +90,26 @@ define('navigator', ['forum/pagination'], function(pagination) {
|
|||||||
navigator.update = function() {
|
navigator.update = function() {
|
||||||
toggle(!!count);
|
toggle(!!count);
|
||||||
|
|
||||||
$($(navigator.selector).get().reverse()).each(function() {
|
var topIndex = 0;
|
||||||
|
var bottomIndex = 0;
|
||||||
|
$(navigator.selector).each(function() {
|
||||||
var el = $(this);
|
var el = $(this);
|
||||||
|
|
||||||
if (elementInView(el)) {
|
if (elementInView(el)) {
|
||||||
if (typeof navigator.callback === 'function') {
|
if (!topIndex) {
|
||||||
index = navigator.callback(el, count);
|
topIndex = parseInt(el.attr('data-index'), 10) + 1;
|
||||||
navigator.updateTextAndProgressBar();
|
} else {
|
||||||
|
bottomIndex = parseInt(el.attr('data-index'), 10) + 1;
|
||||||
}
|
}
|
||||||
|
} else if (topIndex && bottomIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (typeof navigator.callback === 'function' && topIndex && bottomIndex) {
|
||||||
|
index = navigator.callback(topIndex, bottomIndex, count);
|
||||||
|
navigator.updateTextAndProgressBar();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
navigator.updateTextAndProgressBar = function() {
|
navigator.updateTextAndProgressBar = function() {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ define('share', function() {
|
|||||||
|
|
||||||
function getPostUrl(clickedElement) {
|
function getPostUrl(clickedElement) {
|
||||||
var parts = window.location.pathname.split('/');
|
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) : '');
|
return '/' + parts[1] + '/' + parts[2] + (parts[3] ? '/' + parts[3] : '') + (postIndex ? '/' + (postIndex + 1) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user