Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -85,6 +85,7 @@ |
86 | 86 | 'moodbar-feedback-permalink' => 'link to here', |
87 | 87 | 'moodbar-feedback-noresults' => 'There are no comments that match your filters.', |
88 | 88 | 'moodbar-feedback-more' => 'More', |
| 89 | + 'moodbar-feedback-nomore' => 'There are no more results to show', |
89 | 90 | 'moodbar-feedback-newer' => 'Newer', |
90 | 91 | 'moodbar-feedback-older' => 'Older', |
91 | 92 | // Mood types |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -1,20 +1,27 @@ |
2 | 2 | jQuery( function( $ ) { |
3 | | - $( '#fbd-list-more a' ).click( function( e ) { |
| 3 | + $( '#fbd-list-more').children( 'a' ).click( function( e ) { |
4 | 4 | e.preventDefault(); |
5 | 5 | |
6 | | - // TODO spinner |
7 | | - |
8 | 6 | var limit = 20, |
9 | 7 | username = $( '#fbd-filters-username' ).val(), |
10 | 8 | 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 | + }; |
19 | 26 | $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() { |
20 | 27 | if ( $(this).prop( 'checked' ) ) { |
21 | 28 | types.push( $(this).val() ); |
— | — | @@ -27,7 +34,6 @@ |
28 | 35 | reqData['mbcuser'] = username; |
29 | 36 | } |
30 | 37 | |
31 | | - // TODO save jqXhr and protect against duplicate clicks causing concurrent requests |
32 | 38 | $.ajax( mw.util.wikiScript( 'api' ), { |
33 | 39 | 'data': reqData, |
34 | 40 | 'success': function( data ) { |
— | — | @@ -56,7 +62,14 @@ |
57 | 63 | $ul.append( comments[i].formatted ); |
58 | 64 | } |
59 | 65 | |
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 | + } |
61 | 74 | }, |
62 | 75 | 'error': function( jqXHR, textStatus, errorThrown ) { |
63 | 76 | // TODO |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -119,6 +119,7 @@ |
120 | 120 | $wgResourceModules['ext.moodBar.dashboard'] = $mbResourceTemplate + array( |
121 | 121 | 'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js', |
122 | 122 | 'dependencies' => array( 'mediawiki.util' ), |
| 123 | + 'messages' => array( 'moodbar-feedback-nomore' ), |
123 | 124 | ); |
124 | 125 | |
125 | 126 | $wgResourceModules['ext.moodBar.dashboard.styles'] = $mbResourceTemplate + array( |