Merge "docs: Add examples for mw.Upload"
This commit is contained in:
commit
d4111ed30d
1 changed files with 34 additions and 0 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue