r88037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88036‎ | r88037 | r88038 >
Date:09:49, 14 May 2011
Author:siebrand
Status:deferred
Tags:
Comment:
Run stylize.php.
Modified paths:
  • /trunk/extensions/WebFonts/WebFonts.config.php (modified) (history)
  • /trunk/extensions/WebFonts/WebFonts.php (modified) (history)
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/WebFonts.config.php
@@ -34,7 +34,7 @@
3535 "ൾ" => "ള്‍",
3636 "ൻ" => "ന്‍",
3737 "ർ" => "ര്‍",
38 - "ൺ "=> "ണ്‍",
 38+ "ൺ " => "ണ്‍",
3939 "ൽ" => "ല്‍",
4040 "ൿ" => "ക്‍ ",
4141 "ൻ‍റ" => "ന്റ",
@@ -51,7 +51,7 @@
5252 "ൾ" => "ള്‍",
5353 "ൻ" => "ന്‍",
5454 "ർ" => "ര്‍",
55 - "ൺ "=> "ണ്‍",
 55+ "ൺ " => "ണ്‍",
5656 "ൽ" => "ല്‍",
5757 "ൿ" => "ക്‍ ",
5858 "ൻ‍റ" => "ന്റ",
@@ -67,7 +67,7 @@
6868 "ൾ" => "ള്‍",
6969 "ൻ" => "ന്‍",
7070 "ർ" => "ര്‍",
71 - "ൺ "=> "ണ്‍",
 71+ "ൺ " => "ണ്‍",
7272 "ൽ" => "ല്‍",
7373 "ൿ" => "ക്‍ ",
7474 "ൻ‍റ" => "ന്റ",
@@ -82,7 +82,7 @@
8383 "ൾ" => "ള്‍",
8484 "ൻ" => "ന്‍",
8585 "ർ" => "ര്‍",
86 - "ൺ "=> "ണ്‍",
 86+ "ൺ " => "ണ്‍",
8787 "ൽ" => "ല്‍",
8888 "ൿ" => "ക്‍ ",
8989 "ൻ‍റ" => "ന്റ",
@@ -144,7 +144,7 @@
145145 'ttf' => "$fontsPath/he/TaameyFrankCLM.ttf",
146146 'woff' => "$fontsPath/he/TaameyFrankCLM.woff",
147147 'svg' => "$fontsPath/he/TaameyFrankCLM.svg",
148 - ),
 148+ ),
149149 'Kedage' => array(
150150 'eot' => "$fontsPath/kn/Kedage.eot",
151151 'ttf' => "$fontsPath/kn/Kedage.ttf",
@@ -179,13 +179,13 @@
180180 'woff' => "$fontsPath/my/Yunghkio.woff",
181181 'svg' => "$fontsPath/my/Yunghkio.svg",
182182 ),
183 - 'KhmerOSbattambang'=> array(
 183+ 'KhmerOSbattambang' => array(
184184 'eot' => "$fontsPath/km/KhmerOSbattambang.eot",
185185 'ttf' => "$fontsPath/km/KhmerOSbattambang.ttf",
186186 'woff' => "$fontsPath/km/KhmerOSbattambang.woff",
187187 'svg' => "$fontsPath/km/KhmerOSbattambang.svg",
188188 ),
189 - 'KhmerOSbokor'=> array(
 189+ 'KhmerOSbokor' => array(
190190 'eot' => "$fontsPath/km/KhmerOSbokor.eot",
191191 'ttf' => "$fontsPath/km/KhmerOSbokor.ttf",
192192 'woff' => "$fontsPath/km/KhmerOSbokor.woff",
@@ -241,21 +241,21 @@
242242 ),
243243
244244 'languages' => array(
245 - //'en' => array( 'RufScript', 'Perizia', 'Ubuntu' ),
246 - 'ml' => array( 'Meera', 'Rachana' , 'Dyuthi', 'RaghuMalayalam'),
247 - 'or' => array( 'Lohit Oriya'),
248 - 'ta' => array( 'Lohit Tamil'),
249 - 'te' => array( 'Lohit Telugu'),
250 - 'bn' => array( 'Lohit Bengali'),
251 - 'as' => array( 'Lohit Bengali'),
252 - 'gu' => array( 'Samyak Gujarati'),
253 - 'hi' => array( 'Samyak Devanagari', 'Lohit Hindi'),
254 - 'mr' => array( 'Samyak Devanagari', 'Lohit Hindi'),
255 - 'ks' => array( 'Samyak Devanagari', 'Lohit Hindi'),
256 - 'he' => array( 'Ezra SIL', 'David CLM','Hadasim CLM', 'Taamey Frank CLM'),
257 - 'kn' => array( 'Kedage', 'Lohit Kannada'),
258 - 'my' => array( 'Masterpiece Uni Sans','Padauk-Regular','Myanmar3','Yunghkio'),
259 - 'km' => array('KhmerOSbattambang', 'KhmerOSsiemreap', 'KhmerOS', 'KhmerOSbokor', 'KhmerOSmuollight', 'KhmerOSmuol','KhmerOSmuolpali', 'KhmerOSfreehand', 'KhmerOSfasthand'),
260 - 'saz' => array('Pagul'),
 245+ // 'en' => array( 'RufScript', 'Perizia', 'Ubuntu' ),
 246+ 'ml' => array( 'Meera', 'Rachana' , 'Dyuthi', 'RaghuMalayalam' ),
 247+ 'or' => array( 'Lohit Oriya' ),
 248+ 'ta' => array( 'Lohit Tamil' ),
 249+ 'te' => array( 'Lohit Telugu' ),
 250+ 'bn' => array( 'Lohit Bengali' ),
 251+ 'as' => array( 'Lohit Bengali' ),
 252+ 'gu' => array( 'Samyak Gujarati' ),
 253+ 'hi' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
 254+ 'mr' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
 255+ 'ks' => array( 'Samyak Devanagari', 'Lohit Hindi' ),
 256+ 'he' => array( 'Ezra SIL', 'David CLM', 'Hadasim CLM', 'Taamey Frank CLM' ),
 257+ 'kn' => array( 'Kedage', 'Lohit Kannada' ),
 258+ 'my' => array( 'Masterpiece Uni Sans', 'Padauk-Regular', 'Myanmar3', 'Yunghkio' ),
 259+ 'km' => array( 'KhmerOSbattambang', 'KhmerOSsiemreap', 'KhmerOS', 'KhmerOSbokor', 'KhmerOSmuollight', 'KhmerOSmuol', 'KhmerOSmuolpali', 'KhmerOSfreehand', 'KhmerOSfasthand' ),
 260+ 'saz' => array( 'Pagul' ),
261261 ),
262262 );
Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -10,7 +10,7 @@
1111 $.webfonts.reset();
1212 return;
1313 }
14 -
 14+
