@ -319,9 +319,22 @@ ajaxify = window.ajaxify || {};
if ( tpl _url . startsWith ( 'admin' ) ) {
location = '' ;
}
require ( [ 'hooks' , location + tpl _url ] , ( hooks , module ) => {
if ( module && module . init ) {
module . init ( ) ;
}
hooks . fire ( 'static:script.init' , { tpl _url } ) . then ( ajaxify . loadExtraScripts . bind ( null , tpl _url , callback ) ) ;
} , function ( ) {
// ignore 404 error
} ) ;
} ;
ajaxify . loadExtraScripts = ( tpl _url , callback ) => {
var data = {
tpl _url : tpl _url ,
scripts : [ location + tpl _url ] ,
scripts : [ ] ,
} ;
$ ( window ) . trigger ( 'action:script.load' , data ) ;
@ -329,6 +342,16 @@ ajaxify = window.ajaxify || {};
// Require and parse modules
var outstanding = data . scripts . length ;
if ( outstanding && ! app . flags . actionScriptLoadDeprecation ) {
console . group ( 'Deprecation Notice' ) ;
console . warn ( 'The "action:script.load" event has been deprecated and will be removed in NodeBB v1.18.0. Please attach a listener to the "static:script.init" client-side hook instead' ) ;
data . scripts . forEach ( ( script ) => {
console . info ( ` Affected script: ${ typeof script === 'function' ? script . name || 'anonymous ' + script . toString ( ) : script } ` ) ;
} ) ;
console . groupEnd ( ) ;
app . flags . actionScriptLoadDeprecation = 1 ;
}
data . scripts . map ( function ( script ) {
if ( typeof script === 'function' ) {
return function ( next ) {