r98072 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98071‎ | r98072 | r98073 >
Date:17:49, 25 September 2011
Author:catrope
Status:ok
Tags:
Comment:
MoodBar: Add a spinner for the More link, hide the link while the query is in progress, and display a "No more results" text if there are no more results to show. The latter needs styling
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -85,6 +85,7 @@
8686 'moodbar-feedback-permalink' => 'link to here',
8787 'moodbar-feedback-noresults' => 'There are no comments that match your filters.',
8888 'moodbar-feedback-more' => 'More',
 89+ 'moodbar-feedback-nomore' => 'There are no more results to show',
8990 'moodbar-feedback-newer' => 'Newer',
9091 'moodbar-feedback-older' => 'Older',
9192 // Mood types
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
@@ -1,20 +1,27 @@
22 jQuery( function( $ ) {
3 - $( '#fbd-list-more a' ).click( function( e ) {
 3+ $( '#fbd-list-more').children( 'a' ).click( function( e ) {
44 e.preventDefault();
55
6 - // TODO spinner
7 -
86 var limit = 20,
97 username = $( '#fbd-filters-username' ).val(),
108 types = [],
11 - reqData = {
12 - 'action': 'query',
13 - 'list': 'moodbarcomments',
14 - 'format': 'json',
15 - 'mbcprop': 'formatted',
16 - 'mbclimit': limit + 2, // we drop the first and last result
17 - 'mbccontinue': $( '#fbd-list li:last' ).data( 'mbccontinue' )
18 - };
 9+ reqData;
 10+
 11+ // Hide the "More" link and put in a spinner
 12+ $( '#fbd-list-more' )
 13+ .addClass( 'mw-ajax-loader' )
 14+ .children( 'a' )
 15+ .css( 'visibility', 'hidden' ); // using .hide() messes up the layout
 16+
 17+ // Build the API request
 18+ reqData = {
 19+ 'action': 'query',
 20+ 'list': 'moodbarcomments',
 21+ 'format': 'json',
 22+ 'mbcprop': 'formatted',
 23+ 'mbclimit': limit + 2, // we drop the first and last result
 24+ 'mbccontinue': $( '#fbd-list').find( 'li:last' ).data( 'mbccontinue' )
 25+ };
1926 $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() {
2027 if ( $(this).prop( 'checked' ) ) {
2128 types.push( $(this).val() );
@@ -27,7 +34,6 @@
2835 reqData['mbcuser'] = username;
2936 }
3037
31 - // TODO save jqXhr and protect against duplicate clicks causing concurrent requests
3238 $.ajax( mw.util.wikiScript( 'api' ), {
3339 'data': reqData,
3440 'success': function( data ) {
@@ -56,7 +62,14 @@
5763 $ul.append( comments[i].formatted );
5864 }
5965
60 - // TODO act on !moreResults
 66+ // Remove the spinner and restore the "More" link
 67+ $( '#fbd-list-more' )
 68+ .removeClass( 'mw-ajax-loader' )
 69+ .children( 'a' )
 70+ .css( 'visibility', 'visible' );
 71+ if ( !moreResults ) {
 72+ $( '#fbd-list-more' ).text( mw.msg( 'moodbar-feedback-nomore' ) );
 73+ }
6174 },
6275 'error': function( jqXHR, textStatus, errorThrown ) {
6376 // TODO
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -119,6 +119,7 @@
120120 $wgResourceModules['ext.moodBar.dashboard'] = $mbResourceTemplate + array(
121121 'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js',
122122 'dependencies' => array( 'mediawiki.util' ),
 123+ 'messages' => array( 'moodbar-feedback-nomore' ),
123124 );
124125
125126 $wgResourceModules['ext.moodBar.dashboard.styles'] = $mbResourceTemplate + array(

Status & tagging log