r51743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51742‎ | r51743 | r51744 >
Date:14:11, 11 June 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: Add JS+CSS in intercept() rather than initialize(); code depended on two functions attached to the same hook being called in a particular order, which is scary and worked only by accident. Now adding toolbar JS+CSS only if the toolbar is actually shown.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.php
@@ -43,4 +43,4 @@
4444
4545 // Registers Hooks
4646 $wgHooks['AjaxAddScript'][] = 'UsabilityInitiativeHooks::addJs';
47 -$wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addCss';
\ No newline at end of file
 47+$wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addCss';
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -51,6 +51,3 @@
5252 // Registers Hooks
5353 $wgHooks['EditPageBeforeEditToolbar'][] = 'EditToolbarHooks::intercept';
5454 $wgHooks['GetPreferences'][] = 'EditToolbarHooks::addPreferences';
55 -
56 -// Registers Hooks
57 -$wgHooks['AjaxAddScript'][] = 'EditToolbarHooks::initialize';
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php
@@ -37,6 +37,15 @@
3838 }
3939 // Replaces stock toolbar with new toolbar container
4040 $toolbar = '<div id="edittoolbar"></div>';
 41+
 42+ // Add JS and CSS
 43+ global $wgEditToolbarStyleVersion;
 44+ UsabilityInitiativeHooks::addScript(
 45+ 'EditToolbar/EditToolbar.js', $wgEditToolbarStyleVersion
 46+ );
 47+ UsabilityInitiativeHooks::addStyle(
 48+ 'EditToolbar/EditToolbar.css', $wgEditToolbarStyleVersion
 49+ );
4150 // Internationalization
4251 wfLoadExtensionMessages( 'EditToolbar' );
4352 // Adds messages to page
@@ -190,23 +199,4 @@
191200 }
192201 return true;
193202 }
194 -
195 - /**
196 - * AjaxAddScript hook
197 - * Initializes the component
198 - */
199 - public static function initialize() {
200 - global $wgEditToolbarStyleVersion;
201 -
202 - // Add script to document
203 - UsabilityInitiativeHooks::addScript(
204 - 'EditToolbar/EditToolbar.js', $wgEditToolbarStyleVersion
205 - );
206 - // Add style to document
207 - UsabilityInitiativeHooks::addStyle(
208 - 'EditToolbar/EditToolbar.css', $wgEditToolbarStyleVersion
209 - );
210 - // Continue
211 - return true;
212 - }
213203 }

Status & tagging log