http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95858
Revision: 95858
Author: dantman
Date: 2011-08-31 12:30:40 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
Use a fontID function that cleans up font names into a format that is
acceptable to be located in an id="". Previously fonts with spaces would have
spaces in the id resulting in jQuery selects that had a space breaking the
select and not checking off the radio button.
Modified Paths:
--------------
trunk/extensions/WebFonts/js/webfonts.js
Modified: trunk/extensions/WebFonts/js/webfonts.js
===================================================================
--- trunk/extensions/WebFonts/js/webfonts.js 2011-08-31 12:22:21 UTC (rev
95857)
+++ trunk/extensions/WebFonts/js/webfonts.js 2011-08-31 12:30:40 UTC (rev
95858)
@@ -1,5 +1,12 @@
(function($){
+ function fontID(font) {
+ if ( typeof font !== 'string' ) {
+ return font;
+ }
+ return "webfont-"+font.toLowerCase().replace(/[_ ]/g,
'-').replace(/[^-a-z]/g, '');
+ }
+
$.webfonts = {
oldconfig: false,
@@ -163,7 +170,7 @@
if (cookie_font && cookie_font !== 'none') {
$.webfonts.set(cookie_font);
//mark it as checked
- $('#webfont-'+cookie_font).attr('checked',
'checked');
+ $('#'+fontID(cookie_font)).attr('checked',
'checked');
}
//if there are tags with font-family style definition,
get a list of fonts to be loaded
@@ -197,11 +204,11 @@
});
for ( var scheme in config ) {
var $fontLink = $( '<input type="radio"
name="font" />' )
- .attr("id","webfont-"+config[scheme])
+ .attr("id",fontID(config[scheme]))
.val( config[scheme] );
var $fontLabel = $( '<label />' )
- .attr("for","webfont-"+config[scheme])
+ .attr("for",fontID(config[scheme]))
.append( $fontLink )
.append( config[scheme] );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs