http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91046

Revision: 91046
Author:   kaldari
Date:     2011-06-29 02:15:35 +0000 (Wed, 29 Jun 2011)
Log Message:
-----------
adding a couple more validators to submitSend since we are doing just-in-time 
now - extra safe

Modified Paths:
--------------
    trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js

Modified: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
===================================================================
--- trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-06-29 02:01:06 UTC (rev 91045)
+++ trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-06-29 02:15:35 UTC (rev 91046)
@@ -489,17 +489,34 @@
        },
        
        /*
-        * Handler for the send (final submit) button.
+        * Handler for the send (final submit) button. Builds the data for the 
AJAX request.
         * The type sent for statistics is 'typeId-subtypeId' when using 
subtypes,
         * or simply 'typeId' otherwise.
         */
        submitSend: function( e ) {
                e.preventDefault();
                $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' 
).remove();
+               
                // Check for a header if it is required
                if( $.inArray( 'header', currentTypeOrSubtype.fields ) >= 0 && 
$( '#mw-wikilove-header' ).val().length <= 0 ) {
                        $.wikiLove.showAddDetailsError( 'wikilove-err-header' 
); return false;
                }
+               
+               // Check for a title if it is required, and otherwise use the 
header text
+               if( $.inArray( 'title', currentTypeOrSubtype.fields ) >= 0 && 
$( '#mw-wikilove-title' ).val().length <= 0 ) {
+                       $( '#mw-wikilove-title' ).val( $( '#mw-wikilove-header' 
).val() );
+               }
+               
+               if( $.inArray( 'message', currentTypeOrSubtype.fields ) >= 0 ) {
+                       // If there's a signature already in the message, throw 
an error
+                       if ( $( '#mw-wikilove-message' ).val().indexOf( '~~~' ) 
>= 0 ) {
+                               $.wikiLove.showAddDetailsError( 
'wikilove-err-sig' ); return false;
+                       }
+               }
+               
+               // We don't need to do any image validation here since its not 
actually possible to click 
+               // Send WikiLove without having a valid image entered.
+               
                var submitData = {
                        'header': $( '#mw-wikilove-header' ).val(),
                        'text': $.wikiLove.prepareMsg( 
currentTypeOrSubtype.text || options.defaultText ),


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to