User:MarkTraceur/commonsUploadDialog.js

( function ( mw ) {	var uds = importScript( 'User:MarkTraceur/uploadDialog.js' ),		cus = importScript( 'User:MarkTraceur/commonsUpload.js' ),		udp = $.Deferred,		cup = $.Deferred;

uds.addEventListener( 'load', function {		mw.uploadDialogPromise.then( udp.resolve, udp.reject );	} );

cus.addEventListener( 'load', function {		mw.commonsUploadPromise.then( cup.resolve, cup.reject );	} );

mw.commonsUploadDialogPromise = $.when( mw.loader.using( [ 'oojs-ui' ] ), udp, cup ).then( function {		mw.CommonsUploadDialog = function ( config ) {			mw.CommonsUploadDialog.parent.call( this, config );		};

OO.inheritClass( mw.CommonsUploadDialog, mw.UploadDialog );

mw.CommonsUploadDialog.prototype.getFields = function { var fields = mw.CommonsUploadDialog.parent.prototype.getFields.call( this );

this.descriptionWidget = new OO.ui.TextInputWidget( {				multiline: true			} );

this.descriptionField = new OO.ui.FieldLayout( this.descriptionWidget, {				label: 'Description'			} );

this.dateWidget = new OO.ui.TextInputWidget( {} );

this.dateField = new OO.ui.FieldLayout( this.dateWidget, {				label: 'Date created'			} );

fields.push( this.descriptionField ); fields.push( this.dateField );

return fields; };

mw.CommonsUploadDialog.prototype.getUploadObject = function { return new mw.CommonsUpload; };

mw.CommonsUploadDialog.prototype.finalizeUpload = function { mw.CommonsUploadDialog.parent.prototype.finalizeUpload.call( this ); this.upload.addDescription( 'en', this.descriptionWidget.getValue ); this.upload.setDate( this.dateWidget.getValue ); };	} ); }( mediaWiki ) );