mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 06:24:22 +00:00
Load lazyload modules with skin modules if needed
This commit is contained in:
parent
105bcd52ed
commit
3736489118
|
@ -35,27 +35,6 @@ use ThumbnailImage;
|
|||
* on<HookName>()
|
||||
*/
|
||||
class CitizenHooks {
|
||||
/**
|
||||
* @param OutputPage $out
|
||||
* @param Skin $skin
|
||||
* @return bool
|
||||
*/
|
||||
public static function onBeforePageDisplay( $out, $skin ) {
|
||||
try {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' );
|
||||
$lazyloadEnabled = $config->get( 'CitizenEnableLazyload' );
|
||||
} catch ( Exception $e ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $lazyloadEnabled === true ) {
|
||||
$out->addModules( 'skins.citizen.styles.lazyload' );
|
||||
$out->addModules( 'skins.citizen.scripts.lazyload' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceLoaderGetConfigVars hook handler for setting a config variable
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
||||
|
|
|
@ -250,6 +250,11 @@ class SkinCitizen extends SkinTemplate {
|
|||
'skins.citizen.icons.badges',
|
||||
] );
|
||||
|
||||
// Add lazyload-related modules
|
||||
if ( $this->getConfigValue( 'CitizenEnableLazyload' ) === true ) {
|
||||
$this->out->addModuleStyles( [ 'skins.citizen.styles.lazyload' ] );
|
||||
$this->out->addModules( [ 'skins.citizen.scripts.lazyload' ] );
|
||||
}
|
||||
$this->out->addModules( [
|
||||
'skins.citizen.scripts',
|
||||
] );
|
||||
|
|
Loading…
Reference in a new issue