X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special%2Fmediawiki.special.upload.js;h=f818096377720c9b62e37a17dba52e861f100755;hb=2231d4e859628fc4d2fb63a7a752ead5b91ffef2;hp=49af8090113ed41f71826fcdebe4657105189516;hpb=cc991d3cb0cb17c8532d4970c7f50cb1250c7ebe;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.special/mediawiki.special.upload.js b/resources/src/mediawiki.special/mediawiki.special.upload.js index 49af809011..f818096377 100644 --- a/resources/src/mediawiki.special/mediawiki.special.upload.js +++ b/resources/src/mediawiki.special/mediawiki.special.upload.js @@ -5,8 +5,11 @@ * @class mw.special.upload * @singleton */ + +/* eslint-disable no-use-before-define */ +/* global Uint8Array */ + ( function ( mw, $ ) { - /*jshint latedef:false */ var uploadWarning, uploadLicense, ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ), $license = $( '#wpLicense' ); @@ -80,8 +83,9 @@ } else if ( page.invalidreason ) { resultOut = mw.html.escape( page.invalidreason ); } - $spinnerDestCheck.remove(); uploadWarning.processResult( resultOut, uploadWarning.nameToCheck ); + } ).always( function () { + $spinnerDestCheck.remove(); } ); }, @@ -91,16 +95,19 @@ }, setWarning: function ( warning ) { - var $warning = $( $.parseHTML( warning ) ); + var $warningBox = $( '#wpDestFile-warning' ), + $warning = $( $.parseHTML( warning ) ); mw.hook( 'wikipage.content' ).fire( $warning ); - $( '#wpDestFile-warning' ).empty().append( $warning ); + $warningBox.empty().append( $warning ); // Set a value in the form indicating that the warning is acknowledged and // doesn't need to be redisplayed post-upload if ( !warning ) { $( '#wpDestFileWarningAck' ).val( '' ); + $warningBox.removeAttr( 'class' ); } else { $( '#wpDestFileWarningAck' ).val( '1' ); + $warningBox.attr( 'class', 'mw-destfile-warning' ); } } @@ -130,8 +137,9 @@ prop: 'text', pst: true } ).done( function ( result ) { - $spinnerLicense.remove(); uploadLicense.processResult( result, license ); + } ).always( function () { + $spinnerLicense.remove(); } ); }, @@ -261,6 +269,8 @@ $( function () { /** * Is the FileAPI available with sufficient functionality? + * + * @return {boolean} */ function hasFileAPI() { return window.FileReader !== undefined; @@ -416,9 +426,8 @@ }, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) { try { meta = mw.libs.jpegmeta( data, file.fileName ); - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers, disallowDanglingUnderscores + // eslint-disable-next-line no-underscore-dangle, camelcase meta._binary_data = null; - // jscs:enable } catch ( e ) { meta = null; } @@ -494,6 +503,9 @@ /** * Check if the file does not exceed the maximum size + * + * @param {File} file + * @return {boolean} */ function checkMaxUploadSize( file ) { var maxSize, $error; @@ -526,10 +538,11 @@ if ( hasFileAPI() ) { // Update thumbnail when the file selection control is updated. $( '#wpUploadFile' ).change( function () { + var file; clearPreview(); if ( this.files && this.files.length ) { // Note: would need to be updated to handle multiple files. - var file = this.files[ 0 ]; + file = this.files[ 0 ]; if ( !checkMaxUploadSize( file ) ) { return;