r102658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102657‎ | r102658 | r102659 >
Date:14:39, 10 November 2011
Author:santhosh
Status:ok (Comments)
Tags:
Comment:
Modified paths:
  • /trunk/extensions/WebFonts/resources/ext.webfonts.css (modified) (history)
  • /trunk/extensions/WebFonts/resources/ext.webfonts.fontlist.js (modified) (history)
  • /trunk/extensions/WebFonts/resources/ext.webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/resources/ext.webfonts.js
@@ -1,6 +1,6 @@
2 -(function($){
 2+( function( $ ) {
33
4 - function fontID(font) {
 4+ function fontID( font ) {
55 if ( typeof font !== 'string' ) {
66 return font;
77 }
@@ -20,31 +20,31 @@
2121 return;
2222 }
2323
24 - if ( !(font in $.webfonts.config.fonts) ) {
 24+ if ( !( font in $.webfonts.config.fonts ) ) {
2525 mw.log( "Requested unknown font", font );
2626 return;
2727 }
2828 var config = $.webfonts.config.fonts[font];
2929
3030 //load the style sheet for the font
31 - $.webfonts.addFont(font);
 31+ $.webfonts.addFont( font );
3232
3333 //save the current font and its size. Used for reset.
3434 if ( !$.webfonts.oldconfig ) {
35 - var $body = $("body");
 35+ var $body = $( 'body' );
3636 $.webfonts.oldconfig = {
37 - "font-family": $body.css('font-family'),
38 - "font-size": $body.css('font-size')
 37+ "font-family": $body.css( 'font-family' ),
 38+ "font-size": $body.css( 'font-size' )
3939 };
4040 }
4141
4242 //Set the font, fallback fonts.Need to change the fonts of Input Select and Textarea explicitly.
43 - $("body, input, select, textarea").css('font-family', "'"+ font +"', Helvetica, Arial, sans-serif");
 43+ $( 'body, input, select, textarea' ).css( 'font-family', "'"+ font +"', Helvetica, Arial, sans-serif" );
4444
4545 if ( 'normalization' in config ) {
46 - $(document).ready(function() {
47 - $.webfonts.normalize(config.normalization);
48 - });
 46+ $( document ).ready( function() {
 47+ $.webfonts.normalize( config.normalization );
 48+ } );
4949 }
5050 //set the font option in cookie
5151 $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } );
@@ -57,16 +57,16 @@
5858 * Reset the font with old configuration
5959 */
6060 reset: function() {
61 - $("body").css({
 61+ $( 'body' ).css( {
6262 'font-family': $.webfonts.oldconfig["font-family"],
6363 //reset the font size from old configuration
64 - 'font-size': $.webfonts.oldconfig["font-size"]
 64+ 'font-size': $.webfonts.oldconfig[ "font-size" ]
6565 });
6666 //we need to reset the fonts of Input and Select explicitly.
67 - $("input, select").css('font-family', $.webfonts.oldconfig["font-family"]);
 67+ $( 'input, select' ).css( 'font-family', $.webfonts.oldconfig["font-family"] );
6868
6969 // Reset the fonts applied for tags with lang attribute.
70 - $(".webfonts-lang-attr").css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' );
 70+ $( '.webfonts-lang-attr' ).css( 'font-family', 'none' ).removeClass( 'webfonts-lang-attr' );
7171
7272 //remove the cookie
7373 $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } );
@@ -76,25 +76,25 @@
7777 * Does a find replace of string on the page.
7878 * @param normalization_rules hashmap of replacement rules.
7979 */
80 - normalize: function(normalization_rules) {
81 - $.each(normalization_rules, function(search, replace) {
82 - var search_pattern = new RegExp(search,"g");
83 - return $("*").each(function() {
 80+ normalize: function( normalizationRules ) {
 81+ $.each( normalizationRules, function( search, replace ) {
 82+ var searchPattern = new RegExp( search,"g" );
 83+ return $( '*' ).each(function() {
8484 var node = this.firstChild,
85 - val, new_val;
 85+ val, newVal;
8686 if ( node ) {
8787 do {
8888 if ( node.nodeType === 3 ) {
8989 val = node.nodeValue;
90 - new_val = val.replace(search_pattern, replace);
91 - if ( new_val !== val ) {
92 - node.nodeValue = new_val;
 90+ newVal = val.replace( searchPattern, replace );
 91+ if ( newVal !== val ) {
 92+ node.nodeValue = newVal;
9393 }
9494 }
9595 } while ( node = node.nextSibling );
9696 }
97 - });
98 - });
 97+ } );
 98+ } );
9999 },
100100
101101 /*
@@ -102,7 +102,7 @@
103103 * so that it gets loaded.
104104 * @param fontfamily The fontfamily name
105105 */
106 - loadcss: function(fontfamily) {
 106+ loadcss: function( fontfamily ) {
107107 var fontconfig = $.webfonts.config.fonts[fontfamily];
108108 var base = mw.config.get( "wgExtensionAssetsPath" ) + "/WebFonts/fonts/";
109109 var styleString =
@@ -133,7 +133,7 @@
134134 styleString += "\tfont-weight: normal;\n}\n</style>\n";
135135
136136 //inject the css to the head of the page.
137 - $(styleString).appendTo("head");
 137+ $( styleString ).appendTo( 'head' );
138138
139139 },
140140
@@ -163,24 +163,24 @@
164164 var languages = $.webfonts.config.languages;
165165 var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )];
166166
167 - for (var i = 0; i < requested.length; i++) {
168 - if (requested[i] in languages) {
 167+ for ( var i = 0; i < requested.length; i++ ) {
 168+ if ( requested[i] in languages ) {
169169 var fonts = languages[requested[i]];
170 - for (var j = 0; j < fonts.length; j++) {
 170+ for ( var j = 0; j < fonts.length; j++) {
171171 if ( $.inArray(fonts[j], config) === -1 ) {
172 - config.push(fonts[j]);
 172+ config.push( fonts[j] );
173173 }
174174 }
175175 }
176176 }
177177
178178 // Build font dropdown
179 - $.webfonts.buildMenu(config);
 179+ $.webfonts.buildMenu( config );
180180 // See if there is a font in cookie if not first font is default font.
181181 var cookieFont = $.cookie( 'webfonts-font' );
182182 var selectedFont = null;
183183 // check whether this font is for the current userlang/contentlang
184 - if ( $.inArray(cookieFont, config) !== -1){
 184+ if ( $.inArray( cookieFont, config ) !== -1){
185185 selectedFont = cookieFont;
186186 }
187187 else{
@@ -196,10 +196,10 @@
197197
198198 $.webfonts.loadFontsForFontFamilyStyle();
199199 $.webfonts.loadFontsForLangAttr();
200 - if ( $(".webfonts-lang-attr").length && !$( '#webfonts-fontsmenu' ).length ){
 200+ if ( $('.webfonts-lang-attr').length && !$( '#webfonts-fontsmenu' ).length ) {
201201 // We need to show the reset option even if there is no font to show
202202 // for the language, if there is lang attr based font embedding.
203 - $.webfonts.buildMenu(config);
 203+ $.webfonts.buildMenu( config );
204204 }
205205 },
206206
@@ -210,7 +210,7 @@
211211 loadFontsForLangAttr: function() {
212212 var languages = $.webfonts.config.languages;
213213 //if there are tags with lang attribute,
214 - $('body').find('*[lang]').each(function(index) {
 214+ $( 'body' ).find( '*[lang]' ).each( function( index ) {
215215 //check the availability of font.
216216 //add a font-family style if it does not have any
217217 if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily == "none" ) ) {
@@ -229,10 +229,10 @@
230230 loadFontsForFontFamilyStyle: function() {
231231 var languages = $.webfonts.config.languages;
232232 //if there are tags with font-family style definition, get a list of fonts to be loaded
233 - $('body').find('*[style]').each(function(index) {
 233+ $( 'body' ).find( '*[style]' ).each(function( index ) {
234234 if( this.style.fontFamily ) {
235 - var fontFamilyItems = this.style.fontFamily.split(",");
236 - $.each( fontFamilyItems, function(index, fontFamily) {
 235+ var fontFamilyItems = this.style.fontFamily.split( "," );
 236+ $.each( fontFamilyItems, function( index, fontFamily ) {
237237 //remove the ' characters if any.
238238 fontFamily = fontFamily.replace(/'/g, '');
239239 $.webfonts.addFont( fontFamily );
@@ -250,9 +250,9 @@
251251 var haveSchemes = false;
252252 // Build font dropdown
253253 var $fontsMenu = $( '<ul>' ).attr('id','webfonts-fontsmenu');
254 - $fontsMenu.delegate('input:radio', 'change', function( event ) {
 254+ $fontsMenu.delegate( 'input:radio', 'change', function( event ) {
255255 $.webfonts.set( $(this).val() );
256 - });
 256+ } );
257257 for ( var scheme in config ) {
258258 var $fontLink = $( '<input type="radio" />' )
259259 .attr( "name", "font" )
@@ -260,7 +260,7 @@
261261 .val( config[scheme] );
262262
263263 var $fontLabel = $( '<label>' )
264 - .attr("for",fontID(config[scheme]))
 264+ .attr( "for",fontID(config[scheme] ) )
265265 .append( $fontLink )
266266 .append( config[scheme] );
267267
@@ -270,7 +270,7 @@
271271
272272 haveSchemes = true;
273273
274 - $fontsMenu.append($fontMenuItem);
 274+ $fontsMenu.append( $fontMenuItem );
275275
276276 }
277277
@@ -281,49 +281,49 @@
282282 }
283283
284284 var $resetLink = $( '<input type="radio" />' )
285 - .attr("name","font")
286 - .attr("value","webfont-none")
287 - .attr("id","webfont-none")
 285+ .attr( "name","font" )
 286+ .attr( "value","webfont-none" )
 287+ .attr( "id","webfont-none" )
288288 .click( function( event ) {
289 - $.webfonts.set( 'none');
 289+ $.webfonts.set( 'none' );
290290 });
291291
292292 var $resetLabel = $( '<label>' )
293 - .attr("for","webfont-none")
 293+ .attr( "for","webfont-none" )
294294 .append( $resetLink )
295 - .append( mw.msg("webfonts-reset"));
 295+ .append( mw.msg("webfonts-reset") );
296296
297297 var $resetLinkItem = $( '<li>' )
298298 .val( 'none' )
299299 .append( $resetLabel );
300300
301 - $fontsMenu.append($resetLinkItem);
 301+ $fontsMenu.append( $resetLinkItem );
302302
303303 var $menuDiv = $( '<div>' ).attr('id','webfonts-fonts')
304304 .addClass( 'menu' )
305305 .append( $fontsMenu )
306306 .append();
307307
308 - var $div = $( '<div>' ).attr('id','webfonts-menu')
 308+ var $div = $( '<div>' ).attr( 'id','webfonts-menu' )
309309 .addClass( 'webfontMenu' )
310 - .append( $('<a>').prop( 'href', '#' ).append( mw.msg( "webfonts-load" ) ) )
 310+ .append( $( '<a>' ).prop( 'href', '#' ).append( mw.msg( "webfonts-load" ) ) )
311311 .append( $menuDiv );
312312
313313 //this is the fonts link
314 - var $li = $( '<li>' ).attr('id','pt-webfont')
 314+ var $li = $( '<li>' ).attr( 'id','pt-webfont' )
315315 .append( $div );
316316
317317 //if rtl, add to the right of top personal links. Else, to the left
318 - var fn = $('body').hasClass( 'rtl' ) ? "append" : "prepend";
319 - $('#p-personal ul:first')[fn]( $li );
 318+ var fn = $( 'body' ).hasClass( 'rtl' ) ? "append" : "prepend";
 319+ $( '#p-personal ul:first' )[fn]( $li );
320320 //workaround for IE bug - activex components like input fields coming on top of everything.
321321 //TODO: is there a better solution other than hiding it on hover?
322322 if ( $.browser.msie ) {
323 - $("#webfonts-menu").hover(function(){
324 - $("#searchform").css({ visibility: "hidden" });
325 - },function(){
326 - $("#searchform").css({ visibility: "visible" });
327 - });
 323+ $( '#webfonts-menu' ).hover( function( ) {
 324+ $( '#searchform' ).css({ visibility: "hidden" } );
 325+ }, function( ) {
 326+ $( '#searchform' ).css( { visibility: "visible" } );
 327+ } );
328328 }
329329 }
330330 };
@@ -332,4 +332,4 @@
333333 $.webfonts.setup();
334334 } );
335335
336 -})(jQuery);
 336+} ) ( jQuery );
Index: trunk/extensions/WebFonts/resources/ext.webfonts.fontlist.js
@@ -3,7 +3,7 @@
44 * First font is the default font for the language
55 */
66
7 -(function ($) {
 7+( function ( $ ) {
88 $.webfonts = {};
99
1010 $.webfonts.config = {
@@ -37,7 +37,6 @@
3838 eot: "Mlym/Meera.eot",
3939 ttf: "Mlym/Meera.ttf",
4040 woff: "Mlym/Meera.woff",
41 - scale: 1.5,
4241 normalization: {
4342 "ൾ": "ള്‍",
4443 "ൻ": "ന്‍",
@@ -317,4 +316,4 @@
318317 cdo: [ "Charis SIL" ]
319318 }
320319 };
321 -})(jQuery);
 320+} ) ( jQuery );
Index: trunk/extensions/WebFonts/resources/ext.webfonts.css
@@ -1,28 +1,28 @@
2 -li#pt-webfont{
 2+li#pt-webfont {
33 /* @embed */
44 background: url(images/font-icon.png) no-repeat scroll left top transparent;
55 padding-left: 15px !important;
66 }
77
8 -div#webfonts-menu{
 8+div#webfonts-menu {
99 font-size: 100%;
1010 z-index: 99999;
1111 }
1212
13 -div#webfonts-fonts{
 13+div#webfonts-fonts {
1414 font-size: 100%;
1515 z-index: 99999;
1616 }
1717
1818
19 -div#webfonts-menu .menu ul{
20 - padding-left:5px!important;
 19+div#webfonts-menu .menu ul {
 20+ padding-left: 5px!important;
2121 }
2222
2323
24 -div#webfonts-fonts li{
 24+div#webfonts-fonts li {
2525 margin: 0;
26 - padding:5px;
 26+ padding: 5px;
2727 font-size: 100%;
2828 float: none;
2929 }
@@ -68,7 +68,8 @@
6969 margin-left: 23px;
7070 }
7171 /* Enable forcing showing of the menu for accessibility */
72 -div.webfontMenu:hover div.menu, div.webfontMenu div.menuForceShow {
 72+div.webfontMenu:hover div.menu,
 73+div.webfontMenu div.menuForceShow {
7374 display: block;
7475 }
7576 div.webfontMenu ul {
@@ -121,6 +122,6 @@
122123 }
123124 div.webfontMenu a {
124125 display: block;
125 - padding-left:5px;
126 - padding-right:5px;
 126+ padding-left: 5px;
 127+ padding-right: 5px;
127128 }

Comments

#Comment by Krinkle (talk | contribs)   18:24, 10 November 2011

<source lang="diff">

  1. webfonts.fontlist.js

- scale: 1.5, </diff>

Since the scale propery isnt used anywhere I assume this was intentionally removed.

Eveyrything else looks good, marking ok.

#Comment by Krinkle (talk | contribs)   18:25, 10 November 2011
# webfonts.fontlist.js
 
-				scale: 1.5,

Since the scale propery isnt used anywhere I assume this was intentionally removed.

Eveyrything else looks good, marking ok.

#Comment by Nikerabbit (talk | contribs)   20:13, 10 November 2011

It was left-over remnant of feature that was already removed earlier.

Status & tagging log