r110334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110333‎ | r110334 | r110335 >
Date:22:22, 30 January 2012
Author:rsterbin
Status:ok
Tags:aft 
Comment:
Tweaks to the feedback page:
1. Marked-as-deleted state now in use alongside the hidden state; marker
changed from blue background to red with no background
2. When flagged as abuse, the links maintain the count
3. You can un-mark a comment as helpful/unhelpful by clicking the button a
second time
4. Probable fix for the double-marking of hidden comments
- ArticleFeedbackv5.i18n.php:
- New message 'articlefeedbackv5-deleted'
- Updated 'articlefeedbackv5-abuse-saved' to include a count
- ArticleFeedbackv5.hooks.php:
- Updated to send the new message to the special page js
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css:
- Changed styling of hidden/deleted markers
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js:
- Updated setBinds() to reject an up/down vote or an abuse flagging
when the comment is deleted, and to knock down the yes/no vote on the
second click
- Updated markHidden() to make sure any previous hidden flag has been
removed before adding a new one and to put the marker after the date
rather than after the title
- New methods markDeleted() and unmarkDeleted()
- Updated flagFeedback() to send the abuse count to thr saved message,
to store the count in the rel attibute of the link, and to call
markDeleted() or unmarkDeleted() on a successful delete/undelete
- Updated loadFeedback() to catch deleted comments and mark them as
such, and to add the abuse count to the saved message
- api/ApiViewFeedbackArticleFeedbackv5.php:
- Added the abuse count as the rel attribute on the flag as abuse link,
so the js can find it
- Added the top level class "articleFeedbackv5-feedback-deleted" for
deleted comments
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -77,6 +77,7 @@
7878 'articlefeedbackv5-special-pagetitle' => 'Feedback: $1',
7979 'articlefeedbackv5-form-optionid' => 'Option $1',
8080 'articlefeedbackv5-hidden' => 'Hidden',
 81+ 'articlefeedbackv5-deleted' => 'Deleted (oversight)',
8182 'articlefeedbackv5-form-hide' => 'Hide this post',
8283 'articlefeedbackv5-form-unhide' => 'Show this post',
8384 'articlefeedbackv5-form-helpful' => 'Mark as helpful ($1)',
@@ -97,7 +98,7 @@
9899 'articlefeedbackv5-form5-header' => '{{GENDER:$1|$1}} rated this page:',
99100 'articlefeedbackv5-form-not-shown' => '{{GENDER:$1|$1}} was not shown a feedback form.',
100101 'articlefeedbackv5-form-invalid' => 'Invalid feedback form ID.',
101 - 'articlefeedbackv5-abuse-saved' => 'Flagged as abuse',
 102+ 'articlefeedbackv5-abuse-saved' => 'Flagged as abuse ($1)',
102103 'articlefeedbackv5-oversight-saved' => 'Marked for oversight',
103104 'articlefeedbackv5-unoversight-saved' => 'Oversight flag removed',
104105 'articlefeedbackv5-error-loading-feedback' => 'Error loading feedback',
@@ -332,6 +333,7 @@
333334 'articlefeedbackv5-special-pagetitle' => 'Page title for [[Special:ArticleFeedbackv5]]. Parameters:
334335 * $1 is the title of the article for which we show the feedback',
335336 'articlefeedbackv5-hidden' => '{{Identical|Hidden}}',
 337+ 'articlefeedbackv5-deleted' => 'The marker that appears on a comment if it has been deleted by an oversighter.',
