r104937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104936‎ | r104937 | r104938 >
Date:01:39, 2 December 2011
Author:rmoen
Status:ok (Comments)
Tags:todo 
Comment:
added response handling for blocked user on moodbar and feedback dashboard, improved js validation for mb, added red border to textareas when counts are over limit
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.css (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -57,6 +57,8 @@
5858 'moodbar-loading-subtitle' => 'We are sharing your feedback…',
5959 'moodbar-success-subtitle' => 'Sharing your editing experience helps us improve $1.',
6060 'moodbar-error-subtitle' => 'Something went wrong! Please try sharing your feedback again later.',
 61+ 'moodbar-blocked-title' => 'Blocked!',
 62+ 'moodbar-blocked-subtitle' => 'You have been blocked from editing.',
6163 // Special:MoodBar
6264 'right-moodbar-view' => 'View and export MoodBar feedback',
6365 'right-moodbar-admin' => 'Alter visibility on the feedback dashboard',
@@ -208,6 +210,8 @@
209211 'moodbar-error-title' => 'Title of the screen when after an error occurred and submission aborted.',
210212 'moodbar-success-subtitle' => 'Subtitle of screen when feedback was successfullyully submitted. $1 is the SITENAME',
211213 'moodbar-error-subtitle' => 'Subtitle of screen when an error occurred. $1 is the SITENAME',
 214+ 'moodbar-blocked-title' => 'Title of the screen after blocked user attempts to post feedback.',
 215+ 'moodbar-blocked-subtitle' => 'Subtitle of screen after blocked user attempts to post feedback.',
212216 'right-moodbar-view' => '{{doc-right|moodbar-view}}',
213217 'right-moodbar-admin' => '{{doc-right|moodbar-admin}}',
214218 'moodbar-header-timestamp' => '{{Identical|Timestamp}}',
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.css
@@ -95,6 +95,10 @@
9696 outline: none;
9797 }
9898
 99+.mw-moodBar-feedback-invalid {
 100+ border:2px solid #CC0000;
 101+}
 102+
99103 .mw-moodBar-privacy,
100104 .mw-moodBar-overlayWhatContent {
101105 font-size: 10px;
@@ -109,6 +113,7 @@
110114 }
111115 .mw-moodBar-formInputs {
112116 padding-left: 1em;
 117+ padding-right: .2em;
113118 }
114119
115120 .mw-moodBar-state-loading {
@@ -128,6 +133,11 @@
129134 color: #7e7e7e;
130135 }
131136
 137+.red-bold {
 138+ font-weight:bold;
 139+ color:#CC0000;
 140+}
 141+
132142 /**
133143 * Types
134144 */
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js
@@ -26,7 +26,7 @@
2727 <html:msg key="moodbar-form-title" />\
2828 </div>\
2929 <div class="mw-moodBar-formInputs">\
30 - <textarea rows="3" maxlength="140" id="mw-moodBar-feedbackInput" class="mw-moodBar-formInput" /></textarea>\
 30+ <textarea rows="3" id="mw-moodBar-feedbackInput" class="mw-moodBar-formInput" /></textarea>\
