r110193 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110192‎ | r110193 | r110194 >
Date:00:01, 28 January 2012
Author:rsterbin
Status:resolved
Tags:aft 
Comment:
Hide/show is now a toggle:
- ArticleFeedbackv5.i18n.php:
- Updated "articlefeedbackv5-form-hide" to follow the feature
requirements
- Removed old messages 'articlefeedbackv5-hide-saved' and
'articlefeedbackv5-unhide-saved'
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css:
- Added styles for hidden comments
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js:
- Updated setBinds() so that mark as helpful and flag as abuse don't
work when the feedback is hidden
- Updated setBinds() to make hide work as a toggle
- New methods markHidden() and unmarkHidden()
- Updated flagFeedback() to mark the feedback hidden/unhidden on
success
- Updated loadFeedback() to mark incoming feedback with the hidden
class using markHidden()
- api/ApiViewFeedbackArticleFeedbackv5.php:
- Dropped unhide link
- Updated hide link to show the message without a count
- Added the hidden class to hidden feedback
- Also cleaned up some stray spaces
- ArticleFeedbackv5.hooks.php:
- Updated to send 'articlefeedbackv5-form-hide' and
'articlefeedbackv5-form-unhide' to the special js
- Dropped 'articlefeedbackv5-hide-saved',
'articlefeedbackv5-helpful-saved',
'articlefeedbackv5-unhelpful-saved', and
'articlefeedbackv5-unhide-saved' from the special js
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.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,7 +77,7 @@
7878 'articlefeedbackv5-special-pagetitle' => 'Feedback: $1',
7979 'articlefeedbackv5-form-optionid' => 'Option $1',
8080 'articlefeedbackv5-hidden' => 'Hidden',
81 - 'articlefeedbackv5-form-hide' => 'Hide this post ($1)',
 81+ 'articlefeedbackv5-form-hide' => 'Hide this post',
8282 'articlefeedbackv5-form-unhide' => 'Show this post',
8383 'articlefeedbackv5-form-helpful' => 'Mark as helpful ($1)',
8484 'articlefeedbackv5-form-abuse' => 'Flag as abuse ($1)',
@@ -99,10 +99,8 @@
100100 'articlefeedbackv5-form-invalid' => 'Invalid feedback form ID.',
101101 'articlefeedbackv5-delete-saved' => 'Feedback deleted',
102102 'articlefeedbackv5-abuse-saved' => 'Flagged as abuse',
103 - 'articlefeedbackv5-hide-saved' => 'Hide flag saved',
104103 'articlefeedbackv5-unhelpful-saved' => 'No',
105104 'articlefeedbackv5-helpful-saved' => 'Yes',
106 - 'articlefeedbackv5-unhide-saved' => 'Feedback shown',
107105 'articlefeedbackv5-undelete-saved' => 'Feedback shown',
108106 'articlefeedbackv5-oversight-saved' => 'Marked for oversight',
109107 'articlefeedbackv5-unoversight-saved' => 'Oversight flag removed',
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
@@ -221,7 +221,8 @@
222222 margin: 0 15px 0 0;
223223 }
224224 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link,
225 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link {
 225+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link,
 226+#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
226227 display: inline-block;
227228 height: 22px;
228229 line-height: 22px;
@@ -255,7 +256,8 @@
256257 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active,
257258 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active,
258259 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active:hover,
259 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover {
 260+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover,
 261+#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
260262 /* @embed */
261263 background: url(images/bg-button.png) repeat-x;
262264 color: #fff;
@@ -329,3 +331,11 @@
330332 background: url(images/bg-button.png) !important;
331333 color: white !important;
332334 }
 335+.articleFeedbackv5-feedback-hidden .articleFeedbackv5-comment-wrap {
 336+ opacity : 0.4;
 337+ filter: alpha(opacity=40); // msie
 338+ background-color: #000;
 339+}
 340+#articleFeedbackv5-show-feedback .articleFeedbackv5-feedback-hidden .articleFeedbackv5-feedback-hidden-marker {
 341+ margin-left: 20px;
 342+}
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -153,11 +153,14 @@
154154 return false;
155155 } );
156156
157 - // Helpful and unhelpful have their own special logic, so break those out.
 157+ // Helpful and unhelpful
