Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -489,17 +489,34 @@ |
490 | 490 | }, |
491 | 491 | |
492 | 492 | /* |
493 | | - * Handler for the send (final submit) button. |
| 493 | + * Handler for the send (final submit) button. Builds the data for the AJAX request. |
494 | 494 | * The type sent for statistics is 'typeId-subtypeId' when using subtypes, |
495 | 495 | * or simply 'typeId' otherwise. |
496 | 496 | */ |
497 | 497 | submitSend: function( e ) { |
498 | 498 | e.preventDefault(); |
499 | 499 | $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove(); |
| 500 | + |
500 | 501 | // Check for a header if it is required |
501 | 502 | if( $.inArray( 'header', currentTypeOrSubtype.fields ) >= 0 && $( '#mw-wikilove-header' ).val().length <= 0 ) { |
502 | 503 | $.wikiLove.showAddDetailsError( 'wikilove-err-header' ); return false; |
503 | 504 | } |
| 505 | + |
| 506 | + // Check for a title if it is required, and otherwise use the header text |
| 507 | + if( $.inArray( 'title', currentTypeOrSubtype.fields ) >= 0 && $( '#mw-wikilove-title' ).val().length <= 0 ) { |
| 508 | + $( '#mw-wikilove-title' ).val( $( '#mw-wikilove-header' ).val() ); |
| 509 | + } |
| 510 | + |
| 511 | + if( $.inArray( 'message', currentTypeOrSubtype.fields ) >= 0 ) { |
| 512 | + // If there's a signature already in the message, throw an error |
| 513 | + if ( $( '#mw-wikilove-message' ).val().indexOf( '~~~' ) >= 0 ) { |
| 514 | + $.wikiLove.showAddDetailsError( 'wikilove-err-sig' ); return false; |
| 515 | + } |
| 516 | + } |
| 517 | + |
| 518 | + // We don't need to do any image validation here since its not actually possible to click |
| 519 | + // Send WikiLove without having a valid image entered. |
| 520 | + |
504 | 521 | var submitData = { |
505 | 522 | 'header': $( '#mw-wikilove-header' ).val(), |
506 | 523 | 'text': $.wikiLove.prepareMsg( currentTypeOrSubtype.text || options.defaultText ), |