r102634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102633‎ | r102634 | r102635 >
Date:11:03, 10 November 2011
Author:santhosh
Status:ok
Tags:
Comment:
Use comma to use multiple selectors
Use chaining with jquery
Use prop instead of attr for 'checked'


As per https://www.mediawiki.org/wiki/User:Krinkle/Extension_review/WebFonts#jQuery_stuff
Modified paths:
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -63,12 +63,10 @@
6464 'font-size': $.webfonts.oldconfig["font-size"]
6565 });
6666 //we need to reset the fonts of Input and Select explicitly.
67 - $("input").css('font-family', $.webfonts.oldconfig["font-family"]);
68 - $("select").css('font-family', $.webfonts.oldconfig["font-family"]);
 67+ $("input, select").css('font-family', $.webfonts.oldconfig["font-family"]);
6968
7069 // Reset the fonts applied for tags with lang attribute.
71 - $(".webfonts-lang-attr").css( 'font-family', 'none' );
72 - $(".webfonts-lang-attr").removeClass( 'webfonts-lang-attr' );
 70+ $(".webfonts-lang-attr").css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' );
7371
7472 //remove the cookie
7573 $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } );
@@ -186,7 +184,7 @@
187185 var cookieFont = $.cookie( 'webfonts-font' );
188186 var selectedFont = null;
189187 // check whether this font is for the current userlang/contentlang
190 - if ( $.inArray(cookieFont, config) >=0 ){
 188+ if ( $.inArray(cookieFont, config) !== -1){
191189 selectedFont = cookieFont;
192190 }
193191 else{
@@ -197,7 +195,7 @@
198196 if ( selectedFont && selectedFont !== 'none' ) {
199197 $.webfonts.set( selectedFont );
200198 //mark it as checked
201 - $( '#'+fontID( selectedFont ) ).attr( 'checked', 'checked' );
 199+ $( '#'+fontID( selectedFont ) ).prop( 'checked', true );
202200 }
203201
204202 $.webfonts.loadFontsForFontFamilyStyle();
@@ -222,8 +220,7 @@
223221 if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily == "none" ) ) {
224222 fontFamily = languages[this.lang][0];
225223 $.webfonts.addFont( fontFamily );
226 - $(this).css('font-family', fontFamily);
227 - $(this).addClass('webfonts-lang-attr');
 224+ $(this).css('font-family', fontFamily).addClass('webfonts-lang-attr');
228225 }
229226 });
230227

Status & tagging log