Merge "docs: Add examples for mw.Upload"

This commit is contained in:
jenkins-bot 2015-08-05 16:04:16 +00:00 committed by Gerrit Code Review
commit d4111ed30d

View file

@ -9,6 +9,40 @@
* but this model class will tie it together as well as let you perform
* actions in a logical way.
*
* A simple example:
*
* var file = new OO.ui.SelectFileWidget(),
* button = new OO.ui.ButtonWidget( { label: 'Save' } ),
* upload = new mw.Upload;
*
* button.on( 'click', function () {
* upload.setFile( file.getValue() );
* upload.setFilename( file.getValue().name );
* upload.upload();
* } );
*
* $( 'body' ).append( file.$element, button.$element );
*
* You can also choose to {@link #uploadToStash stash the upload} and
* {@link #finishStashUpload finalize} it later:
*
* var file, // Some file object
* upload = new mw.Upload,
* stashPromise = $.Deferred();
*
* upload.setFile( file );
* upload.uploadToStash().then( function () {
* stashPromise.resolve();
* } );
*
* stashPromise.then( function () {
* upload.setFilename( 'foo' );
* upload.setText( 'bar' );
* upload.finishStashUpload().then( function () {
* console.log( 'Done!' );
* } );
* } );
*
* @constructor
* @param {Object} apiconfig Passed to the constructor of mw.Api.
*/