r67323 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67322‎ | r67323 | r67324 >
Date:03:05, 4 June 2010
Author:neilk
Status:deferred
Tags:
Comment:
third party deed validation (needs css work)
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardPage.js (modified) (history)
  • /trunk/extensions/UploadWizard/js/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/styles/uploadWizard.css (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/styles/uploadWizard.css
@@ -469,13 +469,18 @@
470470 visibility: hidden !important;
471471 }
472472
 473+.mwe-upwiz-thirdparty-fields {
 474+ margin-bottom: 5px;
 475+}
 476+
473477 .mwe-upwiz-thirdparty-fields label {
474478 width: 100px;
475479 display: inline-block;
 480+ padding-bottom: 5px;
476481 }
477482
478483 .mwe-upwiz-thirdparty-fields textarea {
479 - margin: 5px 0px -3px 5px;
 484+ margin: 0px
480485 }
481486
482487 .mwe-upwiz-thirdparty-license {
@@ -525,7 +530,11 @@
526531 color: #ff0000;
527532 }
528533
529 -input[type='text'].mwe-error {
 534+.mwe-upwiz-deed-form-internal label.mwe-error {
 535+ margin-left: 100px;
 536+}
 537+
 538+input[type='text'].mwe-error, textarea.mwe-error {
530539 color: black;
531540 border: 1px solid #ff0000;
532541 }
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -112,11 +112,14 @@
113113 'mwe-upwiz-license-incompatible-cc' => 'You can only choose one kind of Creative Commons license.',
114114 'mwe-upwiz-license-show-all' => 'Use a different license',
115115 'mwe-upwiz-license-show-recommended' => 'Use the recommended license',
116 - 'mwe-upwiz-error-author-blank' => 'You must sign the field below with your username or real name.',
117 - 'mwe-upwiz-error-author-too-long' => 'Your signature is too long. Make it shorter than $1 {{PLURAL:$1|character|characters}}.',
118 - 'mwe-upwiz-error-author-too-short' => 'Your signature is too short. Make it longer than $1 {{PLURAL:$1|character|characters}}.',
119 - 'mwe-upwiz-error-author-bad-chars' => 'Your signature contains symbols that aren\'t allowed. Please don\'t use wikitext or HTML here, just your username or real name.',
120 -
 116+ 'mwe-upwiz-error-signature-blank' => 'You must sign the field below with your username or real name.',
 117+ 'mwe-upwiz-error-signature-too-long' => 'Your signature is too long. Make it shorter than $1 {{PLURAL:$1|character|characters}}.',
 118+ 'mwe-upwiz-error-signature-too-short' => 'Your signature is too short. Make it longer than $1 {{PLURAL:$1|character|characters}}.',
 119+ 'mwe-upwiz-error-signature-bad-chars' => 'Your signature contains symbols that aren\'t allowed. Please don\'t use wikitext or HTML here, just your username or real name.',
 120+ 'mwe-upwiz-error-blank' => 'This field is required.',
 121+ 'mwe-upwiz-error-too-long' => 'This field is too long. Make it shorter than $1 {{PLURAL:$1|character|characters}}.',
 122+ 'mwe-upwiz-error-too-short' => 'This field is too short. Make it longer than $1 {{PLURAL:$1|character|characters}}.',
 123+ 'mwe-upwiz-error-bad-chars' => 'This field contains symbols that aren\'t allowed. Please don\'t use wikitext or HTML here, just your username or real name.'
121124 );
122125
123126 /** Message documentation (Message documentation)
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js
@@ -8,7 +8,8 @@
99 * General configuration for the validator
1010 */
1111 $j.validator.setDefaults( {
12 - debug: true
 12+ debug: true,
 13+ errorClass: 'mwe-error'
1314 } );
1415
1516
@@ -2485,10 +2486,7 @@
24862487 * @return boolean true if valid, false if not
24872488 */
24882489 valid: function() {
2489 - // we don't need to validate source because it's set by default
2490 - var authorValid = _this.$form.valid();
2491 - var licenseValid = _this.licenseInput.valid();
2492 - return authorValid & licenseValid;
 2490+ return _this.$form.valid() && _this.licenseInput.valid();
24932491 },
24942492
24952493 getSourceWikiText: function() {
@@ -2590,8 +2588,6 @@
25912589
25922590 // and finally, make it validatable
25932591 _this.formValidator = _this.$form.validate( {
2594 - debug: true,
2595 - errorClass: 'mwe-error', // add to general config?
25962592 rules: {
25972593 author2: {
25982594 required: function( element ) {
@@ -2610,14 +2606,14 @@
26112607 },
26122608 messages: {
26132609 author2: {
2614 - required: gM( 'mwe-upwiz-error-author-blank' ),
2615 - minlength: gM( 'mwe-upwiz-error-author-too-long', mw.getConfig( 'minAuthorLength' ) ),
2616 - maxlength: gM( 'mwe-upwiz-error-author-too-long', mw.getConfig( 'maxAuthorLength' ) )
 2610+ required: gM( 'mwe-upwiz-error-signature-blank' ),
 2611+ minlength: gM( 'mwe-upwiz-error-signature-too-short', mw.getConfig( 'minAuthorLength' ) ),
 2612+ maxlength: gM( 'mwe-upwiz-error-signature-too-long', mw.getConfig( 'maxAuthorLength' ) )
26172613 },
26182614 author: {
2619 - required: gM( 'mwe-upwiz-error-author-blank' ),
2620 - minlength: gM( 'mwe-upwiz-error-author-too-long', mw.getConfig( 'minAuthorLength' ) ),
2621 - maxlength: gM( 'mwe-upwiz-error-author-too-long', mw.getConfig( 'maxAuthorLength' ) )
 2615+ required: gM( 'mwe-upwiz-error-signature-blank' ),
 2616+ minlength: gM( 'mwe-upwiz-error-signature-too-short', mw.getConfig( 'minAuthorLength' ) ),
 2617+ maxlength: gM( 'mwe-upwiz-error-signature-too-long', mw.getConfig( 'maxAuthorLength' ) )
26222618 }
26232619 }
26242620 } );
@@ -2650,6 +2646,9 @@
26512647 name: 'thirdparty',
26522648
26532649 setFormFields: function( $selector ) {
 2650+ var _this = this;
 2651+ _this.$form = $j( '<form/>' );
 2652+
26542653 var $formFields = $j( '<div class="mwe-upwiz-deed-form-internal"/>' );
26552654
26562655 if ( uploadCount > 1 ) {
@@ -2658,9 +2657,11 @@
26592658
26602659 $formFields.append (
26612660 $j( '<div class="mwe-upwiz-source-thirdparty-custom-multiple-intro" />' ),
 2661+ $j( '<label for="source" generated="true" class="mwe-error" style="display:block;"/>' ),
26622662 $j( '<div class="mwe-upwiz-thirdparty-fields" />' )
26632663 .append( $j( '<label for="source"/>' ).text( gM( 'mwe-upwiz-source' ) ),
26642664 _this.sourceInput ),
 2665+ $j( '<label for="author" generated="true" class="mwe-error" style="display:block;"/>' ),
26652666 $j( '<div class="mwe-upwiz-thirdparty-fields" />' )
26662667 .append( $j( '<label for="author"/>' ).text( gM( 'mwe-upwiz-author' ) ),
26672668 _this.authorInput ),
@@ -2669,13 +2670,36 @@
26702671 licenseInputDiv
26712672 );
26722673
2673 - $selector.append( $formFields );
 2674+ _this.$form.validate( {
 2675+ rules: {
 2676+ source: { required: true,
 2677+ minlength: mw.getConfig( 'minSourceLength' ),
 2678+ maxlength: mw.getConfig( 'maxSourceLength' ) },
 2679+ author: { required: true,
 2680+ minlength: mw.getConfig( 'minAuthorLength' ),
 2681+ maxlength: mw.getConfig( 'maxAuthorLength' ) },
 2682+ },
 2683+ messages: {
 2684+ source: {
 2685+ required: gM( 'mwe-upwiz-error-blank' ),
 2686+ minlength: gM( 'mwe-upwiz-error-too-short', mw.getConfig( 'minSourceLength' ) ),
 2687+ maxlength: gM( 'mwe-upwiz-error-too-long', mw.getConfig( 'maxSourceLength' ) )
 2688+ },
 2689+ author: {
 2690+ required: gM( 'mwe-upwiz-error-blank' ),
 2691+ minlength: gM( 'mwe-upwiz-error-too-short', mw.getConfig( 'minAuthorLength' ) ),
 2692+ maxlength: gM( 'mwe-upwiz-error-too-long', mw.getConfig( 'maxAuthorLength' ) )
 2693+ }
 2694+ }
 2695+ } );
 2696+
 2697+ _this.$form.append( $formFields );
 2698+
 2699+ $selector.append( _this.$form );
26742700 },
26752701
26762702 valid: function() {
2677 - return (! mw.isEmpty( $j( this.sourceInput ).val() ) )
2678 - && (! mw.isEmpty( $j( this.authorInput ).val() ) )
2679 - && this.licenseInput.isSet()
 2703+ return this.$form.valid() & this.licenseInput.valid();
26802704 }
26812705 } );
26822706 }
Index: trunk/extensions/UploadWizard/UploadWizardPage.js
@@ -24,6 +24,8 @@
2525 smallThumbnailWidth: 60,
2626 maxAuthorLength: 50,
2727 minAuthorLength: 2,
 28+ maxSourceLength: 200,
 29+ minSourceLength: 5,
2830
2931 // not for use with all wikis.
3032 // The ISO 639 code for the language tagalog is "tl".

Status & tagging log