r84473 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84472‎ | r84473 | r84474 >
Date:18:52, 21 March 2011
Author:kaldari
Status:deferred
Tags:
Comment:
making title field required
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.DestinationChecker.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.DestinationChecker.js
@@ -104,10 +104,11 @@
105105 */
106106 checkUnique: function() {
107107 var _this = this;
108 -
109108 var found = false;
110 - // XXX if input is empty don't bother? but preprocess gives us File:.png...
111109 var title = _this.getTitle();
 110+
 111+ // if input is empty don't bother.
 112+ if ( title == '' ) return;
112113
113114 if ( _this.cachedResult[name] !== undefined ) {
114115 _this.processResult( _this.cachedResult[name] );
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -54,13 +54,17 @@
5555 api: _this.upload.api,
5656 spinner: function(bool) { _this.toggleDestinationBusy(bool); },
5757 preprocess: function( name ) {
58 - // turn the contents of the input into a MediaWiki title ("File:foo_bar.jpg") to look up
59 - return _this.upload.title.setNameText( name ).toString();
 58+ if ( name != '' ) {
 59+ // turn the contents of the input into a MediaWiki title ("File:foo_bar.jpg") to look up
 60+ return _this.upload.title.setNameText( name ).toString();
 61+ } else {
 62+ return name;
 63+ }
6064 },
6165 processResult: function( result ) { _this.processDestinationCheck( result ); }
6266 } );
6367
64 - _this.titleErrorDiv = $j('<div class="mwe-upwiz-details-input-error"><label class="mwe-error" for="' + _this.titleId + '" generated="true"/></div>');
 68+ _this.titleErrorDiv = $j('<div class="mwe-upwiz-details-input-error"><label class="mwe-validator-error" for="' + _this.titleId + '" generated="true"/></div>');
6569
6670 var titleHintId = 'mwe-upwiz-title-hint-' + _this.upload.index;
6771 var $titleDialog = $('<div>')
@@ -221,6 +225,15 @@
222226 _this.addDescription( true, mw.config.get( 'wgUserLanguage' ) );
223227 $j( containerDiv ).append( _this.div );
224228
 229+ // make the title field required
 230+ _this.$form.find( '.mwe-title' )
 231+ .rules( "add", {
 232+ required: true,
 233+ messages: {
 234+ required: gM( 'mwe-upwiz-error-blank' )
 235+ }
 236+ } );
 237+
225238 // make this a category picker
226239 var hiddenCats = [];
227240 if ( mw.isDefined( mw.UploadWizard.config.autoCategory ) ) {
@@ -305,7 +318,6 @@
306319 */
307320 processDestinationCheck: function( result ) {
308321 var _this = this;
309 -
310322 if ( result.isUnique ) {
311323 $j( _this.titleInput ).data( 'valid', true );
312324 _this.$form.find( 'label[for=' + _this.titleId + ']' ).hide().empty();

Status & tagging log