336338 'articlefeedbackv5-form-delete' => '{{Identical|Delete}}',
337339 'articlefeedbackv5-form-oversight' => 'Request that an oversighter review this feedback',
338340 'articlefeedbackv5-form-unoversight' => 'Remove request for oversight',
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
@@ -185,13 +185,13 @@
186186 margin-right: 10px;
187187 }
188188 .articleFeedbackv5-comment-details-date {
189 - float: left;
190 - clear: right;
191 - display: block;
192 - line-height: 24px;
193 - margin: 0 5px 0 0;
194 - position: relative;
195 - top: 18px;
 189+ float: left;
 190+ clear: right;
 191+ display: block;
 192+ line-height: 24px;
 193+ margin: 0 5px 0 0;
 194+ position: relative;
 195+ top: 18px;
196196 }
197197 #articleFeedbackv5-special-add-feedback {
198198 /*color:white;
@@ -230,16 +230,15 @@
231231 width: 520px;
232232 }
233233 .articleFeedbackv5-vote-wrapper {
234 - float: left;
235 - width: 100%;
236 - margin-bottom: 8px;
 234+ float: left;
 235+ width: 100%;
 236+ margin-bottom: 8px;
237237 }
238238 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-caption {
239239 margin: 0 15px 0 0;
240240 }
241241 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link,
242 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link,
243 -#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
 242+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link {
244243 display: inline-block;
245244 height: 22px;
246245 line-height: 22px;
@@ -273,8 +272,7 @@
274273 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active,
275274 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active,
276275 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active:hover,
277 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover,
278 -#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
 276+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover {
279277 /* @embed */
280278 background: url(images/bg-button.png) repeat-x;
281279 color: #fff;
@@ -283,10 +281,10 @@
284282 color: #888;
285283 }
286284 .articleFeedbackv5-feedback .articleFeedbackv5-comment-wrap h3 {
287 - display: block;
288 - float: left;
289 - width: 520px;
290 - line-height: 24px;
 285+ display: block;
 286+ float: left;
 287+ width: 520px;
 288+ line-height: 24px;
291289 }
292290 .articleFeedbackv5-feedback .articleFeedbackv5-comment-wrap h3 .icon {
293291 display: inline-block;
@@ -349,13 +347,18 @@
350348 color: white !important;
351349 }
352350 .articleFeedbackv5-comment-wrap {
353 - width: 100%;
 351+ width: 100%;
354352 }
355 -.articleFeedbackv5-feedback-hidden .articleFeedbackv5-comment-wrap {
 353+.articleFeedbackv5-feedback-hidden .articleFeedbackv5-comment-wrap,
 354+.articleFeedbackv5-feedback-deleted .articleFeedbackv5-comment-wrap {
356355 opacity : 0.4;
357356 filter: alpha(opacity=40); // msie
358357 background-color: #000;
359358 }
360 -#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
 359+#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker,
 360+#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-deleted .articleFeedbackv5-feedback-deleted-marker {
 361+ font-weight: bold;
 362+ color: red;
 363+ text-transform: uppercase;
361364 margin-left: 20px;
362365 }
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -161,15 +161,15 @@
162162 $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) {
163163 e.preventDefault();
164164 var $l = $( e.target );
165 - if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' ) ) {
 165+ if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' )
 166+ || $l.closest( '.articleFeedbackv5-feedback' ).data( 'deleted' ) ) {
166167 return false;
167168 }
168169 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
169170 var activity = $.articleFeedbackv5special.getActivity( id );
170171 if ( activity[value] ) {
171 - return false;
172 - }
173 - if ( 'helpful' == value && activity.unhelpful ) {
 172+ $.articleFeedbackv5special.flagFeedback( id, value, -1 );
 173+ } else if ( 'helpful' == value && activity.unhelpful ) {
174174 $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', -1 );
175175 $.articleFeedbackv5special.flagFeedback( id, 'helpful', 1 );
176176 } else if ( 'unhelpful' == value && activity.helpful ) {
@@ -185,7 +185,8 @@
186186 $( '.articleFeedbackv5-abuse-link' ).live( 'click', function( e ) {
187187 e.preventDefault();
188188 var $l = $( e.target );
189 - if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' ) ) {
 189+ if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' )
 190+ || $l.closest( '.articleFeedbackv5-feedback' ).data( 'deleted' ) ) {
190191 return false;
191192 }
192193 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
@@ -387,11 +388,14 @@
388389 * @param $row element the feedback row
389390 */
390391 $.articleFeedbackv5special.markHidden = function ( $row ) {
 392+ if ( $row.data( 'hidden' ) ) {
 393+ $.articleFeedbackv5special.unmarkHidden();
 394+ }
391395 $row.addClass( 'articleFeedbackv5-feedback-hidden' )
392396 .data( 'hidden', true );
393397 $( '<span class="articleFeedbackv5-feedback-hidden-marker"></span>' )
394398 .text( mw.msg( 'articlefeedbackv5-hidden' ) )
395 - .insertAfter( $row.find( '.articleFeedbackv5-comment-wrap h3 span.result' ) );
 399+ .insertAfter( $row.find( '.articleFeedbackv5-comment-details-date a' ) );
396400 };
397401
398402 // }}}
@@ -409,8 +413,45 @@
410414 };
411415
412416 // }}}
 417+ // {{{ markDeleted
413418
 419+ /**
 420+ * Utility method: Marks a feedback row deleted
 421+ *
 422+ * @param $row element the feedback row
 423+ */
 424+ $.articleFeedbackv5special.markDeleted = function ( $row ) {
 425+ if ( $row.data( 'deleted' ) ) {
 426+ $.articleFeedbackv5special.unmarkDeleted();
 427+ }
 428+ $row.addClass( 'articleFeedbackv5-feedback-deleted' )
 429+ .data( 'deleted', true );
 430+ var $marker = $( '<span class="articleFeedbackv5-feedback-deleted-marker"></span>' )
 431+ .text( mw.msg( 'articlefeedbackv5-deleted' ) );
 432+ if ( $row.data( 'hidden' ) ) {
 433+ $marker.insertAfter( $row.find( '.articleFeedbackv5-feedback-hidden-marker' ) );
 434+ } else {
 435+ $marker.insertAfter( $row.find( '.articleFeedbackv5-comment-details-date a' ) );
 436+ }
 437+ };
 438+
414439 // }}}
 440+ // {{{ unmarkDeleted
 441+
 442+ /**
 443+ * Utility method: Unmarks as deleted a feedback row
 444+ *
 445+ * @param $row element the feedback row
 446+ */
 447+ $.articleFeedbackv5special.unmarkDeleted = function ( $row ) {
 448+ $row.removeClass( 'articleFeedbackv5-feedback-deleted' )
 449+ .data( 'deleted', false );
 450+ $row.find( '.articleFeedbackv5-feedback-deleted-marker' ).remove();
 451+ };
 452+
 453+ // }}}
 454+
 455+ // }}}
415456 // {{{ Process methods
416457
417458 // {{{ flagFeedback
@@ -440,23 +481,25 @@
441482 if ( 'articlefeedbackv5-flag-feedback' in data ) {
442483 if ( 'result' in data['articlefeedbackv5-flag-feedback'] ) {
443484 if ( data['articlefeedbackv5-flag-feedback'].result == 'Success' ) {
 485+ var $l = $( '#articleFeedbackv5-' + type + '-link-' + id );
 486+ // Helpful or unhelpful
444487 if ( 'helpful' in data['articlefeedbackv5-flag-feedback'] ) {
445488 $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
446489 }
447490 if ( 'helpful' == type || 'unhelpful' == type ) {
448 - var $l = $( '#articleFeedbackv5-' + type + '-link-' + id );
449491 if ( dir > 0 ) {
450492 $l.addClass( 'helpful-active' );
451493 } else {
452494 $l.removeClass( 'helpful-active' );
453495 }
 496+ // Abusive
454497 } else if ( 'abuse' == type ) {
455 - var $l = $( '#articleFeedbackv5-abuse-link-' + id );
456498 if ( dir > 0 ) {
457 - $l.text( mw.msg( 'articlefeedbackv5-abuse-saved' ) );
 499+ $l.text( mw.msg( 'articlefeedbackv5-abuse-saved', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
458500 } else {
459501 $l.text( mw.msg( 'articlefeedbackv5-form-abuse', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
460502 }
 503+ $l.attr( 'rel', data['articlefeedbackv5-flag-feedback'].abuse_count );
461504 if ( data['articlefeedbackv5-flag-feedback'].abusive ) {
462505 $l.addClass( 'abusive' );
463506 } else {
@@ -465,8 +508,8 @@
466509 if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
467510 $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
468511 }
 512+ // Hide
469513 } else if ( 'hide' == type ) {
470 - var $l = $( '#articleFeedbackv5-hide-link-' + id );
471514 if ( dir > 0 ) {
472515 $l.text( mw.msg( 'articlefeedbackv5-form-unhide' ) );
473516 $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
@@ -474,12 +517,14 @@
475518 $l.text( mw.msg( 'articlefeedbackv5-form-hide' ) );
476519 $.articleFeedbackv5special.unmarkHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
477520 }
 521+ // Delete
478522 } else if ( 'delete' == type ) {
479 - var $l = $( '#articleFeedbackv5-delete-link-' + id );
480523 if ( dir > 0 ) {
481524 $l.text( mw.msg( 'articlefeedbackv5-form-undelete' ) );
 525+ $.articleFeedbackv5special.markDeleted( $l.closest( '.articleFeedbackv5-feedback' ) );
482526 } else {
483527 $l.text( mw.msg( 'articlefeedbackv5-form-delete' ) );
 528+ $.articleFeedbackv5special.unmarkDeleted( $l.closest( '.articleFeedbackv5-feedback' ) );
484529 }
485530 }
486531 // Save activity
@@ -489,7 +534,7 @@
490535 $.articleFeedbackv5special.activity[id][type] = dir > 0 ? true : false;
491536 $.articleFeedbackv5special.storeActivity();
492537 } else if ( data['articlefeedbackv5-flag-feedback'].result == 'Error' ) {
493 - msg = data['articlefeedbackv5-flag-feedback'].reason;
 538+ mw.log( mw.msg( data['articlefeedbackv5-flag-feedback'].reason ) );
494539 }
495540 }
496541 }
@@ -549,12 +594,15 @@
550595 }
551596 if ( activity.abuse ) {
552597 var $l = $( this ).find( '#articleFeedbackv5-abuse-link-' + id );
553 - $l.text( mw.msg( 'articlefeedbackv5-abuse-saved' ) );
 598+ $l.text( mw.msg( 'articlefeedbackv5-abuse-saved', $l.attr( 'rel' ) ) );
554599 }
555600 }
556601 if ( $( this ).hasClass( 'articleFeedbackv5-feedback-hidden' ) ) {
557602 $.articleFeedbackv5special.markHidden( $( this ) );
558603 }
 604+ if ( $( this ).hasClass( 'articleFeedbackv5-feedback-deleted' ) ) {
 605+ $.articleFeedbackv5special.markDeleted( $( this ) );
 606+ }
559607 } );
560608 $( '#articleFeedbackv5-feedback-count-total' ).text( data['articlefeedbackv5-view-feedback'].count );
561609 $.articleFeedbackv5special.listControls.continue = data['articlefeedbackv5-view-feedback'].continue;
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -363,7 +363,8 @@
364364 }
365365 $footer_links .= Html::element( 'a', array(
366366 'id' => "articleFeedbackv5-abuse-link-$id",
367 - 'class' => $aclass
 367+ 'class' => $aclass,
 368+ 'rel' => $record[0]->af_abuse_count
368369 ), wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->text() );
369370 }
370371 $footer_links .= $details . Html::closeElement( 'div' );
@@ -446,6 +447,9 @@
447448 if ( $record[0]->af_is_hidden ) {
448449 $topClass .= ' articleFeedbackv5-feedback-hidden';
449450 }
 451+ if ( $record[0]->af_is_deleted ) {
 452+ $topClass .= ' articleFeedbackv5-feedback-deleted';
 453+ }
