fix issue where navigating back to a topic listing (category.tpl) would not scroll down to the topic you had clicked on, and in some cases would exclude topics that were beyond that particular 'page'

v1.18.x
Julian Lam 8 years ago
parent 339845ff6b
commit 694f2382bf

@ -103,12 +103,9 @@ define('forum/category', [
return bottomIndex; return bottomIndex;
}; };
$(window).on('action:popstate', function (ev, data) { $(window).on('action:ajaxify.contentLoaded', function (ev, data) {
if (data.url.startsWith('category/')) { if (ajaxify.data.template.category) {
var cid = data.url.match(/^category\/(\d+)/); var cid = ajaxify.data.cid;
if (cid && cid[1]) {
cid = cid[1];
}
if (!cid) { if (!cid) {
return; return;
} }
@ -140,7 +137,9 @@ define('forum/category', [
$('[component="category"]').empty(); $('[component="category"]').empty();
loadTopicsAfter(Math.max(0, bookmarkIndex - 1) + 1, 1, function () { loadTopicsAfter(Math.max(0, bookmarkIndex - 1) + 1, 1, function () {
Category.scrollToTopic(bookmarkIndex, clickedIndex, 0); $(window).one('action:topics.loaded', function () {
Category.scrollToTopic(bookmarkIndex, clickedIndex, 0);
});
}); });
} }
} }
@ -167,9 +166,8 @@ define('forum/category', [
} }
var scrollTo = components.get('category/topic', 'index', bookmarkIndex); var scrollTo = components.get('category/topic', 'index', bookmarkIndex);
var cid = ajaxify.data.cid;
if (scrollTo.length && cid) { if (scrollTo.length) {
$('html, body').animate({ $('html, body').animate({
scrollTop: (scrollTo.offset().top - offset) + 'px' scrollTop: (scrollTo.offset().top - offset) + 'px'
}, duration !== undefined ? duration : 400, function () { }, duration !== undefined ? duration : 400, function () {
@ -272,7 +270,7 @@ define('forum/category', [
return callback(); return callback();
} }
$(window).trigger('action:categories.loading'); $(window).trigger('action:category.loading');
var params = utils.params(); var params = utils.params();
infinitescroll.loadMore('categories.loadMore', { infinitescroll.loadMore('categories.loadMore', {
cid: ajaxify.data.cid, cid: ajaxify.data.cid,
@ -288,7 +286,7 @@ define('forum/category', [
done(); done();
} }
$(window).trigger('action:categories.loaded'); $(window).trigger('action:category.loaded');
callback(); callback();
}); });
} }

Loading…
Cancel
Save