r102759 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102758‎ | r102759 | r102760 >
Date:07:21, 11 November 2011
Author:santhosh
Status:ok
Tags:
Comment:
mw.util.addCSS will not work for IE if the css is font-face style. IE crashes.
Reverting to old way of adding css.

http://stackoverflow.com/questions/7931658/dynamically-adding-font-face-rule-in-ie-8-and-less
Modified paths:
  • /trunk/extensions/WebFonts/WebFonts.php (modified) (history)
  • /trunk/extensions/WebFonts/resources/ext.webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.js
@@ -105,7 +105,7 @@
106106 var base = mw.config.get( 'wgExtensionAssetsPath' ) + '/WebFonts/fonts/';
107107 var fontFormats = [];
108108 var styleString =
109 - "@font-face {\n"
 109+ "<style type='text/css'>\n@font-face {\n"
110110 + "\tfont-family: '"+fontFamily+"';\n";
111111
112112 if ( 'eot' in fontconfig ) {
@@ -134,10 +134,10 @@
135135 }
136136
137137 styleString += fontFormats.join() + ";\n"
138 - styleString += "\tfont-weight: normal;\n}\n";
 138+ styleString += "\tfont-weight: normal;\n}\n</style>\n";
139139
140 - //inject the css to the head of the page.
141 - mw.util.addCSS( styleString );
 140+ //inject the css to the head of the page.
 141+ $( styleString ).appendTo( 'head' );
142142 },
143143
144144 /**
Index: trunk/extensions/WebFonts/WebFonts.php
@@ -46,7 +46,7 @@
4747 'localBasePath' => $dir,
4848 'remoteExtPath' => 'WebFonts',
4949 'messages' => array( 'webfonts-load', 'webfonts-reset' ),
50 - 'dependencies' => array( 'mediawiki.util', 'jquery.cookie', 'ext.webfonts.fontlist'),
 50+ 'dependencies' => array( 'jquery.cookie', 'ext.webfonts.fontlist'),
5151 );
5252
5353 $wgResourceModules['ext.webfonts.fontlist'] = array(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102754Better the css construction using array of fontformats and then joining....santhosh05:15, 11 November 2011

Status & tagging log