Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -130,6 +130,16 @@ |
131 | 131 | $( '#mw-wikilove-preview-form' ).submit( $.wikiLove.validatePreviewForm ); |
132 | 132 | $( '#mw-wikilove-send-form' ).click( $.wikiLove.submitSend ); |
133 | 133 | $( '#mw-wikilove-message' ).elastic(); // have the message textarea grow automatically |
| 134 | + |
| 135 | + // when the input changes, we want to disable the send button |
| 136 | + $( '#mw-wikilove-header' ).change( $.wikiLove.changeInput ); |
| 137 | + $( '#mw-wikilove-header' ).keyup( $.wikiLove.changeInput ); |
| 138 | + $( '#mw-wikilove-title' ).change( $.wikiLove.changeInput ); |
| 139 | + $( '#mw-wikilove-title' ).keyup( $.wikiLove.changeInput ); |
| 140 | + $( '#mw-wikilove-image' ).change( $.wikiLove.changeInput ); |
| 141 | + $( '#mw-wikilove-image' ).keyup( $.wikiLove.changeInput ); |
| 142 | + $( '#mw-wikilove-message' ).change( $.wikiLove.changeInput ); |
| 143 | + $( '#mw-wikilove-message' ).keyup( $.wikiLove.changeInput ); |
134 | 144 | } |
135 | 145 | |
136 | 146 | $dialog.dialog( 'open' ); |
— | — | @@ -350,6 +360,8 @@ |
351 | 361 | 'header': $( '#mw-wikilove-header' ).val(), |
352 | 362 | 'text': text, |
353 | 363 | 'message': $( '#mw-wikilove-message' ).val(), |
| 364 | + 'title': $( '#mw-wikilove-title' ).val(), |
| 365 | + 'image': $( '#mw-wikilove-image' ).val(), |
354 | 366 | 'type': currentTypeId |
355 | 367 | + (currentSubtypeId !== null ? '-' + currentSubtypeId : '') |
356 | 368 | }; |
— | — | @@ -423,21 +435,41 @@ |
424 | 436 | |
425 | 437 | /* |
426 | 438 | * Callback for the preview function. Sets the preview area with the HTML and fades it in. |
| 439 | + * It also (re-)enables the send button. |
427 | 440 | */ |
428 | 441 | showPreview: function( html ) { |
429 | 442 | $( '#mw-wikilove-preview-area' ).html( html ); |
430 | 443 | $( '#mw-wikilove-preview' ).fadeIn( 200 ); |
| 444 | + $( '#mw-wikilove-button-send' ).button( 'enable' ); |
431 | 445 | }, |
432 | 446 | |
| 447 | + changeInput: function() { |
| 448 | + if( previewData !== null && |
| 449 | + ( previewData.message != $( '#mw-wikilove-message' ).val() |
| 450 | + || previewData.title != $( '#mw-wikilove-title' ).val() |
| 451 | + || previewData.header != $( '#mw-wikilove-header' ).val() |
| 452 | + || previewData.image != $( '#mw-wikilove-image' ).val() |
| 453 | + )) { |
| 454 | + $( '#mw-wikilove-button-send' ).button( 'disable' ); |
| 455 | + } |
| 456 | + else { |
| 457 | + $( '#mw-wikilove-button-send' ).button( 'enable' ); |
| 458 | + } |
| 459 | + }, |
| 460 | + |
433 | 461 | /* |
434 | 462 | * Handler for the send (final submit) button. |
435 | 463 | * The type sent for statistics is 'typeId-subtypeId' when using subtypes, |
436 | 464 | * or simply 'typeId' otherwise. |
437 | 465 | */ |
438 | 466 | submitSend: function( e ) { |
439 | | - e.preventDefault(); |
440 | | - $.wikiLove.doSend( previewData.header, previewData.text, |
441 | | - previewData.message, previewData.type, previewData.email ); |
| 467 | + $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove(); |
| 468 | + |
| 469 | + if( !$( '#mw-wikilove-button-send' ).button( 'option', 'disabled' ) ) { |
| 470 | + e.preventDefault(); |
| 471 | + $.wikiLove.doSend( previewData.header, previewData.text, |
| 472 | + previewData.message, previewData.type, previewData.email ); |
| 473 | + } |
442 | 474 | }, |
443 | 475 | |
444 | 476 | /* |
— | — | @@ -565,6 +597,7 @@ |
566 | 598 | $( '#mw-wikilove-gallery a' ).removeClass( 'selected' ); |
567 | 599 | $( this ).addClass( 'selected' ); |
568 | 600 | $( '#mw-wikilove-image' ).val( gallery[$( this ).attr( 'id' )] ); |
| 601 | + $.wikiLove.changeInput(); |
569 | 602 | }) |
570 | 603 | ); |
571 | 604 | gallery['mw-wikilove-gallery-img-' + index] = page.title; |