mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-05 05:25:49 +01:00
updated scrollToPost behaviour to no longer ajaxify loudly. Also updated call to checkPagePresence to fire before the topicDOM events begin, so if an in-topic search is conducted on a different topic from the current topic, the topicDOM behaviour continues. closes #3040
This commit is contained in:
@@ -58,10 +58,13 @@ $(document).ready(function() {
|
||||
require(['translator', 'search'], function(translator, search) {
|
||||
translator.load(config.defaultLang, data.template.name);
|
||||
renderTemplate(url, data.template.name, data, callback);
|
||||
search.topicDOM.end();
|
||||
});
|
||||
});
|
||||
|
||||
if (!quiet) {
|
||||
search.topicDOM.end();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
|
||||
} else {
|
||||
navigator.scrollActive = false;
|
||||
postIndex = parseInt(postIndex, 10) + 1;
|
||||
ajaxify.go(generateUrl(postIndex));
|
||||
ajaxify.go(generateUrl(postIndex), undefined, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -88,13 +88,15 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
|
||||
term: term
|
||||
};
|
||||
|
||||
Search.topicDOM.update(0);
|
||||
Search.checkPagePresence(tid, function() {
|
||||
Search.topicDOM.update(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Search.checkPagePresence = function(tid, callback) {
|
||||
if (!ajaxify.currentPage.match(new RegExp('^topic/' + tid))) {
|
||||
if (parseInt(ajaxify.variables.get('topic_id'), 10) !== parseInt(tid, 10)) {
|
||||
ajaxify.go('topic/' + tid, callback);
|
||||
} else {
|
||||
callback();
|
||||
@@ -119,20 +121,18 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
|
||||
|
||||
Search.topicDOM.start();
|
||||
|
||||
Search.checkPagePresence(Search.current.tid, function() {
|
||||
if (Search.current.results.length > 0) {
|
||||
topicSearchEl.find('.count').html((index+1) + ' / ' + Search.current.results.length);
|
||||
topicSearchEl.find('.prev, .next').removeAttr('disabled');
|
||||
socket.emit('posts.getPidIndex', Search.current.results[index], function(err, postIndex) {
|
||||
nav.scrollToPost(postIndex-1, true); // why -1? Ask @barisusakli
|
||||
});
|
||||
} else {
|
||||
translator.translate('[[search:no-matches]]', function(text) {
|
||||
topicSearchEl.find('.count').html(text);
|
||||
});
|
||||
topicSearchEl.removeClass('hidden').find('.prev, .next').attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
if (Search.current.results.length > 0) {
|
||||
topicSearchEl.find('.count').html((index+1) + ' / ' + Search.current.results.length);
|
||||
topicSearchEl.find('.prev, .next').removeAttr('disabled');
|
||||
socket.emit('posts.getPidIndex', Search.current.results[index], function(err, postIndex) {
|
||||
nav.scrollToPost(postIndex-1, true); // why -1? Ask @barisusakli
|
||||
});
|
||||
} else {
|
||||
translator.translate('[[search:no-matches]]', function(text) {
|
||||
topicSearchEl.find('.count').html(text);
|
||||
});
|
||||
topicSearchEl.removeClass('hidden').find('.prev, .next').attr('disabled', 'disabled');
|
||||
}
|
||||
};
|
||||
|
||||
Search.topicDOM.start = function() {
|
||||
|
||||
Reference in New Issue
Block a user