' + mw.message( 'largefileserver', file.size, maxSize ).escaped() + '
' ); $( '#wpUploadFile' ).after( $error ); return false; } return true; } /** * Initialization */ if ( hasFileAPI() ) { // Update thumbnail when the file selection control is updated. $( '#wpUploadFile' ).change( function () { clearPreview(); if ( this.files && this.files.length ) { // Note: would need to be updated to handle multiple files. var file = this.files[0]; if ( !checkMaxUploadSize( file ) ) { return; } if ( fileIsPreviewable( file ) ) { showPreview( file ); } } } ); } } ); /** * Disable all upload source fields except the selected one */ $( function () { var i, $row, $rows = $( '.mw-htmlform-field-UploadSourceField' ); function createHandler( $currentRow ) { /** * @param {jQuery.Event} */ return function () { $( '.mw-upload-source-error' ).remove(); if ( this.checked ) { // Disable all inputs $rows.find( 'input[name!="wpSourceType"]' ).prop( 'disabled', true ); // Re-enable the current one $currentRow.find( 'input' ).prop( 'disabled', false ); } }; } for ( i = $rows.length; i; i-- ) { $row = $rows.eq(i - 1); $row .find( 'input[name="wpSourceType"]' ) .change( createHandler( $row ) ); } } ); }( mediaWiki, jQuery ) );