diff options
Diffstat (limited to 'wp-includes/js/swfupload/plugins')
4 files changed, 273 insertions, 0 deletions
diff --git a/wp-includes/js/swfupload/plugins/swfupload.cookies.js b/wp-includes/js/swfupload/plugins/swfupload.cookies.js new file mode 100644 index 0000000..4d41612 --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.cookies.js @@ -0,0 +1,50 @@ +/* + Cookie Plug-in + + This plug in automatically gets all the cookies for this site and adds them to the post_params. + Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params. + The cookies will override any other post params with the same name. +*/ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + SWFUpload.prototype.initSettings = function (old_initSettings) { + return function (init_settings) { + if (typeof(old_initSettings) === "function") { + old_initSettings.call(this, init_settings); + } + + this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point + }; + }(SWFUpload.prototype.initSettings); + + // refreshes the post_params and updates SWFUpload. The send_to_flash parameters is optional and defaults to True + SWFUpload.prototype.refreshCookies = function (send_to_flash) { + if (send_to_flash !== false) send_to_flash = true; + + // Get the post_params object + var post_params = this.getSetting("post_params"); + + // Get the cookies + var i, cookie_array = document.cookie.split(';'), ca_length = cookie_array.length, c, eq_index, name, value; + for(i = 0; i < ca_length; i++) { + c = cookie_array[i]; + + // Left Trim spaces + while (c.charAt(0) == " ") { + c = c.substring(1, c.length); + } + eq_index = c.indexOf("="); + if (eq_index > 0) { + name = c.substring(0, eq_index); + value = c.substring(eq_index+1); + post_params[name] = value; + } + } + + if (send_to_flash) { + this.setPostParams(post_params); + } + }; + +} diff --git a/wp-includes/js/swfupload/plugins/swfupload.documentready.js b/wp-includes/js/swfupload/plugins/swfupload.documentready.js new file mode 100644 index 0000000..a95bac5 --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.documentready.js @@ -0,0 +1,102 @@ +/* + DocumentReady Plug-in + + This plugin loads SWFUpload as soon as the document is ready. You should not load SWFUpload inside window.onload using this plugin. + You can also chain other functions by calling SWFUpload.DocumentReady(your function). + + Warning: Embedded Ads or other scripts that overwrite window.onload or use their own document ready functions may interfer with this plugin. You + should not set window.onload when using this plugin. + + Usage Example: + + var swfu = new SWFUpload(your settings object); + SWFUpload.DocumentReady(function () { alert('Document Ready!'; }); + +*/ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + // Override iniSWFUpload so SWFUpload gets inited when the document is ready rather than immediately + SWFUpload.prototype.initSWFUpload = function (old_initSWFUpload) { + return function (init_settings) { + var self = this; + if (typeof(old_initSWFUpload) === "function") { + SWFUpload.DocumentReady(function () { + old_initSWFUpload.call(self, init_settings); + }); + } + } + + }(SWFUpload.prototype.initSWFUpload); + + + // The DocumentReady function adds the passed in function to + // the functions that will be executed when the document is ready/loaded + SWFUpload.DocumentReady = function (fn) { + // Add the function to the chain + SWFUpload.DocumentReady.InternalOnloadChain = function (previous_link_fn) { + return function () { + if (typeof(previous_link_fn) === "function") { + previous_link_fn(); + } + fn(); + }; + }(SWFUpload.DocumentReady.InternalOnloadChain); + }; + SWFUpload.DocumentReady.InternalOnloadChain = null; + SWFUpload.DocumentReady.Onload = function () { + // Execute the onload function chain + if (typeof(SWFUpload.DocumentReady.InternalOnloadChain) === "function") { + SWFUpload.DocumentReady.InternalOnloadChain(); + } + }; + SWFUpload.DocumentReady.SetupComplete = false; + + + /* ******************************************** + This portion of the code gets executed as soon it is loaded. + It binds the proper event for executing JavaScript is + early as possible. This is a per browser function and so + some browser sniffing is used. + + This solution still has the "exposed" issue (See the Global Delegation section at http://peter.michaux.ca/article/553 ) + + Base solution from http://dean.edwards.name/weblog/2006/06/again/ and http://dean.edwards.name/weblog/2005/09/busted/ + ******************************************** */ + if (!SWFUpload.DocumentReady.SetupComplete) { + // for Internet Explorer (using conditional comments) + /*@cc_on @*/ + /*@if (@_win32) + document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>"); + var script = document.getElementById("__ie_onload"); + script.onreadystatechange = function() { + if (this.readyState == "complete") { + SWFUpload.DocumentReady.Onload(); // call the onload handler + } + }; + SWFUpload.DocumentReady.SetupComplete = true; + /*@end @*/ + } + + if (!SWFUpload.DocumentReady.SetupComplete && /WebKit/i.test(navigator.userAgent)) { // sniff + var _timer = setInterval(function() { + if (/loaded|complete/.test(document.readyState)) { + clearInterval(_timer); + SWFUpload.DocumentReady.Onload(); // call the onload handler + } + }, 10); + SWFUpload.DocumentReady.SetupComplete = true; + } + + /* for Mozilla */ + if (!SWFUpload.DocumentReady.SetupComplete && document.addEventListener) { + document.addEventListener("DOMContentLoaded", SWFUpload.DocumentReady.Onload, false); + SWFUpload.DocumentReady.SetupComplete = true; + } + + /* for other browsers */ + if (!SWFUpload.DocumentReady.SetupComplete) { + window.onload = SWFUpload.DocumentReady.Onload; + SWFUpload.DocumentReady.SetupComplete = true; + } +} diff --git a/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js b/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js new file mode 100644 index 0000000..16bf12e --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js @@ -0,0 +1,63 @@ +/* + SWFUpload Graceful Degradation Plug-in + + This plugin allows SWFUpload to display only if it is loaded successfully. Otherwise a default form is left displayed. + + Usage: + + To use this plugin create two HTML containers. Each should have an ID defined. One container should hold the SWFUpload UI. The other should hold the degraded UI. + + The SWFUpload container should have its CSS "display" property set to "none". + + If SWFUpload loads successfully the SWFUpload container will be displayed ("display" set to "block") and the + degraded container will be hidden ("display" set to "none"). + + Use the settings "swfupload_element_id" and "degraded_element_id" to indicate your container IDs. The default values are "swfupload_container" and "degraded_container". + +*/ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + SWFUpload.gracefulDegradation = {}; + SWFUpload.prototype.initSettings = function (old_initSettings) { + return function (init_settings) { + if (typeof(old_initSettings) === "function") { + old_initSettings.call(this, init_settings); + } + + this.addSetting("swfupload_element_id", init_settings.swfupload_element_id, "swfupload_container"); + this.addSetting("degraded_element_id", init_settings.degraded_element_id, "degraded_container"); + this.addSetting("user_swfUploadLoaded_handler", init_settings.swfupload_loaded_handler, SWFUpload.swfUploadLoaded); + + this.swfUploadLoaded_handler = SWFUpload.gracefulDegradation.swfUploadLoaded; + }; + }(SWFUpload.prototype.initSettings); + + SWFUpload.gracefulDegradation.swfUploadLoaded = function () { + var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler; + try { + swfupload_element_id = this.getSetting("swfupload_element_id"); + degraded_element_id = this.getSetting("degraded_element_id"); + + // Show the UI container + swfupload_container = document.getElementById(swfupload_element_id); + if (swfupload_container !== null) { + swfupload_container.style.display = "block"; + + // Now take care of hiding the degraded UI + degraded_container = document.getElementById(degraded_element_id); + if (degraded_container !== null) { + degraded_container.style.display = "none"; + } + } + } catch (ex) { + this.debug(ex); + } + + user_swfUploadLoaded_handler = this.getSetting("user_swfUploadLoaded_handler"); + if (typeof(user_swfUploadLoaded_handler) === "function") { + user_swfUploadLoaded_handler.apply(this); + } + }; + +} diff --git a/wp-includes/js/swfupload/plugins/swfupload.queue.js b/wp-includes/js/swfupload/plugins/swfupload.queue.js new file mode 100644 index 0000000..9752e28 --- /dev/null +++ b/wp-includes/js/swfupload/plugins/swfupload.queue.js @@ -0,0 +1,58 @@ +/* + Queue Plug-in + + Features: + cancelQueue method for cancelling the entire queue. + 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. + + */ + +var SWFUpload; +if (typeof(SWFUpload) === "function") { + SWFUpload.queue = {}; + + SWFUpload.prototype.initSettings = function (old_initSettings) { + return function (init_settings) { + if (typeof(old_initSettings) === "function") { + old_initSettings.call(this, init_settings); + } + + this.customSettings.queue_cancelled_flag = false; + + this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete); + this.uploadComplete_handler = SWFUpload.queue.uploadComplete; + }; + }(SWFUpload.prototype.initSettings); + + 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; + } + + while(stats.files_queued > 0) { + this.cancelUpload(); + stats = this.getStats(); + } + }; + + SWFUpload.queue.uploadComplete = function (file) { + var user_upload_complete_handler = this.getSetting("user_upload_complete_handler"); + var continue_upload = true; + if (typeof(user_upload_complete_handler) === "function") { + continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true; + } + + if (continue_upload) { + var stats = this.getStats(); + if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) { + this.startUpload(); + } else { + this.customSettings.queue_cancelled_flag = false; + } + } + }; +} |