Modern Vector should be compatible with ULS
Without the following changes the language button shows the wrong label and opens a dialog with zero languages. * Don't apply heading change to modern Vector * Look for the element .mw-portlet-lang as well as #p-lang Bug: T273232 Bug: T273928 Change-Id: Ic201b1983a17cc37fd1ff7c507aab656ea25f370
This commit is contained in:
@@ -236,8 +236,8 @@
|
|||||||
getBabelLanguages,
|
getBabelLanguages,
|
||||||
getSitePicks,
|
getSitePicks,
|
||||||
getCommonLanguages,
|
getCommonLanguages,
|
||||||
this.getLangsInText,
|
this.getLangsInText.bind( this ),
|
||||||
this.getLangsWithBadges,
|
this.getLangsWithBadges.bind( this ),
|
||||||
getExtraCommonLanguages,
|
getExtraCommonLanguages,
|
||||||
getFinalFallback
|
getFinalFallback
|
||||||
];
|
];
|
||||||
@@ -300,7 +300,7 @@
|
|||||||
*/
|
*/
|
||||||
CompactInterlanguageList.prototype.getLangsWithBadges = function () {
|
CompactInterlanguageList.prototype.getLangsWithBadges = function () {
|
||||||
return Array.prototype.map.call(
|
return Array.prototype.map.call(
|
||||||
document.querySelectorAll( '#p-lang [class*="badge"] a.interlanguage-link-target' ),
|
this.listElement.querySelectorAll( '[class*="badge"] a.interlanguage-link-target' ),
|
||||||
function ( el ) {
|
function ( el ) {
|
||||||
return mw.uls.convertMediaWikiLanguageCodeToULS( el.lang );
|
return mw.uls.convertMediaWikiLanguageCodeToULS( el.lang );
|
||||||
}
|
}
|
||||||
@@ -382,9 +382,9 @@
|
|||||||
*/
|
*/
|
||||||
function createCompactList() {
|
function createCompactList() {
|
||||||
var listElement, compactList;
|
var listElement, compactList;
|
||||||
listElement = document.querySelector( '#p-lang ul' );
|
listElement = document.querySelector( '.mw-portlet-lang ul, #p-lang ul' );
|
||||||
if ( !listElement ) {
|
if ( !listElement ) {
|
||||||
// Not all namespaces/pages/actions have #p-lang.
|
// Not all namespaces will have a list of languages.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
compactList = new CompactInterlanguageList( listElement );
|
compactList = new CompactInterlanguageList( listElement );
|
||||||
|
|||||||
@@ -236,6 +236,8 @@
|
|||||||
function initInterface() {
|
function initInterface() {
|
||||||
var $pLang,
|
var $pLang,
|
||||||
clickHandler,
|
clickHandler,
|
||||||
|
// T273928: No change to the heading should be made in modern Vector when the language button is present
|
||||||
|
changeHeadingAllowed = mw.config.get( 'skin' ) !== 'vector' || $( '#p-lang-btn' ).length > 0,
|
||||||
$ulsTrigger = $( '.uls-trigger' ),
|
$ulsTrigger = $( '.uls-trigger' ),
|
||||||
anonMode = ( mw.user.isAnon() &&
|
anonMode = ( mw.user.isAnon() &&
|
||||||
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
|
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
|
||||||
@@ -243,7 +245,7 @@
|
|||||||
|
|
||||||
if ( ulsPosition === 'interlanguage' ) {
|
if ( ulsPosition === 'interlanguage' ) {
|
||||||
// TODO: Refactor this block
|
// TODO: Refactor this block
|
||||||
// The interlanguage links section
|
// The interlanguage links section.
|
||||||
$pLang = $( '#p-lang' );
|
$pLang = $( '#p-lang' );
|
||||||
// Add an element near the interlanguage links header
|
// Add an element near the interlanguage links header
|
||||||
$ulsTrigger = $( '<button>' )
|
$ulsTrigger = $( '<button>' )
|
||||||
@@ -253,7 +255,7 @@
|
|||||||
// Take care of any other elements with this class.
|
// Take care of any other elements with this class.
|
||||||
$ulsTrigger = $( '.uls-settings-trigger' );
|
$ulsTrigger = $( '.uls-settings-trigger' );
|
||||||
|
|
||||||
if ( !$pLang.find( 'div ul' ).children().length ) {
|
if ( !$pLang.find( 'div ul' ).children().length && changeHeadingAllowed ) {
|
||||||
// Replace the title of the interlanguage links area
|
// Replace the title of the interlanguage links area
|
||||||
// if there are no interlanguage links
|
// if there are no interlanguage links
|
||||||
$pLang.find( 'h3' )
|
$pLang.find( 'h3' )
|
||||||
@@ -452,10 +454,11 @@
|
|||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
// Load the ULS now.
|
// Load the ULS now.
|
||||||
mw.loader.using( 'ext.uls.mediawiki' ).then( function () {
|
mw.loader.using( 'ext.uls.mediawiki' ).then( function () {
|
||||||
|
var parent = document.querySelectorAll( '.mw-portlet-lang, #p-lang' )[ 0 ];
|
||||||
launchULS(
|
launchULS(
|
||||||
$target,
|
$target,
|
||||||
mw.uls.getInterlanguageListFromNodes(
|
mw.uls.getInterlanguageListFromNodes(
|
||||||
document.querySelectorAll( '#p-lang .interlanguage-link-target' )
|
parent ? parent.querySelectorAll( '.interlanguage-link-target' ) : []
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$target.trigger( 'click' );
|
$target.trigger( 'click' );
|
||||||
|
|||||||
Reference in New Issue
Block a user