mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-23 17:00:24 +01:00
Added ajaxify.isCold()
And used it in app.js, so window.scrollTo(0, 0); is not called on cold load (since you're already at the top). Useful in low- bandwidth modes since you might accidentally get kicked to the top of the page due to a slow connection and delayed .init(). Slightly related to testing in #6150
This commit is contained in:
@@ -37,6 +37,7 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
ajaxify.count = 0;
|
||||
ajaxify.currentPage = null;
|
||||
|
||||
ajaxify.go = function (url, callback, quiet) {
|
||||
@@ -100,6 +101,10 @@ $(document).ready(function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
ajaxify.isCold = function () {
|
||||
return ajaxify.count <= 1;
|
||||
};
|
||||
|
||||
ajaxify.handleRedirects = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, '')).toLowerCase();
|
||||
var isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0;
|
||||
@@ -113,7 +118,6 @@ $(document).ready(function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
ajaxify.start = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, ''));
|
||||
|
||||
@@ -123,6 +127,8 @@ $(document).ready(function () {
|
||||
|
||||
$(window).trigger('action:ajaxify.start', payload);
|
||||
|
||||
ajaxify.count += 1;
|
||||
|
||||
return payload.url;
|
||||
};
|
||||
|
||||
@@ -197,7 +203,6 @@ $(document).ready(function () {
|
||||
|
||||
ajaxify.end = function (url, tpl_url) {
|
||||
var count = 2;
|
||||
|
||||
function done() {
|
||||
count -= 1;
|
||||
if (count === 0) {
|
||||
@@ -205,7 +210,6 @@ $(document).ready(function () {
|
||||
}
|
||||
}
|
||||
ajaxify.loadScript(tpl_url, done);
|
||||
|
||||
ajaxify.widgets.render(tpl_url, done);
|
||||
|
||||
$(window).trigger('action:ajaxify.contentLoaded', { url: url, tpl: tpl_url });
|
||||
|
||||
Reference in New Issue
Block a user