Disable the Cancel Upload button after the upload has finished or if it was interrupted, fixes #19050

git-svn-id: http://svn.automattic.com/wordpress/trunk@19099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-10-31 21:38:28 +00:00
parent 13db43d2d3
commit b63ffa3f38
4 changed files with 24 additions and 38 deletions

View File

@ -1282,17 +1282,18 @@ function media_upload_form( $errors = null ) {
} }
?> ?>
<div id="media-upload-notice"> <div id="media-upload-notice"><?php
<?php if (isset($errors['upload_notice']) ) { ?>
<?php echo $errors['upload_notice']; ?>
<?php } ?>
</div>
<div id="media-upload-error"> if (isset($errors['upload_notice']) )
<?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> echo $errors['upload_notice'];
<?php echo $errors['upload_error']->get_error_message(); ?>
<?php } ?> ?></div>
</div> <div id="media-upload-error"><?php
if (isset($errors['upload_error']) && is_wp_error($errors['upload_error']))
echo $errors['upload_error']->get_error_message();
?></div>
<?php <?php
// Check quota for this blog if multisite // Check quota for this blog if multisite
if ( is_multisite() && !is_upload_space_available() ) { if ( is_multisite() && !is_upload_space_available() ) {

View File

@ -194,18 +194,18 @@ function prepareMediaItemInit(fileObj) {
function cancelUpload() { function cancelUpload() {
uploader.stop(); uploader.stop();
uploadComplete();
jQuery.each(uploader.files, function(i,file) { jQuery.each(uploader.files, function(i,file) {
if ( file.status == plupload.STOPPED ) if ( file.status == plupload.STOPPED )
jQuery('#media-item-' + file.id).remove(); jQuery('#media-item-' + file.id).remove();
}); });
} }
// wp-specific error handlers // wp-specific error handlers
// generic message // generic message
function wpQueueError(message) { function wpQueueError(message) {
jQuery('#media-upload-error').show().text(message); jQuery('#media-upload-error').show().html( '<div id="error"><p>' + message + '</p></div>' );
} }
// file-specific message // file-specific message
@ -268,14 +268,10 @@ function deleteError(X, textStatus, errorThrown) {
// TODO // TODO
} }
// SWFUpload? function uploadComplete() {
function uploadComplete(fileObj) {
// If no more uploads queued, enable the submit button
if ( swfu.getStats().files_queued == 0 ) {
jQuery('#cancel-upload').prop('disabled', true); jQuery('#cancel-upload').prop('disabled', true);
jQuery('#insert-gallery').prop('disabled', false); jQuery('#insert-gallery').prop('disabled', false);
} }
}
function switchUploader(s) { function switchUploader(s) {
var p = document.getElementById('flash-upload-ui'), h = document.getElementById('html-upload-ui'); var p = document.getElementById('flash-upload-ui'), h = document.getElementById('html-upload-ui');
@ -299,21 +295,6 @@ function dndHelper(s) {
} }
} }
// SWFUpload?
function swfuploadPreLoad() {
if ( !uploaderMode ) {
switchUploader(1);
} else {
switchUploader(0);
}
}
// SWFUpload?
function swfuploadLoadFailed() {
switchUploader(0);
jQuery('.upload-html-bypass').hide();
}
function uploadError(fileObj, errorCode, message) { function uploadError(fileObj, errorCode, message) {
switch (errorCode) { switch (errorCode) {
@ -443,6 +424,10 @@ jQuery(document).ready(function($){
uploader.bind('FileUploaded', function(up, file, response) { uploader.bind('FileUploaded', function(up, file, response) {
uploadSuccess(file, response.response); uploadSuccess(file, response.response);
}); });
uploader.bind('UploadComplete', function(up, files) {
uploadComplete();
});
} }
if ( typeof(wpUploaderInit) == 'object' ) if ( typeof(wpUploaderInit) == 'object' )

File diff suppressed because one or more lines are too long

View File

@ -220,7 +220,7 @@ function wp_default_scripts( &$scripts ) {
// cannot use the plupload.full.js, as it loads browserplus init JS from Yahoo // cannot use the plupload.full.js, as it loads browserplus init JS from Yahoo
$scripts->add( 'plupload-full', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1.5b'); $scripts->add( 'plupload-full', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1.5b');
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-full', 'jquery'), '20111012'); $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-full', 'jquery'), '20111031');
$scripts->add_script_data( 'plupload-handlers', 'pluploadL10n', $uploader_l10n ); $scripts->add_script_data( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
// keep 'swfupload' for back-compat. // keep 'swfupload' for back-compat.