Compact language links module is loaded via server side
This provides an alternative mechanism to I0518ecdf402ebf5eb6bad2c430f6462322c0d8e1 for loading the compact language link module. Instead of relying on the client, the HTML is inspected. Bug: T264824 Change-Id: I977a998388b3e70f7fe4d97fa05be3c1ac1bf676
This commit is contained in:
@@ -102,15 +102,24 @@ class UniversalLanguageSelectorHooks {
|
||||
if ( in_array( $skin->getSkinName(), $unsupportedSkins ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Soft dependency to Wikibase client. Don't enable CLL if links are managed manually.
|
||||
$excludedLinks = $out->getProperty( 'noexternallanglinks' );
|
||||
$override = is_array( $excludedLinks ) && in_array( '*', $excludedLinks );
|
||||
$config = [
|
||||
'wgULSPosition' => $wgULSPosition,
|
||||
'wgULSCompactLinksEnabled' => !$override && self::isCompactLinksEnabled( $out->getUser() ),
|
||||
];
|
||||
|
||||
// Load compact links if no mw-interlanguage-selector element is present in the page HTML.
|
||||
// We use the same mechanism as Skin::getDefaultModules and check the HTML for the presence in the HTML,
|
||||
// using the class as the heuristic.
|
||||
// Note if the element is rendered by the skin, its assumed that no collapsing is needed.
|
||||
// See T264824 for more information.
|
||||
if ( !$override && self::isCompactLinksEnabled( $out->getUser() ) &&
|
||||
strpos( $out->getHTML(), 'mw-interlanguage-selector' ) === false
|
||||
) {
|
||||
$out->addModules( 'ext.uls.compactlinks' );
|
||||
}
|
||||
|
||||
if ( is_string( $wgULSGeoService ) ) {
|
||||
$out->addModules( 'ext.uls.geoclient' );
|
||||
}
|
||||
|
||||
@@ -443,23 +443,6 @@
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Compact the language list if necessary
|
||||
*/
|
||||
function compactLanguageLinksList() {
|
||||
if (
|
||||
// Allow skins to register their own button, in which case no need to compact
|
||||
!document.querySelector( '.mw-interlanguage-selector' ) && (
|
||||
// This line is for cached HTML where the JS config variable is not available
|
||||
// it can be removed a week after this code has been in production.
|
||||
mw.loader.getState( 'ext.uls.compactlinks' ) !== 'registered' ||
|
||||
mw.config.get( 'wgULSCompactLinksEnabled' )
|
||||
)
|
||||
) {
|
||||
mw.loader.using( 'ext.uls.compactlinks' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler for the language button
|
||||
* @param {jQuery.Event} ev
|
||||
@@ -494,7 +477,6 @@
|
||||
initInterface();
|
||||
initTooltip();
|
||||
initIme();
|
||||
compactLanguageLinksList();
|
||||
initInterlanguageSelector();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user