/**
* Provides an interface for uploading files to MediaWiki.
+ *
* @class mw.Api.plugin.upload
* @singleton
*/
/**
* @private
* Get nonce for iframe IDs on the page.
+ *
* @return {number}
*/
function getNonce() {
/**
* @private
* Get new iframe object for an upload.
+ *
* @return {HTMLIframeElement}
*/
function getNewIframe( id ) {
/**
* @private
* Shortcut for getting hidden inputs
+ *
* @return {jQuery}
*/
function getHiddenInput( name, val ) {
- return $( '<input type="hidden" />')
+ return $( '<input type="hidden" />' )
.attr( 'name', name )
.val( val );
}
*/
function processIframeResult( iframe ) {
var json,
- doc = iframe.contentDocument || frames[iframe.id].document;
+ doc = iframe.contentDocument || frames[ iframe.id ].document;
if ( doc.XMLDocument ) {
// The response is a document property in IE
isFileInput = file && file.nodeType === Node.ELEMENT_NODE;
if ( formDataAvailable() && isFileInput && file.files ) {
- file = file.files[0];
+ file = file.files[ 0 ];
}
if ( !file ) {
$iframe = $( iframe );
for ( key in data ) {
- if ( !fieldsAllowed[key] ) {
- delete data[key];
+ if ( !fieldsAllowed[ key ] ) {
+ delete data[ key ];
}
}
deferred = $.Deferred();
for ( key in data ) {
- if ( !fieldsAllowed[key] ) {
- delete data[key];
+ if ( !fieldsAllowed[ key ] ) {
+ delete data[ key ];
}
}
* This function will return a promise, which when resolved, will pass back a function
* to finish the stash upload. You can call that function with an argument containing
* more, or conflicting, data to pass to the server. For example:
+ *
* // upload a file to the stash with a placeholder filename
* api.uploadToStash( file, { filename: 'testing.png' } ).done( function ( finish ) {
* // finish is now the function we can use to finalize the upload
* // the upload is complete, data holds the API response
* } );
* } );
+ *
* @param {File|HTMLInputElement} file
* @param {Object} [data]
* @return {jQuery.Promise}