r105980 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105979‎ | r105980 | r105981 >
Date:04:46, 13 December 2011
Author:santhosh
Status:ok
Tags:
Comment:
If an element is having lang attribute value same as page language(contentLang/UserLang/Variant),
do not apply default font for that. This is to make sure that font changes from menu take effect on these elements.
Modified paths:
  • /trunk/extensions/WebFonts/resources/ext.webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.js
@@ -218,16 +218,20 @@
219219 */
220220 loadFontsForLangAttr: function() {
221221 var languages = mw.webfonts.config.languages;
 222+ var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )];
222223 // If there are tags with lang attribute,
223224 $( 'body' ).find( '*[lang]' ).each( function( index ) {
224 - // .. check the availability of font, add a font-family style if it does not have any
225 - if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily === 'none' ) ) {
226 - fontFamily = languages[this.lang][0];
227 - mw.webfonts.addFont( fontFamily );
228 - $(this).css( 'font-family', fontFamily ).addClass( 'webfonts-lang-attr' );
 225+ // If the lang attribute value is same as one of
 226+ // contentLang,useLang, variant, no need to do this.
 227+ if( $.inArray( this.lang , requested ) === -1 ) {
 228+ // check the availability of font, add a font-family style if it does not have any
 229+ if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily === 'none' ) ) {
 230+ fontFamily = languages[this.lang][0];
 231+ mw.webfonts.addFont( fontFamily );
 232+ $(this).css( 'font-family', fontFamily ).addClass( 'webfonts-lang-attr' );
 233+ }
229234 }
230235 });
231 -
232236 },
233237
234238 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r105989MFT r105980nikerabbit05:39, 13 December 2011

Status & tagging log