r100967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100966‎ | r100967 | r100968 >
Date:12:18, 27 October 2011
Author:catrope
Status:deferred
Tags:
Comment:
Followup r100890: add a spinner while loading the shared gadget descriptions. Fake a delay using setTimeout() because the data still isn't loaded using AJAX
Modified paths:
  • /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/modules/ext.gadgets.preferences.css
@@ -1,3 +1,9 @@
 2+/* Hide checkboxes when JS is enabled and descriptions have not yet been loaded */
23 .client-js .mw-gadgetsshared-item-unloaded .mw-input {
34 display: none;
45 }
 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+}
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js
@@ -15,8 +15,9 @@
1616 * @param categoryNames {Object} Map of { categoryID: categoryDescription }
1717 */
1818 function fixPreferenceForm( gadgetsByCategory, categoryNames ) {
19 - var $oldContainer = $( '#mw-prefsection-gadgetsshared .mw-input' ),
 19+ var $oldContainer = $( '#mw-prefsection-gadgetsshared' ).find( '.mw-input' ),
2020 $newContainer = $( '<td>' ).addClass( 'mw-input' ),
 21+ $spinner = $oldContainer.closest( '.mw-gadgetsshared-item-unloaded' ),
2122 category, gadget, $oldItem;
2223 for ( category in gadgetsByCategory ) {
2324 if ( category !== '' ) {
@@ -34,9 +35,8 @@
3536 }
3637 }
3738 $oldContainer.replaceWith( $newContainer );
38 - // Unhide the container by removing the unloaded class
39 - // TODO: We need to have a spinner or something for this
40 - $newContainer.closest( '.mw-gadgetsshared-item-unloaded' ).removeClass( 'mw-gadgetsshared-item-unloaded' );
 39+ // Unhide the container by removing the unloaded class, and remove the spinner too
 40+ $spinner.removeClass( 'mw-gadgetsshared-item-unloaded mw-ajax-loader' );
4141 }
4242
4343 // Temporary testing data
@@ -57,6 +57,12 @@
5858 }
5959 };
6060
61 - $( function() { fixPreferenceForm( gadgetsByCategory, categoryNames ) } );
 61+ $( function() {
 62+ // TODO make all of this nicer once we have AJAX
 63+ // Add spinner
 64+ $( '#mw-prefsection-gadgetsshared').find( '.mw-gadgetsshared-item-unloaded' ).addClass( 'mw-ajax-loader' );
 65+ // Simulate AJAX delay
 66+ setTimeout( function() { fixPreferenceForm( gadgetsByCategory, categoryNames ) }, 2000 );
 67+ } );
6268
6369 } )( jQuery );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100890[RL2] Make the shared gadgets tab on the preferences page work. This changes ...catrope22:26, 26 October 2011

Status & tagging log