mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat(hooks): update action:ajaxify.end to use new hooks module
This commit is contained in:
@@ -30,10 +30,12 @@
|
|||||||
}, 3600000);
|
}, 3600000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(window).on('action:ajaxify.end', function () {
|
require(['hooks'], (hooks) => {
|
||||||
|
hooks.on('action:ajaxify.end', () => {
|
||||||
showCorrectNavTab();
|
showCorrectNavTab();
|
||||||
startLogoutTimer();
|
startLogoutTimer();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function showCorrectNavTab() {
|
function showCorrectNavTab() {
|
||||||
// show correct tab if url has #
|
// show correct tab if url has #
|
||||||
@@ -66,12 +68,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function setupNProgress() {
|
function setupNProgress() {
|
||||||
require(['nprogress'], function (NProgress) {
|
require(['nprogress', 'hooks'], function (NProgress, hooks) {
|
||||||
$(window).on('action:ajaxify.start', function () {
|
$(window).on('action:ajaxify.start', function () {
|
||||||
NProgress.set(0.7);
|
NProgress.set(0.7);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('action:ajaxify.end', function () {
|
hooks.on('action:ajaxify.end', function () {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ ajaxify = window.ajaxify || {};
|
|||||||
|
|
||||||
// If any listeners alter url and set it to an empty string, abort the ajaxification
|
// If any listeners alter url and set it to an empty string, abort the ajaxification
|
||||||
if (url === null) {
|
if (url === null) {
|
||||||
$(window).trigger('action:ajaxify.end', { url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title });
|
require(['hooks'], function (hooks) {
|
||||||
|
hooks.fire('action:ajaxify.end', { url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title });
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +283,9 @@ ajaxify = window.ajaxify || {};
|
|||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
ajaxify.loadScript(tpl_url, function done() {
|
ajaxify.loadScript(tpl_url, function done() {
|
||||||
$(window).trigger('action:ajaxify.end', { url: url, tpl_url: tpl_url, title: ajaxify.data.title });
|
require(['hooks'], function (hooks) {
|
||||||
|
hooks.fire('action:ajaxify.end', { url: url, tpl_url: tpl_url, title: ajaxify.data.title });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
ajaxify.widgets.render(tpl_url);
|
ajaxify.widgets.render(tpl_url);
|
||||||
|
|
||||||
|
|||||||
@@ -55,13 +55,15 @@ app.cacheBuster = null;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.body.addEventListener('click', earlyClick);
|
document.body.addEventListener('click', earlyClick);
|
||||||
$(window).on('action:ajaxify.end', function () {
|
require(['hooks'], function (hooks) {
|
||||||
|
hooks.on('action:ajaxify.end', function () {
|
||||||
document.body.removeEventListener('click', earlyClick);
|
document.body.removeEventListener('click', earlyClick);
|
||||||
earlyQueue.forEach(function (el) {
|
earlyQueue.forEach(function (el) {
|
||||||
el.click();
|
el.click();
|
||||||
});
|
});
|
||||||
earlyQueue = [];
|
earlyQueue = [];
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
setTimeout(app.handleEarlyClicks, 50);
|
setTimeout(app.handleEarlyClicks, 50);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('navigator', ['forum/pagination', 'components'], function (pagination, components) {
|
define('navigator', ['forum/pagination', 'components', 'hooks'], function (pagination, components, hooks) {
|
||||||
var navigator = {};
|
var navigator = {};
|
||||||
var index = 0;
|
var index = 0;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
@@ -142,7 +142,7 @@ define('navigator', ['forum/pagination', 'components'], function (pagination, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mouseDragging = false;
|
var mouseDragging = false;
|
||||||
$(window).on('action:ajaxify.end', function () {
|
hooks.on('action:ajaxify.end', function () {
|
||||||
renderPostIndex = null;
|
renderPostIndex = null;
|
||||||
});
|
});
|
||||||
$('.pagination-block .dropdown-menu').parent().on('shown.bs.dropdown', function () {
|
$('.pagination-block .dropdown-menu').parent().on('shown.bs.dropdown', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user