Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -57,6 +57,8 @@ |
58 | 58 | 'moodbar-loading-subtitle' => 'We are sharing your feedback…', |
59 | 59 | 'moodbar-success-subtitle' => 'Sharing your editing experience helps us improve $1.', |
60 | 60 | '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.', |
61 | 63 | // Special:MoodBar |
62 | 64 | 'right-moodbar-view' => 'View and export MoodBar feedback', |
63 | 65 | 'right-moodbar-admin' => 'Alter visibility on the feedback dashboard', |
— | — | @@ -208,6 +210,8 @@ |
209 | 211 | 'moodbar-error-title' => 'Title of the screen when after an error occurred and submission aborted.', |
210 | 212 | 'moodbar-success-subtitle' => 'Subtitle of screen when feedback was successfullyully submitted. $1 is the SITENAME', |
211 | 213 | '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.', |
212 | 216 | 'right-moodbar-view' => '{{doc-right|moodbar-view}}', |
213 | 217 | 'right-moodbar-admin' => '{{doc-right|moodbar-admin}}', |
214 | 218 | 'moodbar-header-timestamp' => '{{Identical|Timestamp}}', |
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.css |
— | — | @@ -95,6 +95,10 @@ |
96 | 96 | outline: none; |
97 | 97 | } |
98 | 98 | |
| 99 | +.mw-moodBar-feedback-invalid { |
| 100 | + border:2px solid #CC0000; |
| 101 | +} |
| 102 | + |
99 | 103 | .mw-moodBar-privacy, |
100 | 104 | .mw-moodBar-overlayWhatContent { |
101 | 105 | font-size: 10px; |
— | — | @@ -109,6 +113,7 @@ |
110 | 114 | } |
111 | 115 | .mw-moodBar-formInputs { |
112 | 116 | padding-left: 1em; |
| 117 | + padding-right: .2em; |
113 | 118 | } |
114 | 119 | |
115 | 120 | .mw-moodBar-state-loading { |
— | — | @@ -128,6 +133,11 @@ |
129 | 134 | color: #7e7e7e; |
130 | 135 | } |
131 | 136 | |
| 137 | +.red-bold { |
| 138 | + font-weight:bold; |
| 139 | + color:#CC0000; |
| 140 | +} |
| 141 | + |
132 | 142 | /** |
133 | 143 | * Types |
134 | 144 | */ |
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | <html:msg key="moodbar-form-title" />\ |
28 | 28 | </div>\ |
29 | 29 | <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>\ |
31 | 31 | <div class="mw-moodBar-privacy"></div>\ |
32 | 32 | <input type="button" class="mw-moodBar-formSubmit" disabled="disabled" />\ |
33 | 33 | </div>\ |
— | — | @@ -56,6 +56,11 @@ |
57 | 57 | <div class="mw-moodBar-state mw-moodBar-state-error">\ |
58 | 58 | <div class="mw-moodBar-state-title"><html:msg key="moodbar-error-title" /></div>\ |
59 | 59 | <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>\ |
60 | 65 | </div>' |
61 | 66 | }, |
62 | 67 | |
— | — | @@ -92,6 +97,11 @@ |
93 | 98 | setTimeout( function() { |
94 | 99 | mb.ui.overlay.fadeOut(); |
95 | 100 | }, 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 ); |
96 | 106 | } else { |
97 | 107 | mb.swapContent( mb.tpl.error ); |
98 | 108 | } |
— | — | @@ -231,8 +241,8 @@ |
232 | 242 | .find( '.mw-moodBar-formSubmit' ) |
233 | 243 | .val( mw.msg( 'moodbar-form-submit' ) ) |
234 | 244 | .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 ){ |
237 | 247 | mb.swapContent( mb.tpl.loading ); |
238 | 248 | $.moodBar.submit( mb.feedbackItem ); |
239 | 249 | } |
— | — | @@ -248,8 +258,24 @@ |
249 | 259 | |
250 | 260 | // Set up character counter |
251 | 261 | // 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 | + }); |
254 | 280 | }, |
255 | 281 | |
256 | 282 | core: function() { |
— | — | @@ -314,7 +340,8 @@ |
315 | 341 | }, |
316 | 342 | |
317 | 343 | 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 ) { |
319 | 346 | mb.ui.overlay.find( '.mw-moodBar-formSubmit').removeAttr('disabled'); |
320 | 347 | } else { |
321 | 348 | 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 @@ |
285 | 285 | overflow:hidden; |
286 | 286 | } |
287 | 287 | |
| 288 | +.fbd-response-text-invalid { |
| 289 | + border:2px solid #CC0000; |
| 290 | +} |
| 291 | + |
288 | 292 | .fbd-response-preview-spinner { |
289 | 293 | height:32px; |
290 | 294 | line-height:32px; |
— | — | @@ -337,4 +341,8 @@ |
338 | 342 | } |
339 | 343 | .center { |
340 | 344 | text-align:center; |
| 345 | +} |
| 346 | +.red-bold { |
| 347 | + font-weight:bold; |
| 348 | + color:#CC0000; |
341 | 349 | } |
\ No newline at end of file |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -444,7 +444,23 @@ |
445 | 445 | |
446 | 446 | $item.append(inlineForm) |
447 | 447 | .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 | + }) |
449 | 465 | .end() |
450 | 466 | .find('.fbd-response-text') |
451 | 467 | .keyup( function(event) { |
— | — | @@ -524,7 +540,29 @@ |
525 | 541 | .delay(2000) |
526 | 542 | .fadeOut('slow', callback); |
527 | 543 | } |
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 | + } |
529 | 567 | // On-load stuff |
530 | 568 | |
531 | 569 | $('.fbd-item-show a').live( 'click', showHiddenItem ); |
— | — | @@ -575,33 +613,14 @@ |
576 | 614 | 'url': mw.util.wikiScript( 'api' ), |
577 | 615 | 'data': resData, |
578 | 616 | '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 | + } |
594 | 622 | }, |
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' ) ); |
606 | 625 | }, |
607 | 626 | 'dataType': 'json' |
608 | 627 | } ); |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -133,6 +133,8 @@ |
134 | 134 | 'moodbar-loading-subtitle', |
135 | 135 | 'moodbar-error-subtitle', |
136 | 136 | 'moodbar-success-subtitle', |
| 137 | + 'moodbar-blocked-title', |
| 138 | + 'moodbar-blocked-subtitle', |
137 | 139 | ), |
138 | 140 | 'dependencies' => array( |
139 | 141 | 'mediawiki.util', |