r102617 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102616‎ | r102617 | r102618 >
Date:02:10, 10 November 2011
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
[WebFonts] minor fixes:
* adding function documentation
* adding missing argument in addVariables-hook
* fix Uncaught ReferenceError for legacy globals, using mw.config instead
-- Also removes need for 'null' fallback as mw.config.get does this already :)
Modified paths:
  • /trunk/extensions/WebFonts/WebFonts.hooks.php (modified) (history)
  • /trunk/extensions/WebFonts/WebFonts.php (modified) (history)
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -10,7 +10,7 @@
1111 $.webfonts = {
1212
1313 oldconfig: false,
14 - config : $.webfonts.config,
 14+ config: $.webfonts.config,
1515 /* Version number */
1616 version: "0.1.2",
1717 fonts : [],
@@ -147,7 +147,7 @@
148148 * keep track of added fonts.
149149 * @param fontFamilyName The fontfamily name
150150 */
151 - addFont : function( fontFamilyName ) {
 151+ addFont: function( fontFamilyName ) {
152152 // avoid duplication
153153 if ( $.inArray( fontFamilyName, $.webfonts.fonts ) < 0 ){
154154 // check whether the requested font is available.
@@ -165,8 +165,7 @@
166166 setup: function() {
167167 var config = [];
168168 var languages = $.webfonts.config.languages;
169 - var userVariant = (typeof wgUserVariant != 'undefined' )? wgUserVariant : null;
170 - var requested = [userVariant, wgContentLanguage, wgUserLanguage];
 169+ var requested = [mw.config.get( 'wgUserVariant' ), mw.config.get( 'wgContentLanguage' ), mw.config.get( 'wgUserLanguage' )];
171170 if ( mw.config.get( 'wgWebFontsEnabledByDefault' ) == false ) {
172171 // Webfonts are not enabled by default. Not setting up.
173172 // This is applicable only for anonymous users.
Index: trunk/extensions/WebFonts/WebFonts.php
@@ -27,6 +27,7 @@
2828 );
2929
3030 $dir = dirname( __FILE__ );
 31+
3132 // Internationalization
3233 $wgExtensionMessagesFiles['WebFonts'] = "$dir/WebFonts.i18n.php";
3334
Index: trunk/extensions/WebFonts/WebFonts.hooks.php
@@ -8,6 +8,10 @@
99
1010 // WebFonts hooks
1111 class WebFontsHooks {
 12+
 13+ /**
 14+ * BeforePageDisplay hook handler.
 15+ */
1216 public static function addModules( $out, $skin ) {
1317 global $wgUser;
1418
@@ -15,10 +19,13 @@
1620 $out->addModules( 'webfonts' );
1721 }
1822
19 - return true; // Hooks must return value
 23+ return true;
2024 }
2125
22 - public static function addVariables( &$vars ) {
 26+ /**
 27+ * MakeGlobalVariablesScript hook handler.
 28+ */
 29+ public static function addVariables( &$vars, $out ) {
2330 global $wgWebFontsEnabledByDefault, $wgUser;
2431
2532 if ( $wgUser->isAnon() ) {
@@ -29,7 +36,10 @@
3037
3138 return true;
3239 }
33 -
 40+
 41+ /**
 42+ * GetPreferences hook handler.
 43+ */
3444 public static function addPreference( $user, &$preferences ) {
3545 global $wgUser;
3646 // A checkbox in preferences to enable WebFonts

Comments

#Comment by Krinkle (talk | contribs)   02:12, 10 November 2011
#Comment by Krinkle (talk | contribs)   18:20, 10 November 2011

Section removed in r102646 entirely.

Status & tagging log