Index: trunk/extensions/MoodBar/SpecialMoodBarFeedback.php |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | $wgOut->addHTML( $this->buildForm() ); |
41 | 41 | $wgOut->addHTML( $this->buildList( $res ) ); |
42 | 42 | $wgOut->addModuleStyles( 'ext.moodBar.dashboard.styles' ); |
| 43 | + $wgOut->addModules( 'ext.moodBar.dashboard' ); |
43 | 44 | } |
44 | 45 | |
45 | 46 | public function buildForm() { |
— | — | @@ -107,9 +108,10 @@ |
108 | 109 | $comment = htmlspecialchars( $row->mbf_comment ); |
109 | 110 | $permalinkURL = htmlspecialchars( SpecialPage::getTitleFor( 'MoodBarFeedback', $row->mbf_id )->getLinkURL() ); |
110 | 111 | $permalinkText = wfMessage( 'moodbar-feedback-permalink' )->escaped(); |
| 112 | + $continueData = wfTimestamp( TS_MW, $row->mbf_timestamp ) . '|' . intval( $row->mbf_id ); |
111 | 113 | |
112 | 114 | return <<<HTML |
113 | | - <li class="fbd-item"> |
| 115 | + <li class="fbd-item" data-mbccontinue="$continueData"> |
114 | 116 | <div class="fbd-item-emoticon fbd-item-emoticon-$type"> |
115 | 117 | <span class="fbd-item-emoticon-label">$typeMsg</span> |
116 | 118 | </div> |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +jQuery( function( $ ) { |
| 3 | + $( '#fbd-list-more a' ).click( function( e ) { |
| 4 | + e.preventDefault(); |
| 5 | + |
| 6 | + // TODO spinner |
| 7 | + |
| 8 | + var limit = 20, |
| 9 | + username = $( '#fbd-filters-username' ).val(), |
| 10 | + 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 | + }; |
| 19 | + $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() { |
| 20 | + if ( $(this).prop( 'checked' ) ) { |
| 21 | + types.push( $(this).val() ); |
| 22 | + } |
| 23 | + } ); |
| 24 | + if ( types.length ) { |
| 25 | + reqData['mbctype'] = types.join( '|' ); |
| 26 | + } |
| 27 | + if ( username.length ) { |
| 28 | + reqData['mbcuser'] = username; |
| 29 | + } |
| 30 | + |
| 31 | + // TODO save jqXhr and protect against duplicate clicks causing concurrent requests |
| 32 | + $.ajax( mw.util.wikiScript( 'api' ), { |
| 33 | + 'data': reqData, |
| 34 | + 'success': function( data ) { |
| 35 | + if ( !data || !data.query || !data.query.moodbarcomments ) { |
| 36 | + // TODO error |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + var comments = data.query.moodbarcomments, |
| 41 | + len = comments.length, |
| 42 | + $ul = $( '#fbd-list' ), |
| 43 | + moreResults = false, |
| 44 | + i; |
| 45 | + if ( len > 0 ) { |
| 46 | + // Drop the first element because it duplicates the last shown one |
| 47 | + comments.shift(); |
| 48 | + len--; |
| 49 | + } |
| 50 | + if ( len > limit ) { |
| 51 | + // Drop any elements past the limit. We do know there are more results now |
| 52 | + len = limit; |
| 53 | + moreResults = true; |
| 54 | + } |
| 55 | + |
| 56 | + for ( i = 0; i < len; i++ ) { |
| 57 | + $ul.append( comments[i].formatted ); |
| 58 | + } |
| 59 | + |
| 60 | + // TODO act on !moreResults |
| 61 | + }, |
| 62 | + 'error': function( jqXHR, textStatus, errorThrown ) { |
| 63 | + // TODO |
| 64 | + }, |
| 65 | + 'dataType': 'json' |
| 66 | + } ); |
| 67 | + } ); |
| 68 | +} ); |
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 69 | + native |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -116,6 +116,11 @@ |
117 | 117 | 'position' => 'bottom', |
118 | 118 | ); |
119 | 119 | |
| 120 | +$wgResourceModules['ext.moodBar.dashboard'] = $mbResourceTemplate + array( |
| 121 | + 'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js', |
| 122 | + 'dependencies' => array( 'mediawiki.util' ), |
| 123 | +); |
| 124 | + |
120 | 125 | $wgResourceModules['ext.moodBar.dashboard.styles'] = $mbResourceTemplate + array( |
121 | 126 | 'styles' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.css', |
122 | 127 | ); |