Image post format UI:

- When initializing wp.Uploader pass null for 'container' and 'browser'. Fixes a bug where another instance of the uploader was attached to <body>.
- Destroy the uploader instance if drag/drop is not supported (IE8 & 9).
See #24291.

git-svn-id: https://develop.svn.wordpress.org/trunk@24310 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2013-05-22 01:30:00 +00:00
parent dcbff314ea
commit ee93e9c949
1 changed files with 11 additions and 3 deletions

View File

@ -67,6 +67,8 @@ window.wp = window.wp || {};
} }
var uploader = { var uploader = {
container: null,
browser: null,
dropzone: $('.wp-format-media-holder[data-format=image]'), dropzone: $('.wp-format-media-holder[data-format=image]'),
success: imageFormatUploadSuccess, success: imageFormatUploadSuccess,
error: imageFormatUploadError, error: imageFormatUploadError,
@ -77,9 +79,15 @@ window.wp = window.wp || {};
params: {} params: {}
}; };
uploader = new wp.Uploader( uploader ); uploader = new wp.Uploader( uploader );
if ( uploader.supports.dragdrop ) {
uploader.uploader.bind( 'BeforeUpload', imageFormatUploadStart ); uploader.uploader.bind( 'BeforeUpload', imageFormatUploadStart );
uploader.uploader.bind( 'UploadProgress', imageFormatUploadProgress ); uploader.uploader.bind( 'UploadProgress', imageFormatUploadProgress );
uploader.uploader.bind( 'FilesAdded', imageFormatUploadFilesAdded ); uploader.uploader.bind( 'FilesAdded', imageFormatUploadFilesAdded );
} else {
uploader.uploader.destroy();
uploader = null;
}
function switchFormatClass( format ) { function switchFormatClass( format ) {
formatField.val( format ); formatField.val( format );