Index: trunk/extensions/WebFonts/js/webfonts.js |
— | — | @@ -1,5 +1,12 @@ |
2 | 2 | (function($){ |
3 | 3 | |
| 4 | + function fontID(font) { |
| 5 | + if ( typeof font !== 'string' ) { |
| 6 | + return font; |
| 7 | + } |
| 8 | + return "webfont-"+font.toLowerCase().replace(/[_ ]/g, '-').replace(/[^-a-z]/g, ''); |
| 9 | + } |
| 10 | + |
4 | 11 | $.webfonts = { |
5 | 12 | |
6 | 13 | oldconfig: false, |
— | — | @@ -163,7 +170,7 @@ |
164 | 171 | if (cookie_font && cookie_font !== 'none') { |
165 | 172 | $.webfonts.set(cookie_font); |
166 | 173 | //mark it as checked |
167 | | - $('#webfont-'+cookie_font).attr('checked', 'checked'); |
| 174 | + $('#'+fontID(cookie_font)).attr('checked', 'checked'); |
168 | 175 | } |
169 | 176 | |
170 | 177 | //if there are tags with font-family style definition, get a list of fonts to be loaded |
— | — | @@ -197,11 +204,11 @@ |
198 | 205 | }); |
199 | 206 | for ( var scheme in config ) { |
200 | 207 | var $fontLink = $( '<input type="radio" name="font" />' ) |
201 | | - .attr("id","webfont-"+config[scheme]) |
| 208 | + .attr("id",fontID(config[scheme])) |
202 | 209 | .val( config[scheme] ); |
203 | 210 | |
204 | 211 | var $fontLabel = $( '<label />' ) |
205 | | - .attr("for","webfont-"+config[scheme]) |
| 212 | + .attr("for",fontID(config[scheme])) |
206 | 213 | .append( $fontLink ) |
207 | 214 | .append( config[scheme] ); |
208 | 215 | |