Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | 'moodbar-respond-expanded' => '▼', // Ignore, do not translate. ▼ |
39 | 39 | 'moodbar-respond-text' => 'Respond to this', |
40 | 40 | 'moodbar-response-add' => 'Add a response', |
41 | | - 'moodbar-response-nosig' => 'signature not required', |
| 41 | + 'moodbar-response-desc' => 'Response will reference original comment. Signature not required.', |
42 | 42 | 'moodbar-response-btn' => 'Send response', |
43 | 43 | 'moodbar-what-content' => 'This feature is designed to help the community understand the experience of people editing the site. |
44 | 44 | For more information, please visit the $1.', |
— | — | @@ -139,6 +139,16 @@ |
140 | 140 | 'moodbar-response-gfdl' => 'GFDL', |
141 | 141 | 'moodbar-response-gfdl-link' => 'http://www.gnu.org/copyleft/fdl.html', |
142 | 142 | 'feedbackresponse-success' => 'Thank you. Your response was added to the user\'s talk page.', |
| 143 | + 'response-back-text' => 'Back', |
| 144 | + 'response-preview-text' => 'Preview', |
| 145 | + 'response-ajax-action-head' => 'Responding...', |
| 146 | + 'response-ajax-action-body' => 'Your response is being added.', |
| 147 | + 'response-ajax-success-head' => 'Thanks!', |
| 148 | + 'response-ajax-success-body' => 'Your response has been added.', |
| 149 | + 'response-ajax-error-head' => 'Oops!', |
| 150 | + 'response-ajax-error-body' => 'There was an error adding your response. <br />Please try again later.', |
| 151 | + |
| 152 | + |
143 | 153 | ); |
144 | 154 | |
145 | 155 | /** Message documentation (Message documentation) |
— | — | @@ -253,6 +263,24 @@ |
254 | 264 | 'moodbar-response-gfdl' => '{{optional}} |
255 | 265 | GFDL Text', |
256 | 266 | 'feedbackresponse-success' => 'Text for successful feedback response', |
| 267 | + 'moodbar-action-reason' => 'Text for Admin action reason', |
| 268 | + 'moodbar-action-reason-required' => 'Text explaining admin action reason is required', |
| 269 | + 'moodbar-feedback-action-confirm' => 'Text for admin action confirm button', |
| 270 | + 'moodbar-feedback-action-cancel' => 'Text for admin action cancel button', |
| 271 | + 'moodbar-respond-text' => 'Text for Response toggle', |
| 272 | + 'moodbar-respond-collapsed' => 'Special character for response form collapsed', |
| 273 | + 'moodbar-respond-expanded' => 'Special character for response form expanded', |
| 274 | + 'moodbar-response-add' => 'Text for Response heading', |
| 275 | + 'moodbar-response-desc' => 'Text explaining signature is not required, and indicating that the original feedback will be referenced in response', |
| 276 | + 'moodbar-response-btn' => 'Text for Response button', |
| 277 | + 'response-back-text' => 'Text for response preview back button', |
| 278 | + 'response-preview-text' => 'Text for preview response preview button', |
| 279 | + 'response-ajax-action-head' => 'Text for ajax status heading while request is being made', |
| 280 | + 'response-ajax-action-body' => 'Text for ajax status body while request is being made (can be html)', |
| 281 | + 'response-ajax-success-head' => 'Text for ajax status heading on successful response', |
| 282 | + 'response-ajax-success-body' => 'Text for ajax status body on successful response (can be html)', |
| 283 | + 'response-ajax-error-head' => 'Text for ajax status heading on error', |
| 284 | + 'response-ajax-error-body' => 'Text for ajax status body on error (can be html)', |
257 | 285 | ); |
258 | 286 | |
259 | 287 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/MoodBar/modules/jquery.elastic/jquery.elastic.js |
— | — | @@ -0,0 +1,164 @@ |
| 2 | +/** |
| 3 | +* @name Elastic |
| 4 | +* @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically |
| 5 | +* @version 1.6.10 |
| 6 | +* @requires jQuery 1.2.6+ |
| 7 | +* |
| 8 | +* @author Jan Jarfalk |
| 9 | +* @author-email jan.jarfalk@unwrongest.com |
| 10 | +* @author-website http://www.unwrongest.com |
| 11 | +* |
| 12 | +* @licence MIT License - http://www.opensource.org/licenses/mit-license.php |
| 13 | +* |
| 14 | +* This file has been downloaded from http://unwrongest.com/projects/elastic/, please notify the author of |
| 15 | +* any changes. |
| 16 | +*/ |
| 17 | + |
| 18 | +(function(jQuery){ |
| 19 | + jQuery.fn.extend({ |
| 20 | + elastic: function() { |
| 21 | + |
| 22 | + // We will create a div clone of the textarea |
| 23 | + // by copying these attributes from the textarea to the div. |
| 24 | + var mimics = [ |
| 25 | + 'paddingTop', |
| 26 | + 'paddingRight', |
| 27 | + 'paddingBottom', |
| 28 | + 'paddingLeft', |
| 29 | + 'fontSize', |
| 30 | + 'lineHeight', |
| 31 | + 'fontFamily', |
| 32 | + 'width', |
| 33 | + 'fontWeight', |
| 34 | + 'border-top-width', |
| 35 | + 'border-right-width', |
| 36 | + 'border-bottom-width', |
| 37 | + 'border-left-width', |
| 38 | + 'borderTopStyle', |
| 39 | + 'borderTopColor', |
| 40 | + 'borderRightStyle', |
| 41 | + 'borderRightColor', |
| 42 | + 'borderBottomStyle', |
| 43 | + 'borderBottomColor', |
| 44 | + 'borderLeftStyle', |
| 45 | + 'borderLeftColor' |
| 46 | + ]; |
| 47 | + |
| 48 | + return this.each( function() { |
| 49 | + |
| 50 | + // Elastic only works on textareas |
| 51 | + if ( this.type !== 'textarea' ) { |
| 52 | + return false; |
| 53 | + } |
| 54 | + |
| 55 | + var $textarea = jQuery(this), |
| 56 | + $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}), |
| 57 | + lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), |
| 58 | + minheight = parseInt($textarea.css('height'),10) || lineHeight*3, |
| 59 | + maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, |
| 60 | + goalheight = 0; |
| 61 | + |
| 62 | + // Opera returns max-height of -1 if not set |
| 63 | + if (maxheight < 0) { maxheight = Number.MAX_VALUE; } |
| 64 | + |
| 65 | + // Append the twin to the DOM |
| 66 | + // We are going to meassure the height of this, not the textarea. |
| 67 | + $twin.appendTo($textarea.parent()); |
| 68 | + |
| 69 | + // Copy the essential styles (mimics) from the textarea to the twin |
| 70 | + var i = mimics.length; |
| 71 | + while(i--){ |
| 72 | + $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString())); |
| 73 | + } |
| 74 | + |
| 75 | + // Updates the width of the twin. (solution for textareas with widths in percent) |
| 76 | + function setTwinWidth(){ |
| 77 | + curatedWidth = Math.floor(parseInt($textarea.width(),10)); |
| 78 | + if($twin.width() !== curatedWidth){ |
| 79 | + $twin.css({'width': curatedWidth + 'px'}); |
| 80 | + |
| 81 | + // Update height of textarea |
| 82 | + update(true); |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + // Sets a given height and overflow state on the textarea |
| 87 | + function setHeightAndOverflow(height, overflow){ |
| 88 | + |
| 89 | + var curratedHeight = Math.floor(parseInt(height,10)); |
| 90 | + if($textarea.height() !== curratedHeight){ |
| 91 | + $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); |
| 92 | + |
| 93 | + // Fire the custom event resize |
| 94 | + //$textarea.trigger('resize'); |
| 95 | + |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + // This function will update the height of the textarea if necessary |
| 100 | + function update(forced) { |
| 101 | + |
| 102 | + // Get curated content from the textarea. |
| 103 | + var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ {2}/g, ' ').replace(/<|>/g, '>').replace(/\n/g, '<br />'); |
| 104 | + |
| 105 | + // Compare curated content with curated twin. |
| 106 | + var twinContent = $twin.html().replace(/<br>/ig,'<br />'); |
| 107 | + |
| 108 | + if(forced || textareaContent+' ' !== twinContent){ |
| 109 | + |
| 110 | + // Add an extra white space so new rows are added when you are at the end of a row. |
| 111 | + $twin.html(textareaContent+' '); |
| 112 | + |
| 113 | + // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height |
| 114 | + if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){ |
| 115 | + |
| 116 | + var goalheight = $twin.height()+lineHeight; |
| 117 | + if(goalheight >= maxheight) { |
| 118 | + setHeightAndOverflow(maxheight,'auto'); |
| 119 | + } else if(goalheight <= minheight) { |
| 120 | + setHeightAndOverflow(minheight,'hidden'); |
| 121 | + } else { |
| 122 | + setHeightAndOverflow(goalheight,'hidden'); |
| 123 | + } |
| 124 | + |
| 125 | + } |
| 126 | + |
| 127 | + } |
| 128 | + |
| 129 | + } |
| 130 | + |
| 131 | + // Hide scrollbars |
| 132 | + $textarea.css({'overflow':'hidden'}); |
| 133 | + |
| 134 | + // Update textarea size on keyup, change, cut and paste |
| 135 | + $textarea.bind('keyup change cut paste', function(){ |
| 136 | + update(); |
| 137 | + }); |
| 138 | + |
| 139 | + // Update width of twin if browser or textarea is resized (solution for textareas with widths in percent) |
| 140 | + $(window).bind('resize', setTwinWidth); |
| 141 | + $textarea.bind('resize', setTwinWidth); |
| 142 | + $textarea.bind('update', update); |
| 143 | + |
| 144 | + // Compact textarea on blur |
| 145 | + $textarea.bind('blur',function(){ |
| 146 | + if($twin.height() < maxheight){ |
| 147 | + if($twin.height() > minheight) { |
| 148 | + $textarea.height($twin.height()); |
| 149 | + } else { |
| 150 | + $textarea.height(minheight); |
| 151 | + } |
| 152 | + } |
| 153 | + }); |
| 154 | + |
| 155 | + // And this line is to catch the browser paste event |
| 156 | + $textarea.bind('input paste',function(e){ setTimeout( update, 250); }); |
| 157 | + |
| 158 | + // Run update once when elastic is initialized |
| 159 | + update(); |
| 160 | + |
| 161 | + }); |
| 162 | + |
| 163 | + } |
| 164 | + }); |
| 165 | +})(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css |
— | — | @@ -138,6 +138,11 @@ |
139 | 139 | position: static; |
140 | 140 | } |
141 | 141 | |
| 142 | +.mw-ajax-loader { |
| 143 | + /* Undo padding due to it destroying the layout for inline response */ |
| 144 | + padding:8px 16px 0px 16px !important; |
| 145 | +} |
| 146 | + |
142 | 147 | /* The images here are named -ltr instead of -left and -rtl instead of -right |
143 | 148 | * because ResourceLoader flips -ltr and -rtl in URLs, but not -left and -right |
144 | 149 | */ |
— | — | @@ -179,7 +184,6 @@ |
180 | 185 | position: relative; |
181 | 186 | margin-top:0.5em; |
182 | 187 | margin-bottom:0.5em; |
183 | | - |
184 | 188 | padding:0; |
185 | 189 | } |
186 | 190 | |
— | — | @@ -211,6 +215,45 @@ |
212 | 216 | background-image: url(images/emoticon-sad.png); |
213 | 217 | } |
214 | 218 | |
| 219 | +.fbd-ajax-response { |
| 220 | + padding:1.5em 2em; |
| 221 | +} |
| 222 | + |
| 223 | +.fbd-ajax-response div { |
| 224 | +} |
| 225 | + |
| 226 | +.fbd-item-response-icon { |
| 227 | + float:left; |
| 228 | + display:block; |
| 229 | + height:56px; |
| 230 | + width:56px; |
| 231 | + background-position: center center; |
| 232 | + background-repeat: no-repeat; |
| 233 | + padding:8px 16px; |
| 234 | + position: relative; |
| 235 | + top: -16px; |
| 236 | +} |
| 237 | + |
| 238 | +.fbd-item-response-success { |
| 239 | + background-image: url(images/response-success.png); |
| 240 | + |
| 241 | +} |
| 242 | + |
| 243 | +.fbd-item-response-error { |
| 244 | + background-image: url(images/response-error.png); |
| 245 | +} |
| 246 | + |
| 247 | +.fbd-ajax-response > div > .fbd-ajax-heading { |
| 248 | + font-size:1.5em; |
| 249 | + font-weight:bold; |
| 250 | + display:block; |
| 251 | +} |
| 252 | + |
| 253 | +.fbd-ajax-response > div > .fbd-ajax-text { |
| 254 | + color:#262626; |
| 255 | + display:block; |
| 256 | +} |
| 257 | + |
215 | 258 | .fbd-item-userName { |
216 | 259 | font-size: 1.2em; |
217 | 260 | margin: 0; |
— | — | @@ -233,6 +276,22 @@ |
234 | 277 | min-height:40px; |
235 | 278 | } |
236 | 279 | |
| 280 | +.fbd-response-text { |
| 281 | + height:5em; |
| 282 | + overflow:hidden; |
| 283 | +} |
| 284 | + |
| 285 | +.fbd-response-preview-spinner { |
| 286 | + height:32px; |
| 287 | + line-height:32px; |
| 288 | +} |
| 289 | + |
| 290 | +.fbd-response-wikitext{ |
| 291 | + background-color: #FDFFE7; |
| 292 | + border: 1px solid #FCEB92; |
| 293 | + padding:5px; |
| 294 | +} |
| 295 | + |
237 | 296 | .fbd-item-permalink, |
238 | 297 | .fbd-item-show, |
239 | 298 | .fbd-item-hide, |
— | — | @@ -263,14 +322,14 @@ |
264 | 323 | .fbd-response-form b { |
265 | 324 | font-size:1em; |
266 | 325 | } |
267 | | -.fbd-response-form small{ |
| 326 | +.fbd-response-form small, .fbd-response-form .small{ |
268 | 327 | font-size:0.8em; |
269 | 328 | color:#262626; |
270 | 329 | } |
271 | 330 | .fbd-response-formNote { |
272 | 331 | float:right; |
273 | 332 | } |
274 | | -.fbd-response-submit { |
| 333 | +.fbd-response-submit, .fbd-response-preview { |
275 | 334 | float:right; |
276 | 335 | } |
277 | 336 | .center { |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -404,17 +404,17 @@ |
405 | 405 | |
406 | 406 | //ULA |
407 | 407 | var ula = mw.msg( 'moodbar-response-ula' ) |
408 | | - .replace ( /\$1/, mw.msg( 'moodbar-response-btn') ) |
409 | | - .replace ( /\$2/, termsofuse) |
410 | | - .replace ( /\$3/, creativecommons) |
411 | | - .replace ( /\$4/, gfdl); |
| 408 | + .replace ( /\$1/g, mw.msg( 'moodbar-response-btn') ) |
| 409 | + .replace ( /\$2/g, termsofuse) |
| 410 | + .replace ( /\$3/g, creativecommons) |
| 411 | + .replace ( /\$4/g, gfdl); |
412 | 412 | |
413 | 413 | //build form |
414 | 414 | var inlineForm = $('<div>').attr( 'class', 'fbd-response-form' ) |
415 | 415 | .append( |
416 | 416 | $('<b>').text( mw.msg( 'moodbar-response-add' ) ) |
417 | 417 | ).append( |
418 | | - $('<small>').attr( 'class', 'fbd-text-gray' ).text( ' (' + mw.msg( 'moodbar-response-nosig' ) + ') ' ) |
| 418 | + $('<small>').attr( 'class', 'fbd-text-gray' ).text( ' (' + mw.msg( 'moodbar-response-desc' ) + ') ' ) |
419 | 419 | ).append( |
420 | 420 | $('<div>').attr( 'class', 'fbd-response-formNote' ) |
421 | 421 | .append($('<small>') |
— | — | @@ -427,11 +427,25 @@ |
428 | 428 | ).append( |
429 | 429 | $('<textarea>').attr( { 'class':'fbd-response-text', 'name':'fbd-response-text' } ) |
430 | 430 | ).append( |
431 | | - $('<div>').attr('class', 'ula').html( ula ) |
| 431 | + $('<div />').attr('class', 'fbd-response-preview-spinner') |
| 432 | + .append($('<span />').attr('class', 'mw-ajax-loader') |
| 433 | + //hack the .mw-ajax-loader styles beacuse they are horrible for reuse |
| 434 | + .css({ 'top':'0px','padding':'16px', 'display':'block', 'width':'32px' }).html(' ') |
| 435 | + ).hide() |
432 | 436 | ).append( |
| 437 | + $('<div />').attr('class', 'fbd-response-preview-block') |
| 438 | + .append( |
| 439 | + $('<div />').attr('class', 'fbd-response-wikitext').hide()) |
| 440 | + .append( |
| 441 | + $('<div>').attr('class', 'ula small').html( ula ).hide()) |
| 442 | + ).append( |
433 | 443 | $('<button>').attr( 'class', 'fbd-response-submit' ).text( mw.msg( 'moodbar-response-btn' ) + ' ' + mw.msg( 'moodbar-respond-collapsed' ) ) |
434 | | - .attr({'disabled':'true'}) |
| 444 | + .attr( 'disabled', 'true' ).hide() |
435 | 445 | ).append( |
| 446 | + $('<button>').attr('class', 'fbd-response-preview-back').text( mw.msg( 'response-back-text' ) ).hide() |
| 447 | + ).append( |
| 448 | + $('<button>').attr( 'class', 'fbd-response-preview').text ( mw.msg( 'response-preview-text' ) ).attr( 'disabled', 'true' ) |
| 449 | + ).append( |
436 | 450 | $('<div>').attr( 'style', 'clear:both' ) |
437 | 451 | ); |
438 | 452 | |
— | — | @@ -453,72 +467,71 @@ |
454 | 468 | .keyup( function(event) { |
455 | 469 | validateResponse($item); |
456 | 470 | }) |
| 471 | + .elastic() |
457 | 472 | .end() |
458 | | - .find('.fbd-response-submit') |
| 473 | + .find('.fbd-response-preview') |
459 | 474 | .click (function () { |
460 | | - var fbResponse = $item.find('.fbd-response-text').val(); |
461 | | - if( fbResponse ){ |
462 | | - var clientData = $.client.profile(), |
463 | | - item_id = $item.data('mbccontinue').split('|')[1], |
464 | | - resData = { |
465 | | - 'action':'feedbackdashboardresponse', |
466 | | - 'useragent': clientData.name + '/' + clientData.versionNumber, |
467 | | - 'system': clientData.platform, |
468 | | - 'token': mw.config.get('mbEditToken'), |
469 | | - 'response': fbResponse, |
470 | | - 'feedback': item_id, |
471 | | - 'format':'json' |
472 | | - }; |
473 | | - $item.find('.fbd-item-response').remove(); //remove feedback response link for duration of request |
474 | | - var $spinner = $('<span class="mw-ajax-loader"> </span>'); |
475 | | - $responseForm = $item.find('.fbd-response-form').empty().append( $spinner ); |
476 | | - |
477 | | - //send response |
478 | | - $.ajax( { |
479 | | - 'type': 'POST', |
480 | | - 'url': mw.util.wikiScript( 'api' ), |
481 | | - 'data': resData, |
482 | | - 'success': function (data) { |
483 | | - inlineMessage($responseForm, mw.msg( 'feedbackresponse-success' ), function() { |
484 | | - closeAllResponders(); |
485 | | - reloadItem( $item, true ); |
486 | | - }); |
487 | | - }, |
488 | | - 'error': function( jqXHR, textStatus, errorThrown ) { |
489 | | - //ajax error |
490 | | - inlineMessage($responseForm, mw.msg( 'moodbar-feedback-ajaxerror' ), function() { |
491 | | - closeAllResponders(); |
492 | | - reloadItem( $item, true ); |
493 | | - }); |
494 | | - |
495 | | - }, |
496 | | - 'dataType': 'json' |
497 | | - } ); |
498 | | - |
499 | | - } |
500 | | - }) |
501 | | - .end(); |
| 475 | + //toggle preview |
| 476 | + $item = $(this).parent().parent(); |
| 477 | + $item.find('.fbd-response-preview, .fbd-response-text').hide(); |
| 478 | + $item.find('.fbd-response-submit, .fbd-response-preview-back, .ula').show(); |
| 479 | + var wikitext = $item.find('.fbd-response-text').val(); |
| 480 | + wikitext = wikitext.replace(/~{3,5}/g, '') + "\n\n~~~~"; //remove and add signature for |
| 481 | + parseWikiText($item, wikitext); |
| 482 | + }); |
502 | 483 | } |
503 | 484 | e.preventDefault(); |
504 | | - |
505 | 485 | } |
506 | | - |
| 486 | + |
| 487 | + function parseWikiText($item, wikitext) { |
| 488 | + $item.find('.fbd-response-preview-spinner').show(); |
| 489 | + $.ajax({ |
| 490 | + url: mw.util.wikiScript( 'api' ), |
| 491 | + data: { |
| 492 | + 'action': 'parse', |
| 493 | + 'title': mw.config.get( 'wgPageName' ), |
| 494 | + 'format': 'json', |
| 495 | + 'text': wikitext, |
| 496 | + 'prop': 'text', |
| 497 | + 'pst': true |
| 498 | + }, |
| 499 | + dataType: 'json', |
| 500 | + type: 'POST', |
| 501 | + success: function( data ) { |
| 502 | + $item |
| 503 | + .find('.fbd-response-preview-spinner') //fadeout spinner |
| 504 | + .hide() |
| 505 | + .end() |
| 506 | + .find('.fbd-response-wikitext') |
| 507 | + .html( data.parse.text['*'] ) |
| 508 | + .fadeIn() |
| 509 | + .end(); |
| 510 | + }, |
| 511 | + error: function() { |
| 512 | + //handle error |
| 513 | + //fadeout spinner |
| 514 | + } |
| 515 | + }); |
| 516 | + } |
| 517 | + |
507 | 518 | /** |
508 | | - * Toggle submit button from enabled to disabled |
| 519 | + * Toggle submit / preview button from enabled to disabled |
509 | 520 | * Depends on value of .fbd-response-text |
510 | 521 | * @param $item jQuery item containing the .fbd-item |
| 522 | + * Require at least 1 character and limit to 5000 |
511 | 523 | */ |
512 | 524 | function validateResponse($item) { |
513 | | - if( $item.find('.fbd-response-text').val() !== "" ) { |
514 | | - $item.find( '.fbd-response-submit').removeAttr('disabled'); |
| 525 | + var response = $item.find('.fbd-response-text').val(); |
| 526 | + if( response.length > 0 && response.length <= 5000 ) { |
| 527 | + $item.find( '.fbd-response-submit, .fbd-response-preview').removeAttr('disabled'); |
515 | 528 | } else { |
516 | | - $item.find( '.fbd-response-submit').attr({'disabled':'true'}); |
| 529 | + $item.find( '.fbd-response-submit, .fbd-response-preview').attr({'disabled':'true'}); |
517 | 530 | } |
518 | 531 | } |
519 | 532 | |
520 | 533 | /** |
521 | | - * Send Message to item in regards with response |
522 | | - * @param $el Element to display message inside of and fadeout |
| 534 | + * Generic inline message, with fadeout |
| 535 | + * @param $el Element to display message inside |
523 | 536 | * @param msg text to display |
524 | 537 | * @callback to execute after fadeOut |
525 | 538 | */ |
— | — | @@ -529,7 +542,6 @@ |
530 | 543 | .fadeOut('slow', callback); |
531 | 544 | } |
532 | 545 | |
533 | | - |
534 | 546 | // On-load stuff |
535 | 547 | |
536 | 548 | $('.fbd-item-show a').live( 'click', showHiddenItem ); |
— | — | @@ -540,6 +552,80 @@ |
541 | 553 | |
542 | 554 | $('.fbd-respond-link').live ('click', showResponseForm ); |
543 | 555 | |
| 556 | + //handle preview back button |
| 557 | + $('.fbd-response-preview-back').live('click', function(){ |
| 558 | + $item = $(this).parent().parent(); |
| 559 | + $item.find('.fbd-response-submit, .fbd-response-wikitext, .fbd-response-preview-back, .ula').hide(); |
| 560 | + $item.find('.fbd-response-preview, .fbd-response-text').show(); |
| 561 | + }); |
| 562 | + |
| 563 | + //handle response submit |
| 564 | + $('.fbd-response-submit').live('click', function () { |
| 565 | + $item = $(this).parent().parent(); |
| 566 | + var fbResponse = $item.find('.fbd-response-text').val(); |
| 567 | + if( fbResponse ){ |
| 568 | + var clientData = $.client.profile(), |
| 569 | + item_id = $item.data('mbccontinue').split('|')[1], |
| 570 | + resData = { |
| 571 | + 'action':'feedbackdashboardresponse', |
| 572 | + 'useragent': clientData.name + '/' + clientData.versionNumber, |
| 573 | + 'system': clientData.platform, |
| 574 | + 'token': mw.config.get('mbEditToken'), |
| 575 | + 'response': fbResponse, |
| 576 | + 'feedback': item_id, |
| 577 | + 'format':'json' |
| 578 | + }; |
| 579 | + |
| 580 | + var $responseStatus = $('<div />').attr('class', 'fbd-ajax-response') |
| 581 | + .append($('<span />').attr('class','mw-ajax-loader fbd-item-response-icon').html(' ') ) |
| 582 | + .append($('<div />') |
| 583 | + .append($('<span />').attr('class', 'fbd-ajax-heading').text( mw.msg( 'response-ajax-action-head' ) ) ) |
| 584 | + .append($('<span />').attr('class', 'fbd-ajax-text').text( mw.msg( 'response-ajax-action-body' ) ) ) |
| 585 | + ); |
| 586 | + |
| 587 | + $responseForm = $item.find('.fbd-response-form'); |
| 588 | + $responseForm.empty().append( $responseStatus ); |
| 589 | + |
| 590 | + //send response |
| 591 | + $.ajax( { |
| 592 | + 'type': 'POST', |
| 593 | + 'url': mw.util.wikiScript( 'api' ), |
| 594 | + 'data': resData, |
| 595 | + 'success': function (data) { |
| 596 | + $responseForm |
| 597 | + .find('.mw-ajax-loader') |
| 598 | + .addClass('fbd-item-response-success') |
| 599 | + .removeClass('mw-ajax-loader') |
| 600 | + .end() |
| 601 | + .find('.fbd-ajax-heading') |
| 602 | + .text( mw.msg( 'response-ajax-success-head' ) ) |
| 603 | + .end() |
| 604 | + .find('.fbd-ajax-text') |
| 605 | + .html( mw.msg( 'response-ajax-success-body') ) |
| 606 | + .end(); |
| 607 | + setTimeout(function(){ |
| 608 | + reloadItem($item, true); |
| 609 | + }, 5000); |
| 610 | + |
| 611 | + }, |
| 612 | + 'error': function( jqXHR, textStatus, errorThrown ) { |
| 613 | + $responseForm |
| 614 | + .find('.mw-ajax-loader') |
| 615 | + .addClass('fbd-item-response-error') |
| 616 | + .removeClass('mw-ajax-loader') |
| 617 | + .end() |
| 618 | + .find('.fbd-ajax-heading') |
| 619 | + .text( mw.msg( 'response-ajax-error-head' ) ) |
| 620 | + .end() |
| 621 | + .find('.fbd-ajax-text') |
| 622 | + .html( mw.msg( 'response-ajax-error-body' ) ); |
| 623 | + }, |
| 624 | + 'dataType': 'json' |
| 625 | + } ); |
| 626 | + |
| 627 | + } |
| 628 | + }); |
| 629 | + |
544 | 630 | $( '#fbd-filters' ).children( 'form' ).submit( function( e ) { |
545 | 631 | e.preventDefault(); |
546 | 632 | saveFormState(); |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/images/response-success.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/images/response-success.png |
___________________________________________________________________ |
Added: svn:mime-type |
547 | 633 | + application/octet-stream |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/images/response-error.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/images/response-error.png |
___________________________________________________________________ |
Added: svn:mime-type |
548 | 634 | + application/octet-stream |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -148,7 +148,8 @@ |
149 | 149 | 'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js', |
150 | 150 | 'dependencies' => array( |
151 | 151 | 'mediawiki.util', |
152 | | - 'jquery.NobleCount' |
| 152 | + 'jquery.NobleCount', |
| 153 | + 'jquery.elastic' |
153 | 154 | ), |
154 | 155 | 'messages' => array( |
155 | 156 | 'moodbar-feedback-nomore', |
— | — | @@ -163,7 +164,7 @@ |
164 | 165 | 'moodbar-respond-collapsed', |
165 | 166 | 'moodbar-respond-expanded', |
166 | 167 | 'moodbar-response-add', |
167 | | - 'moodbar-response-nosig', |
| 168 | + 'moodbar-response-desc', |
168 | 169 | 'moodbar-response-btn', |
169 | 170 | 'moodbar-form-note-dynamic', |
170 | 171 | 'moodbar-response-ula', |
— | — | @@ -174,6 +175,15 @@ |
175 | 176 | 'moodbar-response-gfdl', |
176 | 177 | 'moodbar-response-gfdl-link', |
177 | 178 | 'feedbackresponse-success', |
| 179 | + 'response-back-text', |
| 180 | + 'response-preview-text', |
| 181 | + 'response-preview-text', |
| 182 | + 'response-ajax-action-head', |
| 183 | + 'response-ajax-action-body', |
| 184 | + 'response-ajax-success-head', |
| 185 | + 'response-ajax-success-body', |
| 186 | + 'response-ajax-error-head', |
| 187 | + 'response-ajax-error-body', |
178 | 188 | ), |
179 | 189 | ); |
180 | 190 | |
— | — | @@ -188,6 +198,10 @@ |
189 | 199 | ), |
190 | 200 | ); |
191 | 201 | |
| 202 | +$wgResourceModules['jquery.elastic'] = $mbResourceTemplate + array( |
| 203 | + 'scripts' => 'jquery.elastic/jquery.elastic.js' |
| 204 | +); |
| 205 | + |
192 | 206 | /** Configuration **/ |
193 | 207 | /** The registration time after which users will be shown the MoodBar **/ |
194 | 208 | $wgMoodBarCutoffTime = null; |