Merge "Add languages in which there is a featured article"

This commit is contained in:
jenkins-bot
2016-08-08 12:47:08 +00:00
committed by Gerrit Code Review

View File

@@ -233,6 +233,8 @@
this.getCommonLanguages, this.getCommonLanguages,
// Add languages that are present in the article content. // Add languages that are present in the article content.
this.filterByLangsInText, this.filterByLangsInText,
// Add languages in which there are featured articles.
this.filterByBadges,
// Some global fallbacks to avoid showing languages in the beginning of the alphabet // Some global fallbacks to avoid showing languages in the beginning of the alphabet
getExtraCommonLanguages, getExtraCommonLanguages,
// Finally add the whole languages array too. // Finally add the whole languages array too.
@@ -366,6 +368,22 @@
return languagesInText; return languagesInText;
}; };
/**
* Filter the language list by languages the page in which
* has any kind of a badge, such as "featured article".
* The "badge-*" classes are added by Wikibase.
*
* The reader doesn't necessarily know this language, but it
* appears relevant to the page.
*
* @return {Array} List of language codes in which there are articles with badges
*/
CompactInterlanguageList.prototype.filterByBadges = function () {
return $( '#p-lang' ).find( '[class*="badge"]' ).map( function ( i, el ) {
return $( el ).find( 'a' ).attr( 'lang' ); }
).toArray();
};
/** /**
* Find out the existing languages supported * Find out the existing languages supported
* by the article and fetch their href. * by the article and fetch their href.