delay: 500, // ms
timeoutID: false,
- keypress: function () {
- if ( !ajaxUploadDestCheck ) {
- return;
- }
-
- // Find file to upload
- if ( !$( '#wpDestFile' ).length || !$( '#wpDestFile-warning' ).length ) {
- return;
- }
-
- this.nameToCheck = $( '#wpDestFile' ).val();
-
- // Clear timer
- if ( this.timeoutID ) {
- clearTimeout( this.timeoutID );
- }
- // Check response cache
- if ( Object.prototype.hasOwnProperty.call( this.responseCache, this.nameToCheck ) ) {
- this.setWarning( this.responseCache[ this.nameToCheck ] );
- return;
- }
-
- this.timeoutID = setTimeout( function () {
- uploadWarning.timeout();
- }, this.delay );
- },
-
checkNow: function ( fname ) {
if ( !ajaxUploadDestCheck ) {
return;
if ( ajaxUploadDestCheck ) {
// Insert an event handler that fetches upload warnings when wpDestFile
// has been changed
- $( '#wpDestFile' ).change( function () {
+ $( '#wpDestFile' ).on( 'change', function () {
uploadWarning.checkNow( $( this ).val() );
} );
// Insert a row where the warnings will be displayed just below the
if ( mw.config.get( 'wgAjaxLicensePreview' ) && $license.length ) {
// License selector check
- $license.change( function () {
+ $license.on( 'change', function () {
// We might show a preview
uploadTemplatePreview.getPreview( $license, $( '#mw-license-preview' ) );
} );
// fillDestFile setup
mw.config.get( 'wgUploadSourceIds' ).forEach( function ( sourceId ) {
- $( '#' + sourceId ).change( function () {
+ $( '#' + sourceId ).on( 'change', function () {
var path, slash, backslash, fname;
if ( !mw.config.get( 'wgUploadAutoFill' ) ) {
return;
};
img.src = dataURL;
}, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) {
- var jpegmeta = mw.loader.require( 'mediawiki.libs.jpegmeta' );
+ var jpegmeta = require( 'mediawiki.libs.jpegmeta' );
try {
meta = jpegmeta( data, file.fileName );
// eslint-disable-next-line no-underscore-dangle, camelcase
/* Initialization */
if ( hasFileAPI() ) {
// Update thumbnail when the file selection control is updated.
- $( '#wpUploadFile' ).change( function () {
+ $( '#wpUploadFile' ).on( 'change', function () {
var file;
clearPreview();
if ( this.files && this.files.length ) {
namespace: 'uploadwarning'
} );
- $uploadForm.submit( function () {
+ $uploadForm.on( 'submit', function () {
allowCloseWindow.release();
} );
} );
// Change tabindex only when main div has focus
if ( $( this ).is( ':focus' ) ) {
- $( this ).find( 'a' ).first().focus();
+ $( this ).find( 'a' ).first().trigger( 'focus' );
setEditTabindex( '0' );
}
} );