r101367 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101366‎ | r101367 | r101368 >
Date:17:08, 31 October 2011
Author:catrope
Status:deferred
Tags:
Comment:
[RL2] Fixes for r101364
* Namespace the preferences section names for categories per repo, so category naming collisions between repos won't cause issues
* Update showPreferenceFormError() to work with the new HTML layout
* Tweak the AJAX error message to reflect that categorization isn't done through AJAX any more
* Kill the spinner stuff and leave a TODO for it. Adding a spinner in the current HTML layout is non-trivial AFAICT
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.hooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/Gadgets.i18n.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.css (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.i18n.php
@@ -28,7 +28,7 @@
2929 Administrators manage the [[Special:Gadgets|gadget definitions, titles and descriptions]] of available gadgets.',
3030 'gadgets-preference-description' => '$1: $2',
3131 'gadgets-sharedprefstext' => 'Below is a list of gadgets from other wikis. TODO: This needs more text',
32 - 'gadgets-sharedprefs-ajaxerror' => 'An error occurred while attempting to fetch category and description information for shared gadgets. The gadgets below are shown uncategorized and without descriptions or proper titles.',
 32+ 'gadgets-sharedprefs-ajaxerror' => 'An error occurred while attempting to fetch category and description information for shared gadgets. The gadgets and categories below do not have their proper titles.',
3333
3434 # For Special:Gadgets
3535 // General
Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php
@@ -259,7 +259,7 @@
260260 foreach ( $byCategory as $category => $gadgets ) {
261261 foreach ( $gadgets as $gadget ) {
262262 $id = $gadget->getId();
263 - $sectionCat = $category === '' ? '' : "/gadgetcategory-$category";
 263+ $sectionCat = $category === '' ? '' : "/gadgetcategory-$repoSource-$category";
264264 if ( $repo->isLocal() ) {
265265 // For local gadgets we have all the information
266266 $title = htmlspecialchars( $gadget->getTitleMessage() );
@@ -280,7 +280,7 @@
281281 $preferences["gadget-$id"] = array(
282282 'type' => 'toggle',
283283 'label' => htmlspecialchars( $id ), // will be changed by JS
284 - // TODO the below means source and category IDs can't contain slashes, enforce this
 284+ // TODO the below means source and category IDs can't contain slashes or dashes, enforce this
285285 'section' => "gadgetsshared/gadgetrepo-$repoSource$sectionCat",
286286 'cssclass' => 'mw-gadgets-shared-pref',
287287 //'default' => $gadget->isEnabledForUser( $user ), // TODO: should we honor 'default' for remote gadgets?
@@ -295,7 +295,7 @@
296296
297297 public static function preferencesGetLegend( $form, $key, &$legend ) {
298298 $matches = null;
299 - if ( preg_match( '/^(gadgetcategory|gadgetrepo)-(.*)$/', $key, $matches ) ) {
 299+ if ( preg_match( '/^(gadgetrepo|gadgetcategory-.*?)-(.*)$/', $key, $matches ) ) {
300300 // Just display the ID itself (with ucfirst applied)
301301 // This will be changed to a properly i18ned string by JS
302302 $legend = $form->getLang()->ucfirst( $matches[2] );
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.css
@@ -1,9 +1 @@
2 -/* Hide checkboxes when JS is enabled and descriptions have not yet been loaded */
3 -.client-js .mw-gadgetsshared-item-unloaded .mw-input {
4 - display: none;
5 -}
6 -
7 -/* When the wrapping <tr> contains a spinner, increase its height so the spinner isn't cut off */
8 -.client-js .mw-gadgetsshared-item-unloaded.mw-ajax-loader {
9 - height: 32px;
10 -}
 2+/* TODO: spinner CSS */
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js
@@ -11,7 +11,7 @@
1212 for ( category in gadgetsByCategory[repo] ) {
1313 // FIXME HTMLForm isn't namespacing these things, we have to make it do that
1414 // to prevent category naming collisions between repos
15 - $( document.getElementById( 'mw-htmlform-gadgetcategory-' + category ) )
 15+ $( document.getElementById( 'mw-htmlform-gadgetcategory-' + repo + '-' + category ) )
1616 .siblings( 'legend' )
1717 .text( categoryNames[repo][category] );
1818
@@ -33,12 +33,11 @@
3434 * @param msgKey {String} Message key of the error message
3535 */
3636 function showPreferenceFormError( msgKey ) {
37 - var $oldContainer = $( '#mw-prefsection-gadgetsshared' ).find( '.mw-input' ),
38 - $oldContainerTR = $oldContainer.closest( '.mw-gadgetsshared-item-unloaded' ),
 37+ var $table = $( '#mw-htmlform-gadgetsshared' ),
3938 $errorMsg = $( '<p>' ).addClass( 'error' ).text( mw.msg( msgKey ) );
4039
41 - $oldContainerTR
42 - .before( $( '<tr>' ).append( $( '<td>' ).attr( 'colspan', 2 ).append( $errorMsg ) ) )
 40+ $table
 41+ .append( $( '<tr>' ).append( $( '<td>' ).attr( 'colspan', 2 ).append( $errorMsg ) ) )
4342 // Unhide the container and remove the spinner
4443 .removeClass( 'mw-gadgetsshared-item-unloaded mw-ajax-loader' );
4544 }
@@ -86,8 +85,7 @@
8786 $( function() {
8887 var gadgetsByCategory = null, categoryNames = null, failed = false;
8988
90 - // Add spinner
91 - $( '#mw-prefsection-gadgetsshared' ).find( '.mw-gadgetsshared-item-unloaded' ).addClass( 'mw-ajax-loader' );
 89+ // TODO spinner
9290
9391 // Do AJAX requests and call fixPreferenceForm() when done
9492 mw.gadgets.api.getForeignGadgetsData(

Sign-offs

UserFlagDate
Nikerabbitinspected15:19, 24 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101364[RL2] Use fieldsets instead of divs and h1's for sectioning the gadget prefer...catrope16:45, 31 October 2011

Status & tagging log