r100853 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100852‎ | r100853 | r100854 >
Date:19:32, 26 October 2011
Author:catrope
Status:deferred
Tags:
Comment:
[RL2] Make the JS that build the shared gadgets preferences form will now save preferences and restore the saved values. The code is very hacky and embarrassing, I'll fix that soon
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.hooks.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.hooks.php
@@ -297,7 +297,9 @@
298298 $preferences['gadgets-shared'] =
299299 array(
300300 'type' => 'multiselect',
301 - 'options' => array(), // TODO: Maybe fill in stuff anyway? The backend may need that
 301+ //'options' => array(), // TODO: Maybe fill in stuff anyway? The backend may need that
 302+ 'options' => array_combine( explode( '|', $GLOBALS['wgRequest']->getVal( 'ryanscrewedchadover' ) ),
 303+ explode( '|', $GLOBALS['wgRequest']->getVal( 'ryanscrewedchadover2' ) ) ),
302304 'section' => 'gadgets-shared',
303305 'label' => ' ',
304306 'prefix' => 'gadget-',
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js
@@ -15,12 +15,16 @@
1616 'id': 'mw-input-wpgadgets-shared-' + id,
1717 'value': id
1818 } );
 19+ if ( mw.user.options.get( 'gadget-' + id ) == "1" ) {
 20+ $input.prop( 'checked', true );
 21+ }
1922 $label = $( '<label>', { for: 'mw-input-wpgadgets-shared-' + id } )
2023 .text( text );
2124 return $div.append( $input ).append( '&nbsp;' ).append( $label );
2225 }
2326
2427 function buildForm( gadgetsByCategory, categoryNames ) {
 28+ var ryanscrewedchadover = [], ryanscrewedchadover2 = [];
2529 var $container = $( '#mw-prefsection-gadgets-shared .mw-input' ),
2630 // Detach the container from the DOM, so we can fill it without visible build-up.
2731 // This is faster, too. In order to put it back where it was, we need to store its parent.
@@ -33,10 +37,14 @@
3438 }
3539 for ( var gadget in gadgetsByCategory[category] ) {
3640 $container.append( buildPref( gadget, gadgetsByCategory[category][gadget] ) );
 41+ ryanscrewedchadover.push( 'wpgadgets-shared-id-' + gadget );
 42+ ryanscrewedchadover2.push( gadgetsByCategory[category][gadget] );
3743 }
3844 }
3945 // Re-attach the container
4046 $containerParent.append( $container );
 47+ $containerParent.closest( 'form' ).append( $( '<input>' ).attr( { 'type': 'hidden', 'name': 'ryanscrewedchadover' } ).val( ryanscrewedchadover.join( '|' ) ) );
 48+ $containerParent.closest( 'form' ).append( $( '<input>' ).attr( { 'type': 'hidden', 'name': 'ryanscrewedchadover2' } ).val( ryanscrewedchadover2.join( '|' ) ) );
4149 }
4250
4351 // Temporary testing data

Follow-up revisions

RevisionCommit summaryAuthorDate
r100855[RL2] Make the checkbox with the empty label on the shared preferences tab go...catrope19:34, 26 October 2011
r100890[RL2] Make the shared gadgets tab on the preferences page work. This changes ...catrope22:26, 26 October 2011

Status & tagging log