r95846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95845‎ | r95846 | r95847 >
Date:10:23, 31 August 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Trying to fix JSHint warnings as good as I can
Modified paths:
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -156,22 +156,19 @@
157157 // Build font dropdown
158158 $.webfonts.buildMenu(config );
159159 //see if there is a font in cookie
160 - cookie_font = $.cookie('webfonts-font');
161 - if(cookie_font == null){
 160+ var cookie_font = $.cookie('webfonts-font');
 161+ if(!cookie_font){
162162 $.webfonts.set( config[0]);
163163 //mark it as checked
164164 $('#webfont-'+config[0]).attr('checked', 'checked');
 165+ } else if (cookie_font !=='none') {
 166+ $.webfonts.set( cookie_font);
 167+ //mark it as checked
 168+ $('#webfont-'+cookie_font).attr('checked', 'checked');
165169 }
166 - else{
167 - if (cookie_font !=='none'){
168 - $.webfonts.set( cookie_font);
169 - //mark it as checked
170 - $('#webfont-'+cookie_font).attr('checked', 'checked');
171 - }
172 - }
173170
174171 //if there are tags with font-family style definition, get a list of fonts to be loaded
175 - var fontFamilies = new Array();
 172+ var fontFamilies = [];
176173 $('body').find('*[style]').each(function(index){
177174 if( this.style.fontFamily){
178175 var fontFamilyItems = this.style.fontFamily.split(",");
@@ -195,20 +192,20 @@
196193 buildMenu : function(config) {
197194 var haveSchemes = false;
198195 // Build font dropdown
199 - $fontsMenu = $( '<ul />' ).attr('id','webfonts-fontsmenu');
 196+ var $fontsMenu = $( '<ul />' ).attr('id','webfonts-fontsmenu');
200197 for ( var scheme in config ) {
201 - $fontLink = $( '<input>' )
 198+ var $fontLink = $( '<input>' )
202199 .attr("type","radio")
203200 .attr("name","font")
204201 .attr("id","webfont-"+config[scheme])
205202 .attr("value",config[scheme] );
206203
207 - $fontLabel = $( '<label />' )
 204+ var $fontLabel = $( '<label />' )
208205 .attr("for","webfont-"+config[scheme])
209206 .append( $fontLink )
210207 .append( config[scheme] );
211208
212 - $fontMenuItem = $( '<li />' )
 209+ var $fontMenuItem = $( '<li />' )
213210 .val( config[scheme] )
214211 .append( $fontLabel );
215212
@@ -217,13 +214,13 @@
218215 (function (font) {
219216 $fontLink.click( function( event ) {
220217 $.webfonts.set( font );
221 - })
 218+ });
222219 }) (config[scheme]);
223220
224221 $fontsMenu.append($fontMenuItem);
225222
226223 }
227 - $resetLink = $( '<input />' )
 224+ var $resetLink = $( '<input />' )
228225 .attr("type","radio")
229226 .attr("name","font")
230227 .attr("value","webfont-none")
@@ -232,14 +229,14 @@
233230 $.webfonts.set( 'none');
234231 });
235232
236 - $resetLabel = $( '<label />' )
 233+ var $resetLabel = $( '<label />' )
237234 .attr("for","webfont-none")
238235 .append( $resetLink )
239236 .append( mw.msg("webfonts-reset"));
240237
241 - $resetLinkItem = $( '<li />' )
 238+ var $resetLinkItem = $( '<li />' )
242239 .val( 'none')
243 - .append( $resetLabel )
 240+ .append( $resetLabel );
244241
245242 $fontsMenu.append($resetLinkItem);
246243 if ( !haveSchemes ) {
@@ -269,7 +266,7 @@
270267 $($('#p-personal ul')[0]).prepend( $li );
271268 }
272269 }
273 - }
 270+ };
274271
275272 $( document ).ready( function() {
276273 $.webfonts.setup();

Status & tagging log