@ -319,26 +319,9 @@ ajaxify = window.ajaxify || {};
if ( tpl _url . startsWith ( 'admin' ) ) {
if ( tpl _url . startsWith ( 'admin' ) ) {
location = '' ;
location = '' ;
}
}
const proceed = ( hooks , module ) => {
if ( module && module . init ) {
module . init ( ) ;
}
hooks . fire ( 'static:script.init' , { tpl _url } ) . then ( ajaxify . loadExtraScripts . bind ( null , tpl _url , callback ) ) ;
} ;
require ( [ 'hooks' , location + tpl _url ] , proceed , ( ) => {
// Module doesn't exist or didn't load, proceed without it
require ( [ 'hooks' ] , proceed ) ;
} ) ;
} ;
// TODO: Deprecate in v1.18.0
ajaxify . loadExtraScripts = ( tpl _url , callback ) => {
var data = {
var data = {
tpl _url : tpl _url ,
tpl _url : tpl _url ,
scripts : [ ] ,
scripts : [ location + tpl _url ] ,
} ;
} ;
$ ( window ) . trigger ( 'action:script.load' , data ) ;
$ ( window ) . trigger ( 'action:script.load' , data ) ;
@ -346,20 +329,6 @@ ajaxify = window.ajaxify || {};
// Require and parse modules
// Require and parse modules
var outstanding = data . scripts . length ;
var outstanding = data . scripts . length ;
if ( ! outstanding ) {
return callback ( ) ;
}
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 ) {
data . scripts . map ( function ( script ) {
if ( typeof script === 'function' ) {
if ( typeof script === 'function' ) {
return function ( next ) {
return function ( next ) {
@ -370,6 +339,7 @@ ajaxify = window.ajaxify || {};
if ( typeof script === 'string' ) {
if ( typeof script === 'string' ) {
return function ( next ) {
return function ( next ) {
require ( [ script ] , function ( script ) {
require ( [ script ] , function ( script ) {
$ ( window ) . trigger ( 'static:script.init' , { tpl _url , module : script } ) ;
if ( script && script . init ) {
if ( script && script . init ) {
script . init ( ) ;
script . init ( ) ;
}
}