158158 $.each( ['helpful', 'unhelpful' ], function ( index, value ) {
159159 $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) {
160160 e.preventDefault();
161161 var $l = $( e.target );
 162+ if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' ) ) {
 163+ return false;
 164+ }
162165 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
163166 var activity = $.articleFeedbackv5special.getActivity( id );
164167 if ( activity[value] ) {
@@ -175,9 +178,13 @@
176179 } )
177180 } );
178181
 182+ // Flag as abuse
179183 $( '.articleFeedbackv5-abuse-link' ).live( 'click', function( e ) {
180184 e.preventDefault();
181185 var $l = $( e.target );
 186+ if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' ) ) {
 187+ return false;
 188+ }
182189 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
183190 var activity = $.articleFeedbackv5special.getActivity( id );
184191 if ( activity.abuse ) {
@@ -185,9 +192,22 @@
186193 } else {
187194 $.articleFeedbackv5special.flagFeedback( id, 'abuse', 1 );
188195 }
189 - } )
 196+ } );
190197
191 - $.each( ['unhide', 'undelete', 'oversight', 'hide', 'delete', 'unoversight'], function ( index, value ) {
 198+ // Hide/Show this post
 199+ $( '.articleFeedbackv5-hide-link' ).live( 'click', function( e ) {
 200+ e.preventDefault();
 201+ var $l = $( e.target );
 202+ var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
 203+ var activity = $.articleFeedbackv5special.getActivity( id );
 204+ if ( activity.hide ) {
 205+ $.articleFeedbackv5special.flagFeedback( id, 'hide', -1 );
 206+ } else {
 207+ $.articleFeedbackv5special.flagFeedback( id, 'hide', 1 );
 208+ }
 209+ } );
 210+
 211+ $.each( ['undelete', 'oversight', 'delete', 'unoversight'], function ( index, value ) {
192212 $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) {
193213 e.preventDefault();
194214 $.articleFeedbackv5special.flagFeedback( $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-' + value + '-link-' ), value, 1 );
@@ -350,8 +370,38 @@
351371 };
352372
353373 // }}}
 374+ // {{{ markHidden
354375
 376+ /**
 377+ * Utility method: Marks a feedback row hidden
 378+ *
 379+ * @param $row element the feedback row
 380+ */
 381+ $.articleFeedbackv5special.markHidden = function ( $row ) {
 382+ $row.addClass( 'articleFeedbackv5-feedback-hidden' )
 383+ .data( 'hidden', true );
 384+ $( '<span class="articleFeedbackv5-feedback-hidden-marker"></span>' )
 385+ .text( mw.msg( 'articlefeedbackv5-hidden' ) )
 386+ .insertAfter( $row.find( '.articleFeedbackv5-comment-wrap h3 span.result' ) );
 387+ };
 388+
355389 // }}}
 390+ // {{{ unmarkHidden
 391+
 392+ /**
 393+ * Utility method: Unmarks as hidden a feedback row
 394+ *
 395+ * @param $row element the feedback row
 396+ */
 397+ $.articleFeedbackv5special.unmarkHidden = function ( $row ) {
 398+ $row.removeClass( 'articleFeedbackv5-feedback-hidden' )
 399+ .data( 'hidden', false );
 400+ $row.find( '.articleFeedbackv5-feedback-hidden-marker' ).remove();
 401+ };
 402+
 403+ // }}}
 404+
 405+ // }}}
356406 // {{{ Process methods
357407
358408 // {{{ flagFeedback
@@ -404,9 +454,17 @@
405455 $l.removeClass( 'abusive' );
406456 }
407457 if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
408 - // TODO: Grey it out and add a "hidden" flag somewhere (as per Fabrice)
409 - // $l.closest( '.articleFeedbackv5-feedback' ).hide( 'slow' );
 458+ $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
410459 }
 460+ } else if ( 'hide' == type ) {
 461+ var $l = $( '#articleFeedbackv5-hide-link-' + id );
 462+ if ( dir > 0 ) {
 463+ $l.text( mw.msg( 'articlefeedbackv5-form-unhide' ) );
 464+ $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
 465+ } else {
 466+ $l.text( mw.msg( 'articlefeedbackv5-form-hide' ) );
 467+ $.articleFeedbackv5special.unmarkHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
 468+ }
411469 } else {
412470 msg = 'articlefeedbackv5-' + type + '-saved';
413471 $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( msg ) );
@@ -481,6 +539,9 @@
482540 $l.text( mw.msg( 'articlefeedbackv5-abuse-saved' ) );
483541 }
484542 }
 543+ if ( $( this ).hasClass( 'articleFeedbackv5-feedback-hidden' ) ) {
 544+ $.articleFeedbackv5special.markHidden( $( this ) );
 545+ }
