r100025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100024‎ | r100025 | r100026 >
Date:13:10, 17 October 2011
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Adjustments to r99351 r99350 r99200 per code review:
* Replace the "show" link with a spinner, and add error handling.
* Use data() instead of attr() where appropriate.
* Fix an errant removal of parameters.
* Fix double-escaping
Modified paths:
  • /trunk/extensions/MoodBar/DashboardForms.php (modified) (history)
  • /trunk/extensions/MoodBar/SpecialFeedbackDashboard.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/SpecialFeedbackDashboard.php
@@ -261,7 +261,7 @@
262262 $linkText = wfMessage('moodbar-feedback-show')->escaped();
263263 $query = array('show-feedback' => '1');
264264 $link = $GLOBALS['wgUser']->getSkin()
265 - ->link( $permalinkTitle, $linkText );
 265+ ->link( $permalinkTitle, $linkText, array(), $query );
266266 return Xml::tags( 'div', array( 'class' => 'fbd-item-show' ), "($link)" );
267267 }
268268 }
@@ -276,7 +276,8 @@
277277 $permalinkTitle = SpecialPage::getTitleFor( 'FeedbackDashboard', $id );
278278 $permalinkText = wfMessage( 'moodbar-feedback-hide' )->escaped();
279279 $permalink = $GLOBALS['wgUser']->getSkin()
280 - ->link( $permalinkTitle, $permalinkText, array(), array('hide-feedback' => '1') );
 280+ ->link( $permalinkTitle, $permalinkText,
 281+ array(), array('hide-feedback' => '1') );
281282 return Xml::tags( 'div', array( 'class' => 'fbd-item-permalink' ), "($permalink)" );
282283 }
283284
Index: trunk/extensions/MoodBar/DashboardForms.php
@@ -143,7 +143,7 @@
144144 public function getForm() {
145145 $form = parent::getForm();
146146
147 - $header = Html::element( 'h3', null,
 147+ $header = Html::rawElement( 'h3', null,
148148 wfMessage( 'moodbar-hide-header' )->parse() );
149149
150150 $header .= wfMessage( 'moodbar-hide-intro' )->parse();
@@ -182,7 +182,7 @@
183183 public function getForm() {
184184 $form = parent::getForm();
185185
186 - $header = Html::element( 'h3', null,
 186+ $header = Html::rawElement( 'h3', null,
187187 wfMessage( 'moodbar-restore-header' )->parse() );
188188
189189 $header .= wfMessage( 'moodbar-restore-intro' )->parse();
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
@@ -198,7 +198,7 @@
199199 */
200200 function showHiddenComment(e) {
201201 var $item = $(this).closest('.fbd-item');
202 - var cont = $item.attr('data-mbccontinue');
 202+ var cont = $item.data('mbccontinue');
203203
204204 var request = {
205205 'action' : 'query',
@@ -209,10 +209,18 @@
210210 'mbccontinue' : cont
211211 };
212212
 213+ var $spinner = $('<span class="mw-ajax-loader">&nbsp;</span>');
 214+ $item.find('.fbd-item-show').empty().append( $spinner );
 215+
213216 $.post( mw.util.wikiScript('api'), request,
214217 function( data ) {
215 - var $content = $j(data.query.moodbarcomments[0].formatted);
216 - $item.replaceWith($content);
 218+ if ( data && data.query && data.query.moodbarcomments ) {
 219+ var $content = $j(data.query.moodbarcomments[0].formatted);
 220+ $item.replaceWith($content);
 221+ } else {
 222+ // Failure, just remove the link.
 223+ $item.find('.fbd-item-show').remove();
 224+ }
217225 }, 'json' );
218226
219227 e.preventDefault();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99200MoodBar feedback dashboard: Implement a means to hide individual comments. Fo...werdna07:14, 7 October 2011
r99350MoodBar: Implement hiding and restoring of entries on the feedback dashboard....werdna12:59, 9 October 2011
r99351svn add DashboardForms.phpwerdna13:15, 9 October 2011

Comments

#Comment by Catrope (talk | contribs)   15:29, 24 October 2011
+				if ( data && data.query && data.query.moodbarcomments ) {

You also need to check that data.query.moodbarcomments.length > 0 before accessing data.query.moodbarcomments[0] .

#Comment by Catrope (talk | contribs)   15:30, 24 October 2011

OK otherwise.

Status & tagging log