3131 <div class="mw-moodBar-privacy"></div>\
3232 <input type="button" class="mw-moodBar-formSubmit" disabled="disabled" />\
3333 </div>\
@@ -56,6 +56,11 @@
5757 <div class="mw-moodBar-state mw-moodBar-state-error">\
5858 <div class="mw-moodBar-state-title"><html:msg key="moodbar-error-title" /></div>\
5959 <div class="mw-moodBar-state-subtitle"><html:msg key="moodbar-error-subtitle" /></div>\
 60+ </div>',
 61+ blocked: '\
 62+ <div class="mw-moodBar-state mw-moodBar-state-blocked">\
 63+ <div class="mw-moodBar-state-title"><html:msg key="moodbar-blocked-title" /></div>\
 64+ <div class="mw-moodBar-state-subtitle"><html:msg key="moodbar-blocked-subtitle" /></div>\
6065 </div>'
6166 },
6267
@@ -92,6 +97,11 @@
9398 setTimeout( function() {
9499 mb.ui.overlay.fadeOut();
95100 }, 3000 );
 101+ } else if (data && data.error && data.error.code === 'blocked') {
 102+ mb.swapContent( mb.tpl.blocked );
 103+ setTimeout( function() {
 104+ mb.ui.overlay.fadeOut();
 105+ }, 3000 );
96106 } else {
97107 mb.swapContent( mb.tpl.error );
98108 }
@@ -231,8 +241,8 @@
232242 .find( '.mw-moodBar-formSubmit' )
233243 .val( mw.msg( 'moodbar-form-submit' ) )
234244 .click( function() {
235 - mb.feedbackItem.comment = mb.ui.overlay.find( '.mw-moodBar-formInput' ).val();
236 - if(mb.feedbackItem.comment){
 245+ mb.feedbackItem.comment = $.trim(mb.ui.overlay.find( '.mw-moodBar-formInput' ).val() );
 246+ if( mb.feedbackItem.comment.length > 0 ){
237247 mb.swapContent( mb.tpl.loading );
238248 $.moodBar.submit( mb.feedbackItem );
239249 }
@@ -248,8 +258,24 @@
249259
250260 // Set up character counter
251261 // This is probably not the right way to do this.
252 - $( '#mw-moodBar-feedbackInput' ).NobleCount('#mw-moodBar-charCount', {max_chars:140});
253 -
 262+ $( '#mw-moodBar-feedbackInput' )
 263+ .NobleCount('#mw-moodBar-charCount', {
 264+ max_chars:140,
 265+ on_negative: function( t_obj ) {
 266+ $( t_obj )
 267+ .addClass('mw-moodBar-feedback-invalid')
 268+ .parent().prev()
 269+ .find('.mw-moodBar-formNote')
 270+ .addClass('red-bold');
 271+ },
 272+ on_positive: function( t_obj ) {
 273+ $( t_obj )
 274+ .removeClass( 'mw-moodBar-feedback-invalid')
 275+ .parent().prev()
 276+ .find('.mw-moodBar-formNote')
 277+ .removeClass('red-bold');
 278+ }
 279+ });
254280 },
255281
256282 core: function() {
@@ -314,7 +340,8 @@
315341 },
316342
317343 validate: function() {
318 - if( $( '#mw-moodBar-feedbackInput' ).val() !== "" && $( '.mw-moodBar-selected').length ) {
 344+ var comment = $( '#mw-moodBar-feedbackInput' ).val();
 345+ if( $.trim( comment ).length > 0 && comment.length <= 140 && $( '.mw-moodBar-selected').length ) {
319346 mb.ui.overlay.find( '.mw-moodBar-formSubmit').removeAttr('disabled');
320347 } else {
321348 mb.ui.overlay.find( '.mw-moodBar-formSubmit').attr({'disabled':'true'});
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css
@@ -284,6 +284,10 @@
285285 overflow:hidden;
286286 }
287287
 288+.fbd-response-text-invalid {
 289+ border:2px solid #CC0000;
 290+}
 291+
288292 .fbd-response-preview-spinner {
289293 height:32px;
290294 line-height:32px;
@@ -337,4 +341,8 @@
338342 }
339343 .center {
340344 text-align:center;
 345+}
 346+.red-bold {
 347+ font-weight:bold;
 348+ color:#CC0000;
341349 }
\ No newline at end of file
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js
@@ -444,7 +444,23 @@
445445
446446 $item.append(inlineForm)
447447 .find('.fbd-response-text')
448 - .NobleCount('.fbd-response-charCount', {max_chars:5000})
 448+ .NobleCount('.fbd-response-charCount', {
 449+ max_chars:5000,
 450+ on_negative: function( t_obj ) {
 451+ $( t_obj )
 452+ .addClass('fbd-response-text-invalid')
 453+ .prev()
 454+ .find('span')
 455+ .addClass('red-bold');
 456+ },
 457+ on_positive: function( t_obj ) {
 458+ $( t_obj )
 459+ .removeClass( 'fbd-response-text-invalid')
 460+ .prev()
 461+ .find('span')
 462+ .removeClass('red-bold');
 463+ }
 464+ })
449465 .end()
450466 .find('.fbd-response-text')
451467 .keyup( function(event) {
@@ -524,7 +540,29 @@
525541 .delay(2000)
526542 .fadeOut('slow', callback);
527543 }
528 -
 544+ /**
 545+ * Set status message for Send Response
 546+ * @param $el Feedback Item for response
 547+ * @param type is type of message which determins icon (error, success)
 548+ * @param head Heading text to be displayed
 549+ * @param body Body text to be displayed
 550+ */
 551+ function responseMessage ($el, type, head, body) {
 552+ $el
 553+ .find('.mw-ajax-loader')
 554+ .addClass('fbd-item-response-' + type)
 555+ .removeClass('mw-ajax-loader')
 556+ .end()
 557+ .find('.fbd-ajax-heading')
 558+ .text( head )
 559+ .end()
 560+ .find('.fbd-ajax-text')
 561+ .html( body )
 562+ .end();
 563+ setTimeout(function(){
 564+ reloadItem($el, true);
 565+ }, 2000);
 566+ }
529567 // On-load stuff
530568
531569 $('.fbd-item-show a').live( 'click', showHiddenItem );
@@ -575,33 +613,14 @@
576614 'url': mw.util.wikiScript( 'api' ),
577615 'data': resData,
578616 'success': function (data) {
579 - $responseForm
580 - .find('.mw-ajax-loader')
581 - .addClass('fbd-item-response-success')
582 - .removeClass('mw-ajax-loader')
583 - .end()
584 - .find('.fbd-ajax-heading')
585 - .text( mw.msg( 'response-ajax-success-head' ) )
586 - .end()
587 - .find('.fbd-ajax-text')
588 - .html( mw.msg( 'response-ajax-success-body') )
589 - .end();
590 - setTimeout(function(){
591 - reloadItem($item, true);
592 - }, 2000);
593 -
 617+ if('error' in data) { //if rejected
 618+ responseMessage ($item, 'error', mw.msg( 'response-ajax-error-head' ), data.error.info );
 619+ } else if('feedbackdashboardresponse' in data) { //if successful
 620+ responseMessage ($item, 'success', mw.msg( 'response-ajax-success-head' ), mw.msg( 'response-ajax-success-body' ) );
 621+ }
594622 },
595 - 'error': function( jqXHR, textStatus, errorThrown ) {
596 - $responseForm
597 - .find('.mw-ajax-loader')
598 - .addClass('fbd-item-response-error')
599 - .removeClass('mw-ajax-loader')
600 - .end()
601 - .find('.fbd-ajax-heading')
602 - .text( mw.msg( 'response-ajax-error-head' ) )
603 - .end()
604 - .find('.fbd-ajax-text')
605 - .html( mw.msg( 'response-ajax-error-body' ) );
 623+ 'error': function( jqXHR, textStatus, errorThrown ) {
 624+ responseMessage ($item, 'error', mw.msg( 'response-ajax-error-head' ), mw.msg( 'response-ajax-error-body' ) );
606625 },
607626 'dataType': 'json'
608627 } );
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -133,6 +133,8 @@
134134 'moodbar-loading-subtitle',
135135 'moodbar-error-subtitle',
136136 'moodbar-success-subtitle',
 137+ 'moodbar-blocked-title',
 138+ 'moodbar-blocked-subtitle',
137139 ),
138140 'dependencies' => array(
139141 'mediawiki.util',

Follow-up revisions

RevisionCommit summaryAuthorDate
r106060added comments for NobleCount callback parameter. followup to r104937rmoen18:45, 13 December 2011

Comments

#Comment by Raindrift (talk | contribs)   22:42, 12 December 2011

It'd be awesome to know what t_obj is (like, if it had a more descriptive name), but otherwise looks fine. Marking todo for that, just so this comment doesn't get lost.

Status & tagging log