mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #5443
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
"nodebb-plugin-spam-be-gone": "0.4.10",
|
||||
"nodebb-rewards-essentials": "0.0.9",
|
||||
"nodebb-theme-lavender": "3.0.15",
|
||||
"nodebb-theme-persona": "4.2.3",
|
||||
"nodebb-theme-persona": "4.2.4",
|
||||
"nodebb-theme-vanilla": "5.2.0",
|
||||
"nodebb-widget-essentials": "2.0.13",
|
||||
"nodemailer": "2.6.4",
|
||||
|
||||
@@ -58,12 +58,25 @@ define('forum/category', [
|
||||
});
|
||||
});
|
||||
|
||||
handleScrollToTopicIndex();
|
||||
|
||||
handleIgnoreWatch(cid);
|
||||
|
||||
$(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics});
|
||||
$(window).trigger('action:category.loaded', {cid: ajaxify.data.cid});
|
||||
};
|
||||
|
||||
function handleScrollToTopicIndex() {
|
||||
var parts = window.location.pathname.split('/');
|
||||
var topicIndex = parts[parts.length - 1];
|
||||
if (topicIndex && utils.isNumber(topicIndex)) {
|
||||
topicIndex = Math.max(0, parseInt(topicIndex, 10) - 1);
|
||||
if (topicIndex && window.location.search.indexOf('page=') === -1) {
|
||||
navigator.scrollToElement($('[component="category/topic"][data-index="' + topicIndex + '"]'), true, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleIgnoreWatch(cid) {
|
||||
$('[component="category/watching"], [component="category/ignoring"]').on('click', function () {
|
||||
var $this = $(this);
|
||||
@@ -104,14 +117,10 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
$(window).on('action:ajaxify.contentLoaded', function (ev, data) {
|
||||
if (ajaxify.data.template.category) {
|
||||
var cid = ajaxify.data.cid;
|
||||
if (!cid) {
|
||||
return;
|
||||
}
|
||||
if (ajaxify.data.template.category && ajaxify.data.cid) {
|
||||
|
||||
var bookmarkIndex = localStorage.getItem('category:' + cid + ':bookmark');
|
||||
var clickedIndex = localStorage.getItem('category:' + cid + ':bookmark:clicked');
|
||||
var bookmarkIndex = localStorage.getItem('category:' + ajaxify.data.cid + ':bookmark');
|
||||
var clickedIndex = localStorage.getItem('category:' + ajaxify.data.cid + ':bookmark:clicked');
|
||||
|
||||
bookmarkIndex = Math.max(0, parseInt(bookmarkIndex, 10) || 0);
|
||||
clickedIndex = Math.max(0, parseInt(clickedIndex, 10) || 0);
|
||||
|
||||
@@ -238,14 +238,17 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
|
||||
|
||||
navigator.scrollToPostIndex = function (postIndex, highlight, duration) {
|
||||
var scrollTo = components.get('post', 'index', postIndex);
|
||||
var postHeight = scrollTo.height();
|
||||
var viewportHeight = $(window).height();
|
||||
var navbarHeight = components.get('navbar').height();
|
||||
navigator.scrollToElement(scrollTo, highlight, duration);
|
||||
};
|
||||
|
||||
navigator.scrollToElement = function(scrollTo, highlight, duration) {
|
||||
if (!scrollTo.length) {
|
||||
navigator.scrollActive = false;
|
||||
return;
|
||||
}
|
||||
var postHeight = scrollTo.height();
|
||||
var viewportHeight = $(window).height();
|
||||
var navbarHeight = components.get('navbar').height();
|
||||
|
||||
// Temporarily disable navigator update on scroll
|
||||
$(window).off('scroll', navigator.update);
|
||||
@@ -290,13 +293,8 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
|
||||
}
|
||||
}
|
||||
|
||||
if (components.get('topic').length) {
|
||||
animateScroll();
|
||||
} else {
|
||||
navigator.scrollActive = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return navigator;
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ categoryController.get = function (req, res, callback) {
|
||||
}
|
||||
|
||||
if (!settings.usePagination) {
|
||||
topicIndex = Math.max(topicIndex - (settings.topicsPerPage - 1), 0);
|
||||
topicIndex = Math.max(0, topicIndex - (Math.ceil(settings.topicsPerPage / 2) - 1));
|
||||
} else if (!req.query.page) {
|
||||
var index = Math.max(parseInt((topicIndex || 0), 10), 0);
|
||||
currentPage = Math.ceil((index + 1) / settings.topicsPerPage);
|
||||
|
||||
Reference in New Issue
Block a user