|
|
|
@ -320,19 +320,20 @@ ajaxify = window.ajaxify || {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ajaxify.loadScript = function (tpl_url, callback) {
|
|
|
|
|
require(['hooks'], (hooks) => {
|
|
|
|
|
var location = !app.inAdmin ? 'forum/' : '';
|
|
|
|
|
|
|
|
|
|
if (tpl_url.startsWith('admin')) {
|
|
|
|
|
location = '';
|
|
|
|
|
}
|
|
|
|
|
var data = {
|
|
|
|
|
const data = {
|
|
|
|
|
tpl_url: tpl_url,
|
|
|
|
|
scripts: [location + tpl_url],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Hint: useful if you want to load a module on a specific page (append module name to `scripts`)
|
|
|
|
|
$(window).trigger('action:script.load', data);
|
|
|
|
|
|
|
|
|
|
hooks.fire('action:script.load', data);
|
|
|
|
|
hooks.fire('filter:script.load', data).then((data) => {
|
|
|
|
|
// Require and parse modules
|
|
|
|
|
var outstanding = data.scripts.length;
|
|
|
|
|
|
|
|
|
@ -345,7 +346,7 @@ ajaxify = window.ajaxify || {};
|
|
|
|
|
}
|
|
|
|
|
if (typeof script === 'string') {
|
|
|
|
|
return function (next) {
|
|
|
|
|
require(['hooks', script], function (hooks, module) {
|
|
|
|
|
require([script], function (module) {
|
|
|
|
|
// Hint: useful if you want to override a loaded library (e.g. replace core client-side logic),
|
|
|
|
|
// or call a method other than .init()
|
|
|
|
|
hooks.fire('static:script.init', { tpl_url, name: script, module }).then(() => {
|
|
|
|
@ -369,6 +370,8 @@ ajaxify = window.ajaxify || {};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ajaxify.loadData = function (url, callback) {
|
|
|
|
|