1515 var config = mw.config.get( "wgWebFonts" );
1616 if ( !font in config.fonts ) {
1717 console.log( "Requested unknown font", font );
@@ -18,8 +18,8 @@
1919 } else {
2020 config = config.fonts[font];
2121 }
22 -
23 - var styleString =
 22+
 23+ var styleString =
2424 "<style type='text/css'>\n@font-face {\n"
2525 + "\tfont-family: '"+font+"';\n";
2626 if ( 'eot' in config ) {
@@ -27,7 +27,7 @@
2828 }
2929 //If the font is present locally, use it.
3030 styleString += "\tsrc: local('"+ font +"'),";
31 -
 31+
3232 if ( 'woff' in config ) {
3333 styleString += "\t\turl('"+config.woff+"') format('woff'),";
3434 }
@@ -37,10 +37,10 @@
3838 if ( 'ttf' in config ) {
3939 styleString += "\t\turl('"+config.ttf+"') format('truetype');\n";
4040 }
41 -
 41+
4242 styleString += "\tfont-weight: normal;\n}\n</style>\n";
4343 $(styleString).appendTo("head" );
44 -
 44+
4545 //save the current font and its size. Used for reset.
4646 if ( !$.webfonts.oldconfig ) {
4747 $.webfonts.oldconfig = {
@@ -48,19 +48,19 @@
4949 "font-size": $("body").css('font-size')
5050 }
5151 }
52 -
 52+
5353 //Set the font, fallback fonts
5454 $("body").css('font-family', font +", Helvetica, Arial, sans-serif");
5555 //we need to change the fonts of Input and Select explicitly.
5656 $("input").css('font-family', font +", Helvetica, Arial, sans-serif");
5757 $("select").css('font-family', font +", Helvetica, Arial, sans-serif");
58 -
 58+
5959 //scale the font of the page. Scale is in percentage.
6060 // For example scale = 1.2 means scale the font by 120 percentage
6161 if ( 'scale' in config ) {
6262 $.webfonts.scale("body", config.scale);
6363 }
64 -
 64+
6565 if ( 'normalization' in config ) {
6666 $(document).ready(function() {
6767 $.webfonts.normalize(config.normalization);
@@ -69,7 +69,7 @@
7070 //set the font option in cookie
7171 $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } );
7272 },
73 -
 73+
7474 /**
7575 * Reset the font with old configuration
7676 */
@@ -83,7 +83,7 @@
8484 //remove the cookie
8585 $.cookie( 'webfonts-font', 'none' );
8686 },
87 -
 87+
