Improvements of Image format dropzone

* Limit drag-drop Image format zone to HTML5 runtime
* Only keep the first file dropped
* Only upload image files
* Fix CSS for the progress bar

props azaozz. see #24291.

git-svn-id: https://develop.svn.wordpress.org/trunk@24236 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-05-10 18:49:05 +00:00
parent d75c52e120
commit 87730d0649
2 changed files with 17 additions and 7 deletions

View File

@ -4061,6 +4061,7 @@ body .ui-slider-tooltip {
.wp-format-media-holder div {
display: none;
}
.wp-format-media-holder.drag-over div {
position: absolute;
top: 10px;
@ -4072,7 +4073,6 @@ body .ui-slider-tooltip {
}
#poststuff .wp-format-media-holder.drag-over div h3 {
position: absolute;
top: 50%;
left: 0;
@ -4111,10 +4111,7 @@ body .ui-slider-tooltip {
text-align: center;
}
body.wp-format-image .attachment-display-settings {
display: none;
}
body.wp-format-image .attachment-display-settings,
body.wp-format-status #titlewrap,
body.wp-format-image .wp-media-buttons .insert-media,
body.wp-format-audio .wp-media-buttons .insert-media,
@ -4124,6 +4121,8 @@ body.wp-format-status .wp-media-buttons .insert-media {
display: none;
}
.wp-format-media-select .media-progress-bar,
.wp-format-media-select .media-progress-bar div,
.mejs-audio audio,
.mejs-video video {
display: block;

View File

@ -59,16 +59,27 @@ window.wp = window.wp || {};
'</div>'].join( '' ) );
}
function imageFormatUploadFilesAdded( uploader, files ) {
$.each( files, function( i, file ) {
if ( i > 0 )
uploader.removeFile(file);
});
}
var uploader = {
dropzone: $('.wp-format-media-holder[data-format=image]'),
success: imageFormatUploadSuccess,
error: imageFormatUploadError,
plupload: {},
error: imageFormatUploadError,
plupload: {
runtimes: 'html5',
filters: [ {title: 'Image', extensions: 'jpg,jpeg,gif,png'} ]
},
params: {}
};
uploader = new wp.Uploader( uploader );
uploader.uploader.bind( 'BeforeUpload', imageFormatUploadStart );
uploader.uploader.bind( 'UploadProgress', imageFormatUploadProgress );
uploader.uploader.bind( 'FilesAdded', imageFormatUploadFilesAdded );
function switchFormatClass( format ) {
formatField.val( format );