Query only for <a> elements that are interlanguage links targets
Depends on the core change in 1.28, which adds the interlanguage-link-target class to the <a> elements: I06c80945af785477be52096022c8493e7f82c298 Includes backwards compatibility code so that ULS compact links would be usable on core versions that don't have this change. Bug: T135378 Change-Id: I2909ce31e19087358d194e0e108e1ba038e7273e Depends-On: I06c80945af785477be52096022c8493e7f82c298
This commit is contained in:
@@ -395,8 +395,16 @@
|
||||
* @return {Array} List of language codes in which there are articles with badges
|
||||
*/
|
||||
CompactInterlanguageList.prototype.filterByBadges = function () {
|
||||
// Can be removed when backwards compatibility before
|
||||
// MediaWiki 1.28 is no longer needed
|
||||
var targetSelector = parseFloat( mw.config.get( 'wgVersion' ) ) >= 1.28 ?
|
||||
'.interlanguage-link-target' :
|
||||
'a';
|
||||
|
||||
return $( '#p-lang' ).find( '[class*="badge"]' ).map( function ( i, el ) {
|
||||
return convertMediaWikiLanguageCodeToULS( $( el ).find( 'a' ).attr( 'lang' ) );
|
||||
return convertMediaWikiLanguageCodeToULS(
|
||||
$( el ).find( targetSelector ).attr( 'lang' )
|
||||
);
|
||||
} ).toArray();
|
||||
};
|
||||
|
||||
@@ -407,9 +415,16 @@
|
||||
* @return {Object} List of existing language codes and their hrefs
|
||||
*/
|
||||
CompactInterlanguageList.prototype.getInterlanguageList = function () {
|
||||
var interlanguageList = {};
|
||||
var targetSelector,
|
||||
interlanguageList = {};
|
||||
|
||||
this.$interlanguageList.find( 'li.interlanguage-link > a' ).each( function () {
|
||||
// Can be removed when backwards compatibility before
|
||||
// MediaWiki 1.28 is no longer needed
|
||||
targetSelector = parseFloat( mw.config.get( 'wgVersion' ) ) >= 1.28 ?
|
||||
'.interlanguage-link-target' :
|
||||
'li.interlanguage-link > a';
|
||||
|
||||
this.$interlanguageList.find( targetSelector ).each( function () {
|
||||
var langCode = convertMediaWikiLanguageCodeToULS( this.getAttribute( 'lang' ) );
|
||||
|
||||
interlanguageList[ langCode ] = {
|
||||
|
||||
Reference in New Issue
Block a user