* @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' );
},
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' );
}
}
$( function () {
/**
* Is the FileAPI available with sufficient functionality?
+ *
+ * @return {boolean}
*/
function hasFileAPI() {
return window.FileReader !== undefined;
}, 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;
}
/**
* Check if the file does not exceed the maximum size
+ *
+ * @param {File} file
+ * @return {boolean}
*/
function checkMaxUploadSize( file ) {
var maxSize, $error;
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;