mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: return to previous page and/or category after marking topic unread
... also return to category if pagination is active and previous page was another page in the thread
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
define('forum/topic/threadTools', [
|
||||
'components',
|
||||
'translator',
|
||||
], function (components, translator) {
|
||||
'handleBack',
|
||||
], function (components, translator, handleBack) {
|
||||
var ThreadTools = {};
|
||||
|
||||
ThreadTools.init = function (tid, topicContainer) {
|
||||
@@ -50,6 +51,13 @@ define('forum/topic/threadTools', [
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
if (app.previousUrl && !app.previousUrl.match('^/topic')) {
|
||||
ajaxify.go(app.previousUrl, handleBack.onBackClicked);
|
||||
} else if (ajaxify.data.category) {
|
||||
ajaxify.go('category/' + ajaxify.data.category.slug, handleBack.onBackClicked);
|
||||
}
|
||||
|
||||
app.alertSuccess('[[topic:mark_unread.success]]');
|
||||
});
|
||||
return false;
|
||||
|
||||
@@ -15,6 +15,8 @@ define('handleBack', [
|
||||
$(window).off('action:popstate', onBackClicked).on('action:popstate', onBackClicked);
|
||||
};
|
||||
|
||||
handleBack.onBackClicked = onBackClicked;
|
||||
|
||||
function saveClickedIndex() {
|
||||
$('[component="category"]').on('click', '[component="topic/header"]', function () {
|
||||
var clickedIndex = $(this).parents('[data-index]').attr('data-index');
|
||||
|
||||
Reference in New Issue
Block a user