8888 /**
8989 * Scale the font of the page by given percentage
9090 * @param selecter CSS selector
@@ -95,35 +95,35 @@
9696 $(this).css("font-size", Math.round( currentSize * percentage));
9797 });
9898 },
99 -
 99+
100100 /**
101101 * Does a find replace of string on the page.
102102 * @param normalization_rules hashmap of replacement rules.
103103 */
104104 normalize: function(normalization_rules){
105 - $.each(normalization_rules, function(search, replace) {
 105+ $.each(normalization_rules, function(search, replace) {
106106 var search_pattern = new RegExp(search,"g");
107 - return $("*").each(function(){
108 - var node = this.firstChild,
109 - val,
 107+ return $("*").each(function(){
 108+ var node = this.firstChild,
 109+ val,
110110 new_val;
111 - if ( node ) {
112 - do {
113 - if ( node.nodeType === 3 ) {
114 - val = node.nodeValue;
115 - new_val = val.replace(search_pattern, replace );
116 - if ( new_val !== val ) {
117 - node.nodeValue = new_val;
118 - }
119 - }
120 - } while ( node = node.nextSibling );
121 - }
122 - });
 111+ if ( node ) {
 112+ do {
 113+ if ( node.nodeType === 3 ) {
 114+ val = node.nodeValue;
 115+ new_val = val.replace(search_pattern, replace );
 116+ if ( new_val !== val ) {
 117+ node.nodeValue = new_val;
 118+ }
 119+ }
 120+ } while ( node = node.nextSibling );
 121+ }
 122+ });
123123 });
124124 },
125 -
 125+
126126 setup: function() {
127 -
 127+
128128 var config = mw.config.get( "wgWebFontsAvailable" );
129129 // Build font dropdown
130130 $fontsmenu = $( '<ul />' ).attr('id','webfonts-fontsmenu');
@@ -133,12 +133,12 @@
134134 .attr("name","font")
135135 .attr("id","webfont-"+config[scheme])
136136 .attr("value",config[scheme] );
137 -
 137+
138138 $fontmenuitem = $( '<li />' )
139139 .val( config[scheme] )
140140 .append( $fontlink )
141141 .append( config[scheme] );
142 -
 142+
143143 haveSchemes = true;
144144 //some closure trick :)
145145 (function (font) {
@@ -155,36 +155,36 @@
156156 .attr("value","webfont-none")
157157 .click( function( event ) {
158158 $.webfonts.set( 'none');
159 - });
 159+ });
160160 $resetlinkitem = $( '<li />' )
161161 .val( 'none')
162 - .append( $resetlink )
 162+ .append( $resetlink )
163163 .append( mw.msg("webfonts-reset"));
164 -
 164+
165165 $fontsmenu.append($resetlinkitem);
166166
167167 if ( !haveSchemes ) {
168168 // No schemes available, don't show the tool
169169 return;
170170 }
171 -
 171+
172172 var $menudiv = $( '<div />' ).attr('id','webfonts-fonts')
173173 .addClass( 'menu' )
174174 .append( $fontsmenu )
175175 .append();
176 -
 176+
177177 var $div = $( '<div />' ).attr('id','webfonts-menu')
178178 .addClass( 'webfontMenu' )
179179 .append( "<a href='#'>"+ mw.msg("webfonts-load")+"</a>")
180180 .append( $menudiv );
181 -
 181+
182182 //this is the fonts link
183183 var $li = $( '<li />' )
184184 .append( $div );
185 -
 185+
186186 //add to the left of top personal links
187187 $($( '#p-personal ul' )[0]).prepend( $li );
188 -
 188+
189189 //see if there is a font in cookie
190190 cookie_font = $.cookie('webfonts-font');
191191 if(cookie_font == null){
@@ -202,7 +202,7 @@
203203 }
204204
205205 }
206 -
 206+
207207 $( document ).ready( function() {
208208 $.webfonts.setup();
209209 } );
Index: trunk/extensions/WebFonts/WebFonts.php
@@ -13,7 +13,7 @@
1414 * @licence GNU General Public Licence 3.0 or later
1515 */
1616
17 -if( !defined( 'MEDIAWIKI' ) ) {
 17+if ( !defined( 'MEDIAWIKI' ) ) {
1818 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1919 die( -1 );
2020 }
@@ -21,12 +21,12 @@
2222 $wgExtensionCredits['parserhook'][] = array(
2323 'path' => __FILE__,
2424 'name' => 'WebFonts',
25 - 'author' => array( 'Santhosh Thottingal', 'Niklas Laxström'),
 25+ 'author' => array( 'Santhosh Thottingal', 'Niklas Laxström' ),
2626 'url' => 'http://www.mediawiki.org/wiki/Extension:WebFonts',
2727 'descriptionmsg' => 'webfonts-desc',
2828 );
2929
30 -$dir = dirname(__FILE__);
 30+$dir = dirname( __FILE__ );
3131 // Internationalization
3232 $wgExtensionMessagesFiles['WebFonts'] = "$dir/WebFonts.i18n.php";
3333
@@ -46,5 +46,5 @@
4747 'styles' => 'css/webfonts.css',
4848 'localBasePath' => dirname( __FILE__ ),
4949 'remoteExtPath' => 'WebFonts',
50 - 'messages' => array( 'webfonts-load', 'webfonts-reset'),
 50+ 'messages' => array( 'webfonts-load', 'webfonts-reset' ),
5151 );

Status & tagging log