SWFUpload 2.2.0 beta 2 with Flash 10 support. Props filosofo. see #6979

git-svn-id: http://svn.automattic.com/wordpress/trunk@9421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-30 23:13:53 +00:00
parent 8fcc4c16ce
commit 03a2e31631
8 changed files with 852 additions and 835 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

View File

@ -205,6 +205,14 @@ function fileDialogComplete(num_files_queued) {
} }
} }
function swfuploadPreLoad() {
return true;
}
function swfuploadLoadFailed() {
return true;
}
function uploadError(fileObj, error_code, message) { function uploadError(fileObj, error_code, message) {
// first the file specific error // first the file specific error
if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) { if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) {

View File

@ -8,42 +8,45 @@
var SWFUpload; var SWFUpload;
if (typeof(SWFUpload) === "function") { if (typeof(SWFUpload) === "function") {
SWFUpload.prototype.initSettings = function (old_initSettings) { SWFUpload.prototype.initSettings = function (oldInitSettings) {
return function (init_settings) { return function () {
if (typeof(old_initSettings) === "function") { if (typeof(oldInitSettings) === "function") {
old_initSettings.call(this, init_settings); oldInitSettings.call(this);
} }
this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
}; };
}(SWFUpload.prototype.initSettings); }(SWFUpload.prototype.initSettings);
// refreshes the post_params and updates SWFUpload. The send_to_flash parameters is optional and defaults to True // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
SWFUpload.prototype.refreshCookies = function (send_to_flash) { SWFUpload.prototype.refreshCookies = function (sendToFlash) {
if (send_to_flash !== false) send_to_flash = true; if (sendToFlash === undefined) {
sendToFlash = true;
}
sendToFlash = !!sendToFlash;
// Get the post_params object // Get the post_params object
var post_params = this.getSetting("post_params"); var postParams = this.settings.post_params;
// Get the cookies // Get the cookies
var i, cookie_array = document.cookie.split(';'), ca_length = cookie_array.length, c, eq_index, name, value; var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
for(i = 0; i < ca_length; i++) { for (i = 0; i < caLength; i++) {
c = cookie_array[i]; c = cookieArray[i];
// Left Trim spaces // Left Trim spaces
while (c.charAt(0) == " ") { while (c.charAt(0) === " ") {
c = c.substring(1, c.length); c = c.substring(1, c.length);
} }
eq_index = c.indexOf("="); eqIndex = c.indexOf("=");
if (eq_index > 0) { if (eqIndex > 0) {
name = c.substring(0, eq_index); name = c.substring(0, eqIndex);
value = c.substring(eq_index+1); value = c.substring(eqIndex + 1);
post_params[name] = value; postParams[name] = value;
} }
} }
if (send_to_flash) { if (sendToFlash) {
this.setPostParams(post_params); this.setPostParams(postParams);
} }
}; };

View File

@ -2,9 +2,12 @@
Queue Plug-in Queue Plug-in
Features: Features:
cancelQueue method for cancelling the entire queue. *Adds a cancelQueue() method for cancelling the entire queue.
All queued files are uploaded when startUpload() is called. *All queued files are uploaded when startUpload() is called.
If false is returned from uploadComplete then the queue upload is stopped. If false is not returned (strict comparison) then the queue upload is continued. *If false is returned from uploadComplete then the queue upload is stopped.
If false is not returned (strict comparison) then the queue upload is continued.
*Adds a QueueComplete event that is fired when all the queued files have finished uploading.
Set the event handler with the queue_complete_handler setting.
*/ */
@ -12,46 +15,62 @@ var SWFUpload;
if (typeof(SWFUpload) === "function") { if (typeof(SWFUpload) === "function") {
SWFUpload.queue = {}; SWFUpload.queue = {};
SWFUpload.prototype.initSettings = function (old_initSettings) { SWFUpload.prototype.initSettings = (function (oldInitSettings) {
return function (init_settings) { return function () {
if (typeof(old_initSettings) === "function") { if (typeof(oldInitSettings) === "function") {
old_initSettings.call(this, init_settings); oldInitSettings.call(this);
} }
this.customSettings.queue_cancelled_flag = false; this.customSettings.queue_cancelled_flag = false;
this.customSettings.queue_upload_count = 0;
this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete); this.settings.user_upload_complete_handler = this.settings.upload_complete_handler;
this.uploadComplete_handler = SWFUpload.queue.uploadComplete; this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
};
})(SWFUpload.prototype.initSettings);
SWFUpload.prototype.startUpload = function (fileID) {
this.customSettings.queue_cancelled_flag = false;
this.callFlash("StartUpload", false, [fileID]);
}; };
}(SWFUpload.prototype.initSettings);
SWFUpload.prototype.cancelQueue = function () { SWFUpload.prototype.cancelQueue = function () {
var stats = this.getStats();
this.customSettings.queue_cancelled_flag = false;
if (stats.in_progress > 0) {
this.customSettings.queue_cancelled_flag = true; this.customSettings.queue_cancelled_flag = true;
} this.stopUpload();
while(stats.files_queued > 0) { var stats = this.getStats();
while (stats.files_queued > 0) {
this.cancelUpload(); this.cancelUpload();
stats = this.getStats(); stats = this.getStats();
} }
}; };
SWFUpload.queue.uploadComplete = function (file) { SWFUpload.queue.uploadCompleteHandler = function (file) {
var user_upload_complete_handler = this.getSetting("user_upload_complete_handler"); var user_upload_complete_handler = this.settings.user_upload_complete_handler;
var continue_upload = true; var continueUpload;
if (typeof(user_upload_complete_handler) === "function") {
continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true; if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
this.customSettings.queue_upload_count++;
} }
if (continue_upload) { if (typeof(user_upload_complete_handler) === "function") {
continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
} else {
continueUpload = true;
}
if (continueUpload) {
var stats = this.getStats(); var stats = this.getStats();
if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) { if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) {
this.startUpload(); this.startUpload();
} else if (this.customSettings.queue_cancelled_flag === false) {
this.queueEvent("queue_complete_handler", [this.customSettings.queue_upload_count]);
this.customSettings.queue_upload_count = 0;
} else { } else {
this.customSettings.queue_cancelled_flag = false; this.customSettings.queue_cancelled_flag = false;
this.customSettings.queue_upload_count = 0;
} }
} }
}; };

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -104,6 +104,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430'); $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430');
$scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2-20080430'); $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2-20080430');
$scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); $scripts->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
$scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload'), '2.0.2');
$scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array( $scripts->localize( 'swfupload-degrade', 'uploadDegradeOptions', array(
'is_lighttpd_before_150' => is_lighttpd_before_150(), 'is_lighttpd_before_150' => is_lighttpd_before_150(),
) ); ) );