Index: trunk/extensions/WebFonts/js/webfonts.js |
— | — | @@ -156,22 +156,19 @@ |
157 | 157 | // Build font dropdown |
158 | 158 | $.webfonts.buildMenu(config ); |
159 | 159 | //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){ |
162 | 162 | $.webfonts.set( config[0]); |
163 | 163 | //mark it as checked |
164 | 164 | $('#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'); |
165 | 169 | } |
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 | | - } |
173 | 170 | |
174 | 171 | //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 = []; |
176 | 173 | $('body').find('*[style]').each(function(index){ |
177 | 174 | if( this.style.fontFamily){ |
178 | 175 | var fontFamilyItems = this.style.fontFamily.split(","); |
— | — | @@ -195,20 +192,20 @@ |
196 | 193 | buildMenu : function(config) { |
197 | 194 | var haveSchemes = false; |
198 | 195 | // Build font dropdown |
199 | | - $fontsMenu = $( '<ul />' ).attr('id','webfonts-fontsmenu'); |
| 196 | + var $fontsMenu = $( '<ul />' ).attr('id','webfonts-fontsmenu'); |
200 | 197 | for ( var scheme in config ) { |
201 | | - $fontLink = $( '<input>' ) |
| 198 | + var $fontLink = $( '<input>' ) |
202 | 199 | .attr("type","radio") |
203 | 200 | .attr("name","font") |
204 | 201 | .attr("id","webfont-"+config[scheme]) |
205 | 202 | .attr("value",config[scheme] ); |
206 | 203 | |
207 | | - $fontLabel = $( '<label />' ) |
| 204 | + var $fontLabel = $( '<label />' ) |
208 | 205 | .attr("for","webfont-"+config[scheme]) |
209 | 206 | .append( $fontLink ) |
210 | 207 | .append( config[scheme] ); |
211 | 208 | |
212 | | - $fontMenuItem = $( '<li />' ) |
| 209 | + var $fontMenuItem = $( '<li />' ) |
213 | 210 | .val( config[scheme] ) |
214 | 211 | .append( $fontLabel ); |
215 | 212 | |
— | — | @@ -217,13 +214,13 @@ |
218 | 215 | (function (font) { |
219 | 216 | $fontLink.click( function( event ) { |
220 | 217 | $.webfonts.set( font ); |
221 | | - }) |
| 218 | + }); |
222 | 219 | }) (config[scheme]); |
223 | 220 | |
224 | 221 | $fontsMenu.append($fontMenuItem); |
225 | 222 | |
226 | 223 | } |
227 | | - $resetLink = $( '<input />' ) |
| 224 | + var $resetLink = $( '<input />' ) |
228 | 225 | .attr("type","radio") |
229 | 226 | .attr("name","font") |
230 | 227 | .attr("value","webfont-none") |
— | — | @@ -232,14 +229,14 @@ |
233 | 230 | $.webfonts.set( 'none'); |
234 | 231 | }); |
235 | 232 | |
236 | | - $resetLabel = $( '<label />' ) |
| 233 | + var $resetLabel = $( '<label />' ) |
237 | 234 | .attr("for","webfont-none") |
238 | 235 | .append( $resetLink ) |
239 | 236 | .append( mw.msg("webfonts-reset")); |
240 | 237 | |
241 | | - $resetLinkItem = $( '<li />' ) |
| 238 | + var $resetLinkItem = $( '<li />' ) |
242 | 239 | .val( 'none') |
243 | | - .append( $resetLabel ) |
| 240 | + .append( $resetLabel ); |
244 | 241 | |
245 | 242 | $fontsMenu.append($resetLinkItem); |
246 | 243 | if ( !haveSchemes ) { |
— | — | @@ -269,7 +266,7 @@ |
270 | 267 | $($('#p-personal ul')[0]).prepend( $li ); |
271 | 268 | } |
272 | 269 | } |
273 | | - } |
| 270 | + }; |
274 | 271 | |
275 | 272 | $( document ).ready( function() { |
276 | 273 | $.webfonts.setup(); |