485546 } );
486547 $( '#articleFeedbackv5-show-feedback' ).append( $newList );
487548 $( '#articleFeedbackv5-feedback-count-total' ).text( data['articlefeedbackv5-view-feedback'].count );
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php
@@ -270,14 +270,14 @@
271271 $wgHooks['ArticleSaveComplete'][] = 'ArticleFeedbackv5Hooks::trackEditSuccess';
272272
273273 // API Registration
274 -#$wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5';
275 -#$wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5';
276 -#$wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5';
 274+$wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5';
 275+$wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5';
 276+$wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5';
277277 $wgAPIModules['articlefeedbackv5'] = 'ApiArticleFeedbackv5';
278278
279279 // Special Page
280 -#$wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5';
281 -#$wgSpecialPageGroups['ArticleFeedbackv5'] = 'other';
 280+$wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5';
 281+$wgSpecialPageGroups['ArticleFeedbackv5'] = 'other';
282282
283283 $wgAvailableRights[] = 'aftv5-hide-feedback';
284284 $wgAvailableRights[] = 'aftv5-delete-feedback';
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -73,8 +73,8 @@
7474 return $count ? $count : 0;
7575 }
7676
77 - public function fetchFeedback( $pageId, $filter = 'visible',
78 - $filterValue = null, $sort = 'age', $sortOrder = 'desc',
 77+ public function fetchFeedback( $pageId, $filter = 'visible',
 78+ $filterValue = null, $sort = 'age', $sortOrder = 'desc',
7979 $limit = 25, $continue = null ) {
8080 $dbr = wfGetDB( DB_SLAVE );
8181 $ids = array();
@@ -139,7 +139,7 @@
140140 record until we fetch them, this is the only way to make
141141 sure we get all answers for the exact IDs we want. */
142142 $id_query = $dbr->select(
143 - array(
 143+ array(
144144 'aft_article_feedback',
145145 'rating' => 'aft_article_answer',
146146 'comment' => 'aft_article_answer',
@@ -156,13 +156,13 @@
157157 'ORDER BY' => $order
158158 ),
159159 array(
160 - 'rating' => array(
161 - 'LEFT JOIN',
162 - 'rating.aa_feedback_id = af_id AND rating.aa_field_id = '.intval( $ratingField )
 160+ 'rating' => array(
 161+ 'LEFT JOIN',
 162+ 'rating.aa_feedback_id = af_id AND rating.aa_field_id = '.intval( $ratingField )
163163 ),
164 - 'comment' => array(
165 - 'LEFT JOIN',
166 - 'comment.aa_feedback_id = af_id AND comment.aa_field_id = '.intval( $commentField )
 164+ 'comment' => array(
 165+ 'LEFT JOIN',
 166+ 'comment.aa_feedback_id = af_id AND comment.aa_field_id = '.intval( $commentField )
167167 )
168168 )
169169 );
@@ -176,10 +176,10 @@
177177 }
178178
179179 $rows = $dbr->select(
180 - array( 'aft_article_feedback',
 180+ array( 'aft_article_feedback',
181181 'rating' => 'aft_article_answer',
182182 'answer' => 'aft_article_answer',
183 - 'aft_article_field',
 183+ 'aft_article_field',
184184 'aft_article_field_option', 'user', 'page'
185185 ),
186186 array( 'af_id', 'af_bucket_id', 'afi_name', 'afo_name',
@@ -198,10 +198,10 @@
199199 __METHOD__,
200200 array( 'ORDER BY' => $order ),
201201 array(
202 - 'rating' => array(
203 - 'LEFT JOIN',
204 - 'rating.aa_feedback_id = af_id AND rating.aa_field_id = '.intval( $ratingField )
205 - ),
 202+ 'rating' => array(
 203+ 'LEFT JOIN',
 204+ 'rating.aa_feedback_id = af_id AND rating.aa_field_id = '.intval( $ratingField )
 205+ ),
206206 'answer' => array(
207207 'LEFT JOIN', 'af_id = answer.aa_feedback_id'
208208 ),
@@ -423,18 +423,16 @@
424424 'id' => 'articleFeedbackv5-feedback-tools-list-' . $id
425425 ) );
426426
427 -
428427 if ( $can_hide ) {
429 - $link = 'hide';
430428 if ( $record[0]->af_is_hidden > 0 ) {
431 - # unhide
432 - $link = 'unhide';
433 - $tools .= Html::element( 'li', array(), wfMessage( 'articlefeedbackv5-hidden' ) );
 429+ $msg = 'unhide';
 430+ } else {
 431+ $msg = 'hide';
434432 }
435433 $tools .= Html::rawElement( 'li', array(), Html::element( 'a', array(
436 - 'id' => "articleFeedbackv5-$link-link-$id",
437 - 'class' => "articleFeedbackv5-$link-link"
438 - ), wfMessage( "articlefeedbackv5-form-$link", $record[0]->af_is_hidden )->text() ) );
 434+ 'id' => "articleFeedbackv5-hide-link-$id",
 435+ 'class' => "articleFeedbackv5-hide-link"
 436+ ), wfMessage( "articlefeedbackv5-form-" . $msg )->text() ) );
439437 }
440438
441439 if ( $can_delete ) {
@@ -474,8 +472,12 @@
475473 . Html::closeElement( 'div' );
476474 }
477475
 476+ $topClass = 'articleFeedbackv5-feedback';
 477+ if ( $record[0]->af_is_hidden ) {
 478+ $topClass .= ' articleFeedbackv5-feedback-hidden';
 479+ }
478480 return Html::openElement( 'div', array(
479 - 'class' => 'articleFeedbackv5-feedback',
 481+ 'class' => $topClass,
480482 'rel' => $id
481483 ) )
482484 . Html::openElement( 'div', array(
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -167,12 +167,10 @@
168168 'articlefeedbackv5-invalid-feedback-flag',
169169 'articlefeedbackv5-form-abuse',
170170 'articlefeedbackv5-abuse-saved',
171 - 'articlefeedbackv5-hide-saved',
 171+ 'articlefeedbackv5-form-hide',
 172+ 'articlefeedbackv5-form-unhide',
172173 'articlefeedbackv5-hidden',
173174 'articlefeedbackv5-delete-saved',
174 - 'articlefeedbackv5-helpful-saved',
175 - 'articlefeedbackv5-unhelpful-saved',
176 - 'articlefeedbackv5-unhide-saved',
177175 'articlefeedbackv5-undelete-saved',
178176 'articlefeedbackv5-oversight-saved',
179177 'articlefeedbackv5-unoversight-saved',

Follow-up revisions

RevisionCommit summaryAuthorDate
r110196Fix for r110193, where I accidentally reverted the commenting-out of the spec...rsterbin00:33, 28 January 2012

Status & tagging log