http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98072

Revision: 98072
Author:   catrope
Date:     2011-09-25 17:49:14 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
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
    trunk/extensions/MoodBar/MoodBar.php
    
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js

Modified: trunk/extensions/MoodBar/MoodBar.i18n.php
===================================================================
--- trunk/extensions/MoodBar/MoodBar.i18n.php   2011-09-25 17:45:31 UTC (rev 
98071)
+++ trunk/extensions/MoodBar/MoodBar.i18n.php   2011-09-25 17:49:14 UTC (rev 
98072)
@@ -85,6 +85,7 @@
        'moodbar-feedback-permalink' => 'link to here',
        'moodbar-feedback-noresults' => 'There are no comments that match your 
filters.',
        'moodbar-feedback-more' => 'More',
+       'moodbar-feedback-nomore' => 'There are no more results to show',
        'moodbar-feedback-newer' => 'Newer',
        'moodbar-feedback-older' => 'Older',
        // Mood types

Modified: trunk/extensions/MoodBar/MoodBar.php
===================================================================
--- trunk/extensions/MoodBar/MoodBar.php        2011-09-25 17:45:31 UTC (rev 
98071)
+++ trunk/extensions/MoodBar/MoodBar.php        2011-09-25 17:49:14 UTC (rev 
98072)
@@ -119,6 +119,7 @@
 $wgResourceModules['ext.moodBar.dashboard'] = $mbResourceTemplate + array(
        'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js',
        'dependencies' => array( 'mediawiki.util' ),
+       'messages' => array( 'moodbar-feedback-nomore' ),
 );
 
 $wgResourceModules['ext.moodBar.dashboard.styles'] = $mbResourceTemplate + 
array(

Modified: 
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
===================================================================
--- 
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js 
    2011-09-25 17:45:31 UTC (rev 98071)
+++ 
trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js 
    2011-09-25 17:49:14 UTC (rev 98072)
@@ -1,20 +1,27 @@
 jQuery( function( $ ) {
-       $( '#fbd-list-more a' ).click( function( e ) {
+       $( '#fbd-list-more').children( 'a' ).click( function( e ) {
                e.preventDefault();
                
-               // TODO spinner
-               
                var     limit = 20,
                        username = $( '#fbd-filters-username' ).val(),
                        types = [],
-                       reqData = {
-                               'action': 'query',
-                               'list': 'moodbarcomments',
-                               'format': 'json',
-                               'mbcprop': 'formatted',
-                               'mbclimit': limit + 2, // we drop the first and 
last result
-                               'mbccontinue': $( '#fbd-list li:last' ).data( 
'mbccontinue' )
-                       };
+                       reqData;
+               
+               // Hide the "More" link and put in a spinner
+               $( '#fbd-list-more' )
+                       .addClass( 'mw-ajax-loader' )
+                       .children( 'a' )
+                       .css( 'visibility', 'hidden' ); // using .hide() messes 
up the layout
+               
+               // Build the API request
+               reqData = {
+                       'action': 'query',
+                       'list': 'moodbarcomments',
+                       'format': 'json',
+                       'mbcprop': 'formatted',
+                       'mbclimit': limit + 2, // we drop the first and last 
result
+                       'mbccontinue': $( '#fbd-list').find( 'li:last' ).data( 
'mbccontinue' )
+               };
                $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, 
#fbd-filters-type-issues' ).each( function() {
                        if ( $(this).prop( 'checked' ) ) {
                                types.push( $(this).val() );
@@ -27,7 +34,6 @@
                        reqData['mbcuser'] = username;
                }
                
-               // TODO save jqXhr and protect against duplicate clicks causing 
concurrent requests
                $.ajax( mw.util.wikiScript( 'api' ), {
                        'data': reqData,
                        'success': function( data ) {
@@ -56,7 +62,14 @@
                                        $ul.append( comments[i].formatted );
                                }
                                
-                               // TODO act on !moreResults
+                               // Remove the spinner and restore the "More" 
link
+                               $( '#fbd-list-more' )
+                                       .removeClass( 'mw-ajax-loader' )
+                                       .children( 'a' )
+                                       .css( 'visibility', 'visible' );
+                               if ( !moreResults ) {
+                                       $( '#fbd-list-more' ).text( mw.msg( 
'moodbar-feedback-nomore' ) );
+                               }
                        },
                        'error': function( jqXHR, textStatus, errorThrown ) {
                                // TODO


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to