r111962 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111961‎ | r111962 | r111963 >
Date:21:05, 20 February 2012
Author:yonishostak
Status:ok (Comments)
Tags:
Comment:
AFTv5: complete overhaul of special page JS, no more spaghetti code, restructures around the actions object - this is phase 1, more work to be done here
Modified paths:
  • /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/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
@@ -271,7 +271,9 @@
272272 margin: 0 15px 0 0;
273273 }
274274 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link,
275 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link {
 275+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link,
 276+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reversehelpful-link,
 277+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reverseunhelpful-link {
276278 display: inline-block;
277279 height: 22px;
278280 line-height: 22px;
@@ -294,7 +296,9 @@
295297 }
296298
297299 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link:hover,
298 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link:hover {
 300+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link:hover,
 301+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reversehelpful-link:hover,
 302+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reverseunhelpful-link:hover {
299303 /* @embed */
300304 background: url(images/bg-button-hov.png) repeat-x;
301305 cursor: pointer;
@@ -305,7 +309,11 @@
306310 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active,
307311 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active,
308312 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-helpful-link.active:hover,
309 -#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover {
 313+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-unhelpful-link.active:hover,
 314+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reversehelpful-link.active,
 315+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reverseunhelpful-link.active,
 316+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reversehelpful-link.active:hover,
 317+#articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot .articleFeedbackv5-reverseunhelpful-link.active:hover {
310318 /* @embed */
311319 background: url(images/bg-button.png) repeat-x;
312320 color: #fff;
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -97,37 +97,7 @@
9898 <a class="articlefeedbackv5-flyover-help" id="articlefeedbackv5-noteflyover-help" href="#"></a>\
9999 </div>\
100100 </form>';
101 -
102 - /**
103 - * Formatted and localized flyover panel HTMLs. These are initialized once on page setup.
104 - *
105 - * @var object
106 - */
107 - $.articleFeedbackv5special.notePanelHtml = {
108 - 'hide': undefined,
109 - 'show': undefined,
110 - 'requestoversight': undefined,
111 - 'unrequestoversight': undefined,
112 - 'oversight': undefined,
113 - 'declineoversight': undefined,
114 - 'unoversight': undefined
115 - };
116 -
117 - /**
118 - * Activity log flyover panel HTML
119 - *
120 - * @var string
121 - */
122 - $.articleFeedbackv5special.logPanelHtml = '\
123 - <div>\
124 - <div class="articlefeedbackv5-flyover-header">\
125 - <h3 id="articlefeedbackv5-noteflyover-caption">Activity log</h3>\
126 - <a id="articlefeedbackv5-noteflyover-helpbutton" href="#"></a>\
127 - <a id="articlefeedbackv5-noteflyover-close" href="#"></a>\
128 - </div>\
129 - <div id="articlefeedbackv5-activity-log"></div>\
130 - </div>';
131 -
 101+
132102 // }}}
133103 // {{{ Init methods
134104
@@ -158,20 +128,6 @@
159129 $.articleFeedbackv5special.activityCookieName += $.articleFeedbackv5special.page;
160130 $.articleFeedbackv5special.loadActivity();
161131
162 - // initialize flyover panels for actions
163 - $.articleFeedbackv5special.initFlyoverPanels();
164 -
165 - // Initial load
166 - $.articleFeedbackv5special.loadFeedback( true );
167 - };
168 -
169 - // }}}
170 - // {{{ initFlyoverPanels
171 -
172 - /**
173 - * Initialize the action note flyover panels
174 - */
175 - $.articleFeedbackv5special.initFlyoverPanels = function() {
176132 // set tipsy defaults, once
177133 $.fn.tipsy.defaults = {
178134 delayIn: 0, // delay before showing tooltip (ms)
@@ -187,20 +143,26 @@
188144 trigger: 'manual' // how tooltip is triggered - hover | focus | manual
189145 };
190146
191 - // i18n, create specific panels from template
 147+ // i18n, create action-specific tipsy panels from template
192148 var container = $( '<div></div>' );
193149 container.html( $.articleFeedbackv5special.notePanelHtmlTemplate );
194 - for( var action in $.articleFeedbackv5special.notePanelHtml ) {
195 - container.find( '#articlefeedbackv5-noteflyover-caption' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-caption' ) );
196 - container.find( '#articlefeedbackv5-noteflyover-label' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-label' ) );
197 - container.find( '#articlefeedbackv5-noteflyover-submit' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-submit' ) );
198 - container.find( '#articlefeedbackv5-noteflyover-submit' ).attr( 'rel', action );
199 - container.find( '#articlefeedbackv5-noteflyover-help' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-help' ) );
200 - container.find( '#articlefeedbackv5-noteflyover-help' ).attr( 'href', mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-help-link' ) );
201 - $.articleFeedbackv5special.notePanelHtml[action] = container.html();
 150+ for( var action in $.articleFeedbackv5special.actions ) {
 151+ if( $.articleFeedbackv5special.actions[action].hasTipsy && (undefined == $.articleFeedbackv5special.actions[action].tipsyHtml) ) {
 152+ container.find( '#articlefeedbackv5-noteflyover-caption' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-caption' ) );
 153+ container.find( '#articlefeedbackv5-noteflyover-label' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-label' ) );
 154+ container.find( '#articlefeedbackv5-noteflyover-submit' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-submit' ) );
 155+ // will add an 'action' attribute to the link
 156+ container.find( '#articlefeedbackv5-noteflyover-submit' ).attr( 'action', action );
 157+ container.find( '#articlefeedbackv5-noteflyover-help' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-help' ) );
 158+ container.find( '#articlefeedbackv5-noteflyover-help' ).attr( 'href', mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-help-link' ) );
 159+ $.articleFeedbackv5special.actions[action].tipsyHtml = container.html();
 160+ }
202161 }
203 - }
204 -
 162+
 163+ // Initial load
 164+ $.articleFeedbackv5special.loadFeedback( true );
 165+ };
 166+
205167 // }}}
206168 // {{{ setBinds
207169
@@ -258,145 +220,34 @@
259221 return false;
260222 } );
261223
262 - // Helpful and unhelpful
263 - $.each( ['helpful', 'unhelpful' ], function ( index, value ) {
264 - $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) {
265 - e.preventDefault();
266 - var $l = $( e.target );
267 - if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' )
268 - || $l.closest( '.articleFeedbackv5-feedback' ).data( 'deleted' ) ) {
269 - return false;
270 - }
271 - var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
272 - var activity = $.articleFeedbackv5special.getActivity( id );
273 - if ( activity[value] ) {
274 - $.articleFeedbackv5special.flagFeedback( id, value, -1 );
275 - } else if ( 'helpful' == value && activity.unhelpful ) {
276 - // Allow multiple simultaneous ajax requests in this case.
277 - $.articleFeedbackv5special.listControls.allowMultiple = true;
278 - $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', -1 );
279 - $.articleFeedbackv5special.flagFeedback( id, 'helpful', 1 );
280 - $.articleFeedbackv5special.listControls.allowMultiple = false;
281 - } else if ( 'unhelpful' == value && activity.helpful ) {
282 - // Allow multiple simultaneous ajax requests in this case.
283 - $.articleFeedbackv5special.listControls.allowMultiple = true;
284 - $.articleFeedbackv5special.flagFeedback( id, 'helpful', -1 );
285 - $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', 1 );
286 - $.articleFeedbackv5special.listControls.allowMultiple = false;
287 - } else {
288 - $.articleFeedbackv5special.flagFeedback( id, value, 1 );
289 - }
290 - } )
291 - } );
292 -
293 - // Flag/Unflag as abuse
294 - $( '.articleFeedbackv5-abuse-link' ).live( 'click', function( e ) {
295 - e.preventDefault();
296 - var $l = $( e.target );
297 - if ( $l.closest( '.articleFeedbackv5-feedback' ).data( 'hidden' )
298 - || $l.closest( '.articleFeedbackv5-feedback' ).data( 'deleted' ) ) {
299 - return false;
300 - }
301 - var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
302 - var activity = $.articleFeedbackv5special.getActivity( id );
303 - if ( activity.abuse ) {
304 - $.articleFeedbackv5special.flagFeedback( id, 'abuse', -1 );
305 - } else {
306 - $.articleFeedbackv5special.flagFeedback( id, 'abuse', 1 );
307 - }
308 - } );
309 -
310 - // Prepare an array of actions to bind
311 - var actions = ['activity'];
312 - for( var action in $.articleFeedbackv5special.notePanelHtml ) { actions.push(action); }
313 - // Bind tipsies
314 - for( var index in actions ) {
315 - var action = actions[index];
316 - $( '.articleFeedbackv5-' + action + '-link' ).live( 'click', function( e ) {
317 - e.preventDefault();
318 - var $l = $( e.target );
319 - // are we hiding the current tipsy?
320 - if( $l.attr( 'id' ) == $.articleFeedbackv5special.currentPanelHostId ) {
321 - $l.tipsy( 'hide' );
322 - $.articleFeedbackv5special.currentPanelHostId = undefined;
323 - } else {
324 - // no, we're displaying another one
325 - if( undefined != $.articleFeedbackv5special.currentPanelHostId ) {
326 - $( '#' + $.articleFeedbackv5special.currentPanelHostId ).tipsy( 'hide' );
327 - }
328 - $l.tipsy( 'show' );
329 - $.articleFeedbackv5special.currentPanelHostId= $l.attr( 'id' );
330 - // load activity if it is an activity log
331 - if( -1 != $l.attr( 'id' ).indexOf( 'articleFeedbackv5-activity-link-' ) ) {
332 - $.articleFeedbackv5special.loadActivityLog( $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ) );
333 - }
334 - }
335 - } );
 224+ // Bind actions
 225+ for( var action in $.articleFeedbackv5special.actions ) {
 226+ $( '.articleFeedbackv5-' + action + '-link' ).live( 'click', $.articleFeedbackv5special.actions[action].click );
336227 }
337228
338 - // Bind submit actions on flyover panels
 229+ // Bind submit actions on flyover panels (flag actions)
339230 $( '#articlefeedbackv5-noteflyover-submit' ).live( 'click', function( e ) {
340231 e.preventDefault();
341 - var $l = $( '#' + $.articleFeedbackv5special.currentPanelHostId );
342 - var action = $( e.target ).attr( 'rel' );
343 - var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
344 - var activity = $.articleFeedbackv5special.getActivity( id );
345 - var note = $( '#articlefeedbackv5-noteflyover-note' ).attr( 'value' );
346 - switch( action ) {
347 - case 'hide':
348 - $.articleFeedbackv5special.flagFeedback( id, 'hide', 1, note );
349 - break;
350 - case 'show':
351 - $.articleFeedbackv5special.flagFeedback( id, 'hide', -1, note );
352 - break;
353 - case 'oversight':
354 - $.articleFeedbackv5special.flagFeedback( id, 'delete', 1, note );
355 - break;
356 - case 'unoversight':
357 - $.articleFeedbackv5special.flagFeedback( id, 'delete', -1, note );
358 - break;
359 - case 'declineoversight':
360 - $.articleFeedbackv5special.flagFeedback( id, 'resetoversight', 1, note );
361 - break;
362 - case 'requestoversight':
363 - $.articleFeedbackv5special.flagFeedback( id, 'oversight', 1, note );
364 - break;
365 - case 'unrequestoversight':
366 - $.articleFeedbackv5special.flagFeedback( id, 'oversight', -1, note );
367 - break;
368 - }
 232+ $.articleFeedbackv5special.flagFeedback(
 233+ $( '#' + $.articleFeedbackv5special.currentPanelHostId ).closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ),
 234+ $( e.target ).attr( 'action' ),
 235+ $( '#articlefeedbackv5-noteflyover-note' ).attr( 'value' ) );
 236+
369237 // hide tipsy
370 - $l.tipsy( 'hide' );
 238+ $( '#' + $.articleFeedbackv5special.currentPanelHostId ).tipsy( 'hide' );
371239 $.articleFeedbackv5special.currentPanelHostId = undefined;
372240 } );
373241
374 - // flyover panel close button
 242+ // bind flyover panel close button
375243 $( '#articlefeedbackv5-noteflyover-close' ).live( 'click', function( e ) {
376244 e.preventDefault();
377 - var $l = $( '#' + $.articleFeedbackv5special.currentPanelHostId );
378 - $l.tipsy( 'hide' );
 245+ $( '#' + $.articleFeedbackv5special.currentPanelHostId ).tipsy( 'hide' );
379246 $.articleFeedbackv5special.currentPanelHostId = undefined;
380247 } );
381248
382 - // Delete/Undelete this post
383 - /*$( '.articleFeedbackv5-delete-link' ).live( 'click', function( e ) {
384 - e.preventDefault();
385 - var $l = $( e.target );
386 - var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
387 - var activity = $.articleFeedbackv5special.getActivity( id );
388 - if ( activity.delete
389 - || $( e.target ).text() == mw.msg('articlefeedbackv5-form-undelete')
390 - ) {
391 - $.articleFeedbackv5special.flagFeedback( id, 'delete', -1 );
392 - } else {
393 - $.articleFeedbackv5special.flagFeedback( id, 'delete', 1 );
394 - }
395 - } );*/
396249 }
397 -
398250 // }}}
399251 // {{{ bindPanels
400 -
401252 /**
402253 * Bind panels to controls - that cannot be 'live' events due to jQuery.typsy
403254 * limitations. This function should be invoked after feedback posts are loaded,
@@ -408,53 +259,52 @@
409260 $.articleFeedbackv5special.bindPanels = function( id ) {
410261 // single post or entire list?
411262 var $selector = !id ? $( '#articleFeedbackv5-show-feedback' ) : $( '.articleFeedbackv5-feedback[rel="' + id + '"]' );
412 -
413 - // hide/show action
414 - $selector.find( '.articleFeedbackv5-hide-link,.articleFeedbackv5-show-link' ).tipsy( {
415 - title: function() {
416 - var activity = $.articleFeedbackv5special.getActivity( id );
417 - return ( activity.hide || this.text == mw.msg( 'articlefeedbackv5-form-unhide' ) ) ?
418 - $.articleFeedbackv5special.notePanelHtml['show'] : $.articleFeedbackv5special.notePanelHtml['hide'];
419 - }
420 - } );
421 -
422 - // oversight/unoversight action
423 - $selector.find( '.articleFeedbackv5-oversight-link,.articleFeedbackv5-unoversight-link' ).tipsy( {
424 - title: function() {
425 - var activity = $.articleFeedbackv5special.getActivity( id );
426 - return ( activity.delete || this.text == mw.msg('articlefeedbackv5-form-undelete') ) ?
427 - $.articleFeedbackv5special.notePanelHtml['unoversight'] : $.articleFeedbackv5special.notePanelHtml['oversight'];
428 - }
429 - } );
430 -
431 - // request/unrequest oversight action
432 - $selector.find( '.articleFeedbackv5-requestoversight-link,.articleFeedbackv5-unrequestoversight-link' ).tipsy( {
433 - title: function() {
434 - var activity = $.articleFeedbackv5special.getActivity( id );
435 - return ( activity.oversight || this.text == mw.msg('articlefeedbackv5-form-unoversight') ) ?
436 - $.articleFeedbackv5special.notePanelHtml['unrequestoversight'] : $.articleFeedbackv5special.notePanelHtml['requestoversight'];
437 - }
438 - } );
439263
440 - // decline oversight action
441 - $selector.find( '.articleFeedbackv5-declineoversight-link' ).tipsy( {
442 - title: function() {
443 - return $.articleFeedbackv5special.notePanelHtml['declineoversight'];
444 - }
445 - } );
446 -
447 - // view activity action
448 - $selector.find( '.articleFeedbackv5-activity-link' ).tipsy( {
449 - title: function() {
450 - return $.articleFeedbackv5special.logPanelHtml;
451 - }
452 - } );
 264+ for( var action in $.articleFeedbackv5special.actions ) {
 265+ $selector.find( '.articleFeedbackv5-' + action + '-link' )
 266+ .attr( 'action', action )
 267+ .tipsy( {
 268+ title: function() {
 269+ return $.articleFeedbackv5special.actions[$( this ).attr( 'action' )].tipsyHtml;
 270+ }
 271+ } );
 272+ }
453273 }
 274+ // }}}
454275
455276 // }}}
 277+ // {{{ Utility methods
456278
 279+ // {{{ toggleTipsy
 280+ /**
 281+ * Toggles tipsy display for an action link
 282+ *
 283+ * @param e event
 284+ * @returns true if showing tipsy, false if hiding
 285+ */
 286+ $.articleFeedbackv5special.toggleTipsy = function( e ) {
 287+ e.preventDefault();
 288+ var $l = $( e.target );
 289+ // are we hiding the current tipsy?
 290+ if( $l.attr( 'id' ) == $.articleFeedbackv5special.currentPanelHostId ) {
 291+ $l.tipsy( 'hide' );
 292+ $.articleFeedbackv5special.currentPanelHostId = undefined;
 293+ return false;
 294+ } else {
 295+ // no, we're displaying another one
 296+ if( undefined != $.articleFeedbackv5special.currentPanelHostId ) {
 297+ $( '#' + $.articleFeedbackv5special.currentPanelHostId ).tipsy( 'hide' );
 298+ }
 299+ $l.tipsy( 'show' );
 300+ $.articleFeedbackv5special.currentPanelHostId = $l.attr( 'id' );
 301+ return true;
 302+ // load activity if it is an activity log
 303+ if( -1 != $l.attr( 'id' ).indexOf( 'articleFeedbackv5-activity-link-' ) ) {
 304+ $.articleFeedbackv5special.loadActivityLog( $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ) );
 305+ }
 306+ }
 307+ }
457308 // }}}
458 - // {{{ Utility methods
459309
460310 // {{{ toggleComment
461311 $.articleFeedbackv5special.toggleComment = function( id ) {
@@ -659,7 +509,6 @@
660510
661511 // }}}
662512 // {{{ unmarkDeleted
663 -
664513 /**
665514 * Utility method: Unmarks as deleted a feedback row
666515 *
@@ -670,10 +519,20 @@
671520 .data( 'deleted', false );
672521 $row.find( '.articleFeedbackv5-feedback-deleted-marker' ).remove();
673522 };
674 -
675523 // }}}
676524
 525+ // {{{ setActivityFlag
 526+ $.articleFeedbackv5special.setActivityFlag = function( id, flag, value ) {
 527+ // no activity for this post yet, create default structure
 528+ if ( !( id in $.articleFeedbackv5special.activity ) ) {
 529+ $.articleFeedbackv5special.activity[id] = { 'helpful': false, 'unhelpful': false, 'abuse': false, 'hide': false, 'delete': false };
 530+ }
 531+ $.articleFeedbackv5special.activity[id][flag] = value;
 532+ $.articleFeedbackv5special.storeActivity();
 533+ }
677534 // }}}
 535+
 536+ // }}}
678537 // {{{ Process methods
679538
680539 // {{{ flagFeedback
@@ -681,16 +540,16 @@
682541 /**
683542 * Sends the request to mark a response
684543 *
685 - * @param id int the feedback id
686 - * @param type string the type of mark (valid values: hide, abuse, delete, helpful, unhelpful)
687 - * @param dir int the direction of the mark (-1 = tick down; 1 = tick up)
688 - * @param note string note for action (default empty)
 544+ * @param id int the feedback id
 545+ * @param action string action to execute
 546+ * @param note string note for action (default empty)
689547 */
690 - $.articleFeedbackv5special.flagFeedback = function ( id, type, dir, note ) {
 548+ $.articleFeedbackv5special.flagFeedback = function ( id, action, note ) {
691549 // default parameters
692550 note = typeof note !== undefined ? note : '';
693551
694552 if( $.articleFeedbackv5special.listControls.disabled ) {
 553+ console.log('disabled');
695554 return false;
696555 }
697556
@@ -712,8 +571,8 @@
713572 'data' : {
714573 'pageid' : $.articleFeedbackv5special.page,
715574 'feedbackid': id,
716 - 'flagtype' : type,
717 - 'direction' : dir > 0 ? 'increase' : 'decrease',
 575+ 'flagtype' : $.articleFeedbackv5special.actions[action].apiFlagType,
 576+ 'direction' : $.articleFeedbackv5special.actions[action].apiFlagDir > 0 ? 'increase' : 'decrease',
718577 'note' : note,
719578 'format' : 'json',
720579 'action' : 'articlefeedbackv5-flag-feedback'
@@ -723,90 +582,17 @@
724583 if ( 'articlefeedbackv5-flag-feedback' in data ) {
725584 if ( 'result' in data['articlefeedbackv5-flag-feedback'] ) {
726585 if ( data['articlefeedbackv5-flag-feedback'].result == 'Success' ) {
727 - var $l = $( '#articleFeedbackv5-' + type + '-link-' + id );
728 - var $post = $l.closest( '.articleFeedbackv5-feedback' );
729 - // Helpful or unhelpful
730 - if ( 'helpful' in data['articlefeedbackv5-flag-feedback'] ) {
731 - $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
 586+ // invoke the registered onSuccess callback for the executed action
 587+ if( undefined != $.articleFeedbackv5special.actions[action].onSuccess ) {
 588+ $.articleFeedbackv5special.actions[action].onSuccess( id, data );
732589 }
733 - if ( 'helpful' == type || 'unhelpful' == type ) {
734 - if ( dir > 0 ) {
735 - $l.addClass( 'helpful-active' );
736 - } else {
737 - $l.removeClass( 'helpful-active' );
738 - }
739 - // Abusive
740 - } else if ( 'abuse' == type ) {
741 - if ( dir > 0 ) {
742 - if( mw.config.get( 'afCanEdit' ) == 1 ) {
743 - $l.text( mw.msg( 'articlefeedbackv5-abuse-saved', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
744 - } else {
745 - $l.text( mw.msg( 'articlefeedbackv5-abuse-saved-masked', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
746 - }
747 - } else {
748 - if( mw.config.get( 'afCanEdit' ) == 1 ) {
749 - $l.text( mw.msg( 'articlefeedbackv5-form-abuse', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
750 - } else {
751 - $l.text( mw.msg( 'articlefeedbackv5-form-abuse-masked', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
752 - }
753 - }
754 - $l.attr( 'rel', data['articlefeedbackv5-flag-feedback'].abuse_count );
755 - if ( data['articlefeedbackv5-flag-feedback'].abusive ) {
756 - $l.addClass( 'abusive' );
757 - } else {
758 - $l.removeClass( 'abusive' );
759 - }
760 - if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
761 - $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
762 - }
763 - // Hide/show
764 - } else if ( 'hide' == type ) {
765 - if ( dir > 0 ) {
766 - var $l = $( '#articleFeedbackv5-hide-link-' + id );
767 - $l.attr( 'id', 'articleFeedbackv5-show-link-' + id );
768 - $l.text( mw.msg( 'articlefeedbackv5-form-unhide' ) );
769 - $.articleFeedbackv5special.markHidden( $l.closest( '.articleFeedbackv5-feedback' ) );
770 - } else {
771 - var $l = $( '#articleFeedbackv5-show-link-' + id );
772 - $l.attr( 'id', 'articleFeedbackv5-hide-link-' + id );
773 - $l.text( mw.msg( 'articlefeedbackv5-form-hide' ) );
774 - $.articleFeedbackv5special.unmarkHidden( $l.closest( '.articleFeedbackv5-feedback' ));
775 - }
776 - // oversight/unoversight
777 - } else if ( 'delete' == type ) {
778 - if ( dir > 0 ) {
779 - var $l = $( '#articleFeedbackv5-oversight-link-' + id );
780 - $l.attr( 'id', 'articleFeedbackv5-unoversight-link-' + id );
781 - $l.text( mw.msg( 'articlefeedbackv5-form-undelete' ) );
782 - $.articleFeedbackv5special.markDeleted( $l.closest( '.articleFeedbackv5-feedback' ) );
783 - } else {
784 - var $l = $( '#articleFeedbackv5-unoversight-link-' + id );
785 - $l.attr( 'id', 'articleFeedbackv5-oversight-link-' + id );
786 - $l.text( mw.msg( 'articlefeedbackv5-form-delete' ) );
787 - $.articleFeedbackv5special.unmarkDeleted( $l.closest( '.articleFeedbackv5-feedback' ) );
788 - }
789 - // decline oversight
790 - } else if( 'resetoversight' == type ) {
791 - $( '#articleFeedbackv5-resetoversight-link-' + id ).remove();
792 - // request/unrequest oversight
793 - } else if( 'oversight' == type ) {
794 - if( dir > 0 ) {
795 - var $l = $( '#articleFeedbackv5-requestoversight-link-' + id );
796 - $l.attr( 'id', 'articleFeedbackv5-unrequestoversight-link-' + id );
797 - $l.text( mw.msg( 'articlefeedbackv5-form-unoversight' ) );
798 - } else {
799 - var $l = $( '#articleFeedbackv5-unrequestoversight-link-' + id );
800 - $l.attr( 'id', 'articleFeedbackv5-requestoversight-link-' + id );
801 - $l.text( mw.msg( 'articlefeedbackv5-form-oversight' ) );
802 - }
803 - }
804 - // Save activity
805 - if ( !( id in $.articleFeedbackv5special.activity ) ) {
806 - $.articleFeedbackv5special.activity[id] = { helpful: false, unhelpful: false, abuse: false, hide: false, delete: false };
807 - }
808 - $.articleFeedbackv5special.activity[id][type] = dir > 0 ? true : false;
809 - $.articleFeedbackv5special.storeActivity();
 590+
 591+ // Re-enable ajax flagging.
 592+ $.articleFeedbackv5special.listControls.disabled = false;
 593+
 594+ // re-bind panels (tipsies)
810595 $.articleFeedbackv5special.bindPanels( id );
 596+ return true;
811597 } else if ( data['articlefeedbackv5-flag-feedback'].result == 'Error' ) {
812598 mw.log( mw.msg( data['articlefeedbackv5-flag-feedback'].reason ) );
813599 }
@@ -828,7 +614,6 @@
829615 // {{{ loadActivityLog
830616
831617 $.articleFeedbackv5special.loadActivityLog = function( id ) {
832 - console.log('loadActivityLog');
833618 $.ajax( {
834619 'url': $.articleFeedbackv5special.apiUrl,
835620 'type': 'GET',
@@ -841,11 +626,10 @@
842627 'continue': 0
843628 },
844629 'success': function( data ) {
845 - console.log(data['articlefeedbackv5-view-activity'].activity);
846630 $( '#articlefeedbackv5-activity-log' ).html( data['articlefeedbackv5-view-activity'].activity );
847631 },
848632 'error': function( data ) {
849 - console.log('error');
 633+ $( '#articlefeedbackv5-activity-log' ).html( mw.msg( 'articleFeedbackv5-view-activity-error' ) );
850634 }
851635 } );
852636
@@ -894,10 +678,18 @@
895679 if ( id in $.articleFeedbackv5special.activity ) {
896680 var activity = $.articleFeedbackv5special.getActivity( id );
897681 if ( activity.helpful ) {
898 - $( this ).find( '#articleFeedbackv5-helpful-link-' + id ).addClass( 'helpful-active' );
 682+ $( this ).find( '#articleFeedbackv5-helpful-link-' + id )
 683+ .addClass( 'helpful-active' )
 684+ .removeClass( 'articleFeedbackv5-helpful-link' )
 685+ .addClass( 'articleFeedbackv5-reversehelpful-link' )
 686+ .attr( 'id', 'articleFeedbackv5-reversehelpful-link-' + id );
899687 }
900688 if ( activity.unhelpful ) {
901 - $( this ).find( '#articleFeedbackv5-unhelpful-link-' + id ).addClass( 'helpful-active' );
 689+ $( this ).find( '#articleFeedbackv5-unhelpful-link-' + id )
 690+ .addClass( 'helpful-active' )
 691+ .removeClass( 'articleFeedbackv5-unhelpful-link' )
 692+ .addClass( 'articleFeedbackv5-reverseunhelpful-link' )
 693+ .attr( 'id', 'articleFeedbackv5-reverseunhelpful-link-' + id );
902694 }
903695 if ( activity.abuse ) {
904696 var $l = $( this ).find( '#articleFeedbackv5-abuse-link-' + id );
@@ -906,6 +698,9 @@
907699 } else {
908700 $l.text( mw.msg( 'articlefeedbackv5-abuse-saved-masked', $l.attr( 'rel' ) ) );
909701 }
 702+ $l.attr( 'id', 'articleFeedbackv5-unabuse-link-' + id )
 703+ .removeClass( 'articleFeedbackv5-abuse-link' )
 704+ .addClass( 'articleFeedbackv5-unabuse-link' );
910705 }
911706 }
912707 if ( $( this ).hasClass( 'articleFeedbackv5-feedback-hidden' ) ) {
@@ -951,7 +746,6 @@
952747
953748 // }}}
954749 // {{{ storeActivity
955 -
956750 /**
957751 * Stores the user activity to the cookie
958752 */
@@ -963,9 +757,356 @@
964758 { 'expires': 365, 'path': '/' }
965759 );
966760 }
 761+ // }}}
 762+ // {{{ canBeFlagged
 763+ /**
 764+ * Returns true if the post can be flagged
 765+ */
 766+ $.articleFeedbackv5special.canBeFlagged = function( $post ) {
 767+ return !$post.data( 'hidden' ) && !$post.data( 'deleted' );
 768+ }
 769+ // }}}
967770
968771 // }}}
 772+
 773+ // {{{ Actions
 774+ /**
 775+ * Actions - available actions on the page.
 776+ *
 777+ * Each action is an object with the following properties:
 778+ * hasTipsy - true if the action needs a flyover panel
 779+ * tipsyHtml - html for the corresponding flyover panel
 780+ * click - click action
 781+ * apiFlagType - flag type for api call
 782+ * apiFlagDir - flag direction for api call (+/-1)
 783+ * onSuccess - callback to execute after action success. Callback parameters:
 784+ * id - respective post id
 785+ * data - any data returned by the AJAX call
 786+ */
 787+ $.articleFeedbackv5special.actions = {
 788+
 789+ // Vote helpful
 790+ 'helpful': {
 791+ 'hasTipsy': false,
 792+ 'click': function( e ) {
 793+ e.preventDefault();
 794+ var $link = $( e.target );
 795+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 796+ var id = $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
 797+ var activity = $.articleFeedbackv5special.getActivity( id );
 798+ $.articleFeedbackv5special.listControls.allowMultiple = true;
 799+ if( activity['unhelpful'] ) {
 800+ $.articleFeedbackv5special.flagFeedback( id, 'reverseunhelpful', '' );
 801+ }
 802+ $.articleFeedbackv5special.flagFeedback( id, 'helpful', '' );
 803+ $.articleFeedbackv5special.listControls.allowMultiple = false;
 804+ }
 805+ },
 806+ 'apiFlagType': 'helpful',
 807+ 'apiFlagDir': 1,
 808+ 'onSuccess': function( id, data ) {
 809+ $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
 810+ $( '#articleFeedbackv5-helpful-link-' + id )
 811+ .addClass( 'helpful-active' )
 812+ .removeClass( 'articleFeedbackv5-helpful-link' )
 813+ .addClass( 'articleFeedbackv5-reversehelpful-link' )
 814+ .attr( 'id', 'articleFeedbackv5-reversehelpful-link-' + id );
 815+ $.articleFeedbackv5special.setActivityFlag( id, 'helpful', true );
 816+ }
 817+ },
 818+
 819+ // Un-vote helpful
 820+ 'reversehelpful': {
 821+ 'hasTipsy': false,
 822+ 'click': function( e ) {
 823+ e.preventDefault();
 824+ var $link = $( e.target );
 825+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 826+ $.articleFeedbackv5special.flagFeedback(
 827+ $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ), 'reversehelpful', '' );
 828+ }
 829+ },
 830+ 'apiFlagType': 'helpful',
 831+ 'apiFlagDir': -1,
 832+ 'onSuccess': function( id, data ) {
 833+ $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
 834+ $( '#articleFeedbackv5-reversehelpful-link-' + id )
 835+ .removeClass( 'helpful-active' )
 836+ .removeClass( 'articleFeedbackv5-reversehelpful-link')
 837+ .addClass( 'articleFeedbackv5-helpful-link' )
 838+ .attr( 'id', 'articleFeedbackv5-helpful-link-' + id );
 839+ $.articleFeedbackv5special.setActivityFlag( id, 'helpful', false );
 840+ }
 841+ },
 842+
 843+ // Vote unhelpful
 844+ 'unhelpful': {
 845+ 'hasTipsy': false,
 846+ 'click': function( e ) {
 847+ e.preventDefault();
 848+ var $link = $( e.target );
 849+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 850+ var id = $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
 851+ var activity = $.articleFeedbackv5special.getActivity( id );
 852+ $.articleFeedbackv5special.listControls.allowMultiple = true;
 853+ if( activity['helpful'] ) {
 854+ $.articleFeedbackv5special.flagFeedback( id, 'reversehelpful', '' );
 855+ }
 856+ $.articleFeedbackv5special.flagFeedback( id, 'unhelpful', '' );
 857+ $.articleFeedbackv5special.listControls.allowMultiple = false;
 858+ }
 859+ },
 860+ 'apiFlagType': 'unhelpful',
 861+ 'apiFlagDir': 1,
 862+ 'onSuccess': function( id, data ) {
 863+ $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
 864+ $( '#articleFeedbackv5-unhelpful-link-' + id )
 865+ .addClass( 'helpful-active' )
 866+ .removeClass( 'articleFeedbackv5-unhelpful-link')
 867+ .addClass( 'articleFeedbackv5-reverseunhelpful-link' )
 868+ .attr( 'id', 'articleFeedbackv5-reverseunhelpful-link-' + id );
 869+ $.articleFeedbackv5special.setActivityFlag( id, 'unhelpful', true );
 870+ }
 871+ },
 872+
 873+ // Un-vote unhelpful
 874+ 'reverseunhelpful': {
 875+ 'hasTipsy': false,
 876+ 'click': function( e ) {
 877+ e.preventDefault();
 878+ var $link = $( e.target );
 879+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 880+ $.articleFeedbackv5special.flagFeedback(
 881+ $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ), 'reverseunhelpful', '' );
 882+ }
 883+ },
 884+ 'apiFlagType': 'unhelpful',
 885+ 'apiFlagDir': -1,
 886+ 'onSuccess': function( id, data ) {
 887+ $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful );
 888+ $( '#articleFeedbackv5-reverseunhelpful-link-' + id )
 889+ .removeClass( 'helpful-active' )
 890+ .removeClass( 'articleFeedbackv5-reverseunhelpful-link')
 891+ .addClass( 'articleFeedbackv5-unhelpful-link' )
 892+ .attr( 'id', 'articleFeedbackv5-unhelpful-link-' + id );
 893+ $.articleFeedbackv5special.setActivityFlag( id, 'unhelpful', false );
 894+ }
 895+ },
969896
 897+ // Flag post as abusive
 898+ 'abuse': {
 899+ 'hasTipsy': false,
 900+ 'click': function( e ) {
 901+ e.preventDefault();
 902+ var $link = $( e.target );
 903+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 904+ var id = $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
 905+ $.articleFeedbackv5special.flagFeedback( $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ), 'abuse', '' );
 906+ }
 907+ },
 908+ 'apiFlagType': 'abuse',
 909+ 'apiFlagDir': 1,
 910+ 'onSuccess': function( id, data ) {
 911+ $link = $( '#articleFeedbackv5-abuse-link-' + id );
 912+ if( mw.config.get( 'afCanEdit' ) == 1 ) {
 913+ $link.text( mw.msg( 'articlefeedbackv5-abuse-saved', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
 914+ } else {
 915+ $link.text( mw.msg( 'articlefeedbackv5-abuse-saved-masked', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
 916+ }
 917+ $link.attr( 'rel', data['articlefeedbackv5-flag-feedback'].abuse_count );
 918+ if ( data['articlefeedbackv5-flag-feedback'].abusive ) {
 919+ $link.addClass( 'abusive' );
 920+ } else {
 921+ $link.removeClass( 'abusive' );
 922+ }
 923+ if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
 924+ $.articleFeedbackv5special.markHidden( $link.closest( '.articleFeedbackv5-feedback' ) );
 925+ }
 926+ $link.attr( 'id', 'articleFeedbackv5-unabuse-link-' + id )
 927+ .removeClass( 'articleFeedbackv5-abuse-link' )
 928+ .addClass( 'articleFeedbackv5-unabuse-link' );
 929+ $.articleFeedbackv5special.setActivityFlag( id, 'abuse', true );
 930+ }
 931+ },
 932+
 933+ // Unflag post as abusive
 934+ 'unabuse': {
 935+ 'hasTipsy': false,
 936+ 'click': function( e ) {
 937+ e.preventDefault();
 938+ var $link = $( e.target );
 939+ if( $.articleFeedbackv5special.canBeFlagged( $link.closest( '.articleFeedbackv5-feedback' ) ) ) {
 940+ var id = $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
 941+ $.articleFeedbackv5special.flagFeedback( $link.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ), 'unabuse', '' );
 942+ }
 943+ },
 944+ 'apiFlagType': 'abuse',
 945+ 'apiFlagDir': -1,
 946+ 'onSuccess': function( id, data ) {
 947+ $link = $( '#articleFeedbackv5-unabuse-link-' + id );
 948+ if( mw.config.get( 'afCanEdit' ) == 1 ) {
 949+ $link.text( mw.msg( 'articlefeedbackv5-form-abuse', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
 950+ } else {
 951+ $link.text( mw.msg( 'articlefeedbackv5-form-abuse-masked', data['articlefeedbackv5-flag-feedback'].abuse_count ) );
 952+ }
 953+ $link.attr( 'rel', data['articlefeedbackv5-flag-feedback'].abuse_count );
 954+ if ( data['articlefeedbackv5-flag-feedback'].abusive ) {
 955+ $link.addClass( 'abusive' );
 956+ } else {
 957+ $link.removeClass( 'abusive' );
 958+ }
 959+ if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
 960+ $.articleFeedbackv5special.markHidden( $link.closest( '.articleFeedbackv5-feedback' ) );
 961+ }
 962+ $link.attr( 'id', 'articleFeedbackv5-abuse-link-' + id )
 963+ .removeClass( 'articleFeedbackv5-unabuse-link' )
 964+ .addClass( 'articleFeedbackv5-abuse-link' );
 965+ $.articleFeedbackv5special.setActivityFlag( id, 'abuse', false );
 966+ }
 967+ },
 968+
 969+ // Hide post action
 970+ 'hide': {
 971+ 'hasTipsy': true,
 972+ 'tipsyHtml': undefined,
 973+ 'click': $.articleFeedbackv5special.toggleTipsy,
 974+ 'apiFlagType': 'hide',
 975+ 'apiFlagDir': 1,
 976+ 'onSuccess': function( id, data ) {
 977+ var $link = $( '#articleFeedbackv5-hide-link-' + id )
 978+ .attr( 'action', 'show' )
 979+ .attr( 'id', 'articleFeedbackv5-show-link-' + id )
 980+ .text( mw.msg( 'articlefeedbackv5-form-unhide' ) )
 981+ .removeClass( 'articleFeedbackv5-hide-link' )
 982+ .addClass( 'articleFeedbackv5-show-link' );
 983+ $.articleFeedbackv5special.markHidden( $link.closest( '.articleFeedbackv5-feedback' ) );
 984+ $.articleFeedbackv5special.setActivityFlag( id, 'hide', true );
 985+ }
 986+ },
 987+
 988+ // Show post action
 989+ 'show': {
 990+ 'hasTipsy': true,
 991+ 'tipsyHtml': undefined,
 992+ 'click': $.articleFeedbackv5special.toggleTipsy,
 993+ 'apiFlagType': 'hide',
 994+ 'apiFlagDir': -1,
 995+ 'onSuccess': function( id, data ) {
 996+ var $link = $( '#articleFeedbackv5-show-link-' + id )
 997+ .attr( 'action', 'hide' )
 998+ .attr( 'id', 'articleFeedbackv5-hide-link-' + id )
 999+ .text( mw.msg( 'articlefeedbackv5-form-hide' ) )
 1000+ .removeClass( 'articleFeedbackv5-show-link' )
 1001+ .addClass( 'articleFeedbackv5-hide-link' );
 1002+ $.articleFeedbackv5special.unmarkHidden( $link.closest( '.articleFeedbackv5-feedback' ));
 1003+ $.articleFeedbackv5special.setActivityFlag( id, 'hide', false );
 1004+ }
 1005+ },
 1006+
 1007+ // Request oversight action
 1008+ 'requestoversight': {
 1009+ 'hasTipsy': true,
 1010+ 'tipsyHtml': undefined,
 1011+ 'click': $.articleFeedbackv5special.toggleTipsy,
 1012+ 'apiFlagType': 'oversight',
 1013+ 'apiFlagDir': 1,
 1014+ 'onSuccess': function( id, data ) {
 1015+ $( '#articleFeedbackv5-requestoversight-link-' + id )
 1016+ .attr( 'action', 'unrequestoversight' )
 1017+ .attr( 'id', 'articleFeedbackv5-unrequestoversight-link-' + id )
 1018+ .text( mw.msg( 'articlefeedbackv5-form-unoversight' ) )
 1019+ .removeClass( 'articleFeedbackv5-requestoversight-link' )
 1020+ .addClass( 'articleFeedbackv5-unrequestoversight-link');
 1021+ }
 1022+ },
 1023+
 1024+ // Cancel oversight request action
 1025+ 'unrequestOversight': {
 1026+ 'hasTipsy': true,
 1027+ 'tipsyHtml': undefined,
 1028+ 'click': $.articleFeedbackv5special.toggleTipsy,
 1029+ 'apiFlagType': 'oversight',
 1030+ 'apiFlagDir': -1,
 1031+ 'onSuccess': function( id, data ) {
 1032+ $( '#articleFeedbackv5-unrequestoversight-link-' + id )
 1033+ .attr( 'action', 'requestoversight' )
 1034+ .attr( 'id', 'articleFeedbackv5-requestoversight-link-' + id )
 1035+ .text( mw.msg( 'articlefeedbackv5-form-oversight' ) )
 1036+ .removeClass( 'articleFeedbackv5-unrequestoversight-link' )
 1037+ .addClass( 'articleFeedbackv5-requestoversight-link');
 1038+ }
 1039+ },
 1040+
 1041+ // Oversight post action
 1042+ 'oversight': {
 1043+ 'hasTipsy': true,
 1044+ 'tipsyHtml': undefined,
 1045+ 'click': $.articleFeedbackv5special.toggleTipsy,
 1046+ 'apiFlagType': 'delete',
 1047+ 'apiFlagDir': 1,
 1048+ 'onSuccess': function( id, data ) {
 1049+ var $link = $( '#articleFeedbackv5-oversight-link-' + id )
 1050+ .attr( 'action', 'unoversight' )
 1051+ .attr( 'id', 'articleFeedbackv5-unoversight-link-' + id )
 1052+ .text( mw.msg( 'articlefeedbackv5-form-undelete' ) )
 1053+ .removeClass( 'articleFeedbackv5-oversight-link' )
 1054+ .addClass( 'articleFeedbackv5-unoversight-link' );
 1055+ $.articleFeedbackv5special.markDeleted( $link.closest( '.articleFeedbackv5-feedback' ) );
 1056+ $.articleFeedbackv5special.setActivityFlag( id, 'delete', true );
 1057+ }
 1058+ },
 1059+
 1060+ // Un-oversight action
 1061+ 'unoversight': {
 1062+ 'hasTipsy': true,
 1063+ 'tipsyHtml': undefined,
 1064+ 'click': $.articleFeedbackv5special.toggleTipsy,
 1065+ 'apiFlagType': 'delete',
 1066+ 'apiFlagDir': 1,
 1067+ 'onSuccess': function( id, data ) {
 1068+ var $link = $( '#articleFeedbackv5-unoversight-link-' + id )
 1069+ .attr( 'action', 'oversight' )
 1070+ .attr( 'id', 'articleFeedbackv5-oversight-link-' + id )
 1071+ .text( mw.msg( 'articlefeedbackv5-form-delete' ) )
 1072+ .removeClass( 'articleFeedbackv5-unoversight-link' )
 1073+ .addClass( 'articleFeedbackv5-oversight-link' );
 1074+ $.articleFeedbackv5special.unmarkDeleted( $link.closest( '.articleFeedbackv5-feedback' ) );
 1075+ $.articleFeedbackv5special.setActivityFlag( id, 'delete', false );
 1076+ }
 1077+ },
 1078+
 1079+ // Decline oversight action
 1080+ 'declineoversight': {
 1081+ 'hasTipsy': true,
 1082+ 'tipsyHtml': undefined,
 1083+ 'click': $.articleFeedbackv5special.toggleTipsy,
 1084+ 'apiFlagType': 'resetoversight',
 1085+ 'apiFlagDir': 1,
 1086+ 'onSuccess': function( id, data ) {
 1087+ $( '#articleFeedbackv5-declineoversight-link-' + id ).remove();
 1088+ }
 1089+ },
 1090+
 1091+ // View activity log action
 1092+ 'activity': {
 1093+ 'hasTipsy': true,
 1094+ 'tipsyHtml': '\
 1095+ <div>\
 1096+ <div class="articlefeedbackv5-flyover-header">\
 1097+ <h3 id="articlefeedbackv5-noteflyover-caption">Activity log</h3>\
 1098+ <a id="articlefeedbackv5-noteflyover-helpbutton" href="#"></a>\
 1099+ <a id="articlefeedbackv5-noteflyover-close" href="#"></a>\
 1100+ </div>\
 1101+ <div id="articlefeedbackv5-activity-log"></div>\
 1102+ </div>',
 1103+ 'click': function( e ) {
 1104+ if( $.articleFeedbackv5special.toggleTipsy( e ) ) {
 1105+ $.articleFeedbackv5special.loadActivityLog( $( e.target ).closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ) );
 1106+ }
 1107+ }
 1108+ }
 1109+
 1110+ };
9701111 // }}}
9711112
9721113 // }}}

Comments

#Comment by Catrope (talk | contribs)   17:52, 6 March 2012
+ container.find( '#articlefeedbackv5-noteflyover-caption' ).html( mw.msg( 'articlefeedbackv5-noteflyover-' + action + '-caption' ) );

This is not an HTML-safe way of including messages, but the vast majority of these occurrences have been fixed since.

+ $l.tipsy( 'show' );
+ $.articleFeedbackv5special.currentPanelHostId = $l.attr( 'id' );
+ return true;
+ // load activity if it is an activity log
+ if( -1 != $l.attr( 'id' ).indexOf( 'articleFeedbackv5-activity-link-' ) ) {
+ $.articleFeedbackv5special.loadActivityLog( $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' ) );
+ }

Dead code after return true; , has been removed since.

+ console.log('disabled');

Debugging code, has been removed since.

Status & tagging log