wp/wp-includes/js/plupload/wp-plupload.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    68 		 */
    68 		 */
    69 		$.extend( true, this, options );
    69 		$.extend( true, this, options );
    70 
    70 
    71 		// Proxy all methods so this always refers to the current instance.
    71 		// Proxy all methods so this always refers to the current instance.
    72 		for ( key in this ) {
    72 		for ( key in this ) {
    73 			if ( $.isFunction( this[ key ] ) ) {
    73 			if ( typeof this[ key ] === 'function' ) {
    74 				this[ key ] = $.proxy( this[ key ], this );
    74 				this[ key ] = $.proxy( this[ key ], this );
    75 			}
    75 			}
    76 		}
    76 		}
    77 
    77 
    78 		// Ensure all elements are jQuery elements and have id attributes,
    78 		// Ensure all elements are jQuery elements and have id attributes,
   282 			if ( ! dragdrop ) {
   282 			if ( ! dragdrop ) {
   283 				return dropzone.unbind('.wp-uploader');
   283 				return dropzone.unbind('.wp-uploader');
   284 			}
   284 			}
   285 
   285 
   286 			// 'dragenter' doesn't fire correctly, simulate it with a limited 'dragover'.
   286 			// 'dragenter' doesn't fire correctly, simulate it with a limited 'dragover'.
   287 			dropzone.bind( 'dragover.wp-uploader', function() {
   287 			dropzone.on( 'dragover.wp-uploader', function() {
   288 				if ( timer ) {
   288 				if ( timer ) {
   289 					clearTimeout( timer );
   289 					clearTimeout( timer );
   290 				}
   290 				}
   291 
   291 
   292 				if ( active ) {
   292 				if ( active ) {
   295 
   295 
   296 				dropzone.trigger('dropzone:enter').addClass('drag-over');
   296 				dropzone.trigger('dropzone:enter').addClass('drag-over');
   297 				active = true;
   297 				active = true;
   298 			});
   298 			});
   299 
   299 
   300 			dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() {
   300 			dropzone.on('dragleave.wp-uploader, drop.wp-uploader', function() {
   301 				/*
   301 				/*
   302 				 * Using an instant timer prevents the drag-over class
   302 				 * Using an instant timer prevents the drag-over class
   303 				 * from being quickly removed and re-added when elements
   303 				 * from being quickly removed and re-added when elements
   304 				 * inside the dropzone are repositioned.
   304 				 * inside the dropzone are repositioned.
   305 				 *
   305 				 *
   356 					Uploader.errors.unshift({
   356 					Uploader.errors.unshift({
   357 						message: pluploadL10n.unsupported_image,
   357 						message: pluploadL10n.unsupported_image,
   358 						data:    {},
   358 						data:    {},
   359 						file:    file
   359 						file:    file
   360 					});
   360 					});
       
   361 				} else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
       
   362 					// Disallow uploading of WebP images if the server cannot edit them.
       
   363 					error( pluploadL10n.noneditable_image, {}, file, 'no-retry' );
       
   364 					up.removeFile( file );
       
   365 					return;
   361 				}
   366 				}
   362 
   367 
   363 				// Generate attributes for a new `Attachment` model.
   368 				// Generate attributes for a new `Attachment` model.
   364 				attributes = _.extend({
   369 				attributes = _.extend({
   365 					file:      file,
   370 					file:      file,
   438 			// Check for plupload errors.
   443 			// Check for plupload errors.
   439 			for ( key in Uploader.errorMap ) {
   444 			for ( key in Uploader.errorMap ) {
   440 				if ( pluploadError.code === plupload[ key ] ) {
   445 				if ( pluploadError.code === plupload[ key ] ) {
   441 					message = Uploader.errorMap[ key ];
   446 					message = Uploader.errorMap[ key ];
   442 
   447 
   443 					if ( _.isFunction( message ) ) {
   448 					if ( typeof message === 'function' ) {
   444 						message = message( pluploadError.file, pluploadError );
   449 						message = message( pluploadError.file, pluploadError );
   445 					}
   450 					}
   446 
   451 
   447 					break;
   452 					break;
   448 				}
   453 				}