450454 return Html::openElement( 'div', array(
451455 'class' => $topClass,
452456 'rel' => $id
@@ -460,12 +464,12 @@
461465 . $tools
462466 . Html::closeElement( 'div' );
463467 }
464 -
 468+
465469 private function renderPermalinkTimestamp( $record ) {
466470 global $wgLang;
467471 $id = $record->af_id;
468472 $title = $record->page_title;
469 -
 473+
470474 // Taken from the Moodbar extension.
471475 $now = wfTimestamp( TS_UNIX );
472476 $timestamp = wfTimestamp( TS_UNIX, $record->af_created );
@@ -480,16 +484,16 @@
481485 } elseif( $timestamp ) {
482486 $date = $wgLang->timeanddate($record->af_created );
483487 }
484 -
 488+
485489 // format the element
486490 return Html::openElement( 'span', array(
487491 'class' => 'articleFeedbackv5-comment-details-date'
488492 ) )
489 - . Linker::link(
490 - Title::newFromText(
491 - "Special:ArticleFeedbackv5/$title/$id"
492 - ),
493 - $date
 493+ . Linker::link(
 494+ Title::newFromText(
 495+ "Special:ArticleFeedbackv5/$title/$id"
 496+ ),
 497+ $date
494498 )
495499 . Html::closeElement( 'span' );
496500 }
@@ -593,11 +597,11 @@
594598 $short = $wgLang->truncate( $text, 500 );
595599
596600 $rv = Html::openElement( 'blockquote' )
597 - . Html::element( 'span',
 601+ . Html::element( 'span',
598602 array(
599603 'class' => 'articleFeedbackv5-comment-short',
600604 'id' => "articleFeedbackv5-comment-short-$feedbackId"
601 - ),
 605+ ),
602606 htmlspecialchars( $short )
603607 );
604608
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -173,6 +173,7 @@
174174 'articlefeedbackv5-form-delete',
175175 'articlefeedbackv5-form-undelete',
176176 'articlefeedbackv5-hidden',
 177+ 'articlefeedbackv5-deleted',
177178 'articlefeedbackv5-comment-more',
178179 'articlefeedbackv5-comment-less',
179180 'articlefeedbackv5-error-loading-feedback'

Status & tagging log