Uploader: show the progress bars as soon as files are queued, attempt to make the progress bar more precise, see #19228
git-svn-id: https://develop.svn.wordpress.org/trunk@19346 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f69b9abfb0
commit
4ded511eff
@ -17,8 +17,6 @@ function fileQueued(fileObj) {
|
|||||||
}
|
}
|
||||||
// Create a progress bar containing the filename
|
// Create a progress bar containing the filename
|
||||||
jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><div class="progress"><div class="percent">0%</div><div class="bar"></div></div><div class="filename original"> ' + fileObj.name + '</div></div>');
|
jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><div class="progress"><div class="percent">0%</div><div class="bar"></div></div><div class="filename original"> ' + fileObj.name + '</div></div>');
|
||||||
// Display the progress div
|
|
||||||
jQuery('.progress', jQuery('#media-item-' + fileObj.id)).fadeIn();
|
|
||||||
|
|
||||||
// Disable submit
|
// Disable submit
|
||||||
jQuery('#insert-gallery').prop('disabled', true);
|
jQuery('#insert-gallery').prop('disabled', true);
|
||||||
@ -61,7 +59,7 @@ function updateMediaForm() {
|
|||||||
|
|
||||||
// Just one file, no need for collapsible part
|
// Just one file, no need for collapsible part
|
||||||
if ( items.length == 1 ) {
|
if ( items.length == 1 ) {
|
||||||
items.addClass('open').find('.slidetoggle').slideDown();
|
items.addClass('open').find('.slidetoggle').show();
|
||||||
jQuery('.insert-gallery').hide();
|
jQuery('.insert-gallery').hide();
|
||||||
} else if ( items.length > 1 ) {
|
} else if ( items.length > 1 ) {
|
||||||
items.removeClass('open');
|
items.removeClass('open');
|
||||||
@ -83,7 +81,7 @@ function uploadSuccess(fileObj, serverData) {
|
|||||||
if ( serverData.match('media-upload-error') ) {
|
if ( serverData.match('media-upload-error') ) {
|
||||||
item.html(serverData);
|
item.html(serverData);
|
||||||
return;
|
return;
|
||||||
} else if ( fileObj.status == 5 ) {
|
} else {
|
||||||
jQuery('.percent', item).html( pluploadL10n.crunching );
|
jQuery('.percent', item).html( pluploadL10n.crunching );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,22 +107,16 @@ function setResize(arg) {
|
|||||||
|
|
||||||
function prepareMediaItem(fileObj, serverData) {
|
function prepareMediaItem(fileObj, serverData) {
|
||||||
var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
|
var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
|
||||||
// Move the progress bar to 100%
|
|
||||||
jQuery('.bar', item).remove();
|
|
||||||
jQuery('.progress', item).hide();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( typeof topWin.tb_remove != 'undefined' )
|
if ( typeof topWin.tb_remove != 'undefined' )
|
||||||
topWin.jQuery('#TB_overlay').click(topWin.tb_remove);
|
topWin.jQuery('#TB_overlay').click(topWin.tb_remove);
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
|
|
||||||
// Old style: Append the HTML returned by the server -- thumbnail and form inputs
|
if ( isNaN(serverData) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
|
||||||
if ( isNaN(serverData) || !serverData ) {
|
|
||||||
item.append(serverData);
|
item.append(serverData);
|
||||||
prepareMediaItemInit(fileObj);
|
prepareMediaItemInit(fileObj);
|
||||||
}
|
} else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
|
||||||
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
|
|
||||||
else {
|
|
||||||
item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
|
item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -436,20 +428,19 @@ jQuery(document).ready(function($){
|
|||||||
$('#media-upload-error').html('');
|
$('#media-upload-error').html('');
|
||||||
uploadStart();
|
uploadStart();
|
||||||
|
|
||||||
if ( max > hundredmb && up.runtime != 'html5' ) {
|
|
||||||
plupload.each(files, function(file){
|
plupload.each(files, function(file){
|
||||||
if ( file.size > hundredmb ) {
|
if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' )
|
||||||
uploadSizeError( up, file, true );
|
uploadSizeError( up, file, true );
|
||||||
}
|
else
|
||||||
|
fileQueued(file);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
up.refresh();
|
up.refresh();
|
||||||
up.start();
|
up.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
uploader.bind('BeforeUpload', function(up, file) {
|
uploader.bind('BeforeUpload', function(up, file) {
|
||||||
fileQueued(file);
|
// something
|
||||||
});
|
});
|
||||||
|
|
||||||
uploader.bind('UploadFile', function(up, file) {
|
uploader.bind('UploadFile', function(up, file) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -222,7 +222,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-all', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1511-20111112');
|
$scripts->add( 'plupload-all', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1511-20111112');
|
||||||
|
|
||||||
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery'), '20111117');
|
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery'), '20111118');
|
||||||
$scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
|
$scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
|
||||||
|
|
||||||
// keep 'swfupload' for back-compat.
|
// keep 'swfupload' for back-compat.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user