]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js
Wordpress 2.7.1
[autoinstalls/wordpress.git] / wp-includes / js / swfupload / plugins / swfupload.graceful_degradation.js
1 /* 
2         SWFUpload Graceful Degradation Plug-in
3
4         This plugin allows SWFUpload to display only if it is loaded successfully.  Otherwise a default form is left displayed.
5         
6         Usage:
7         
8         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.
9         
10         The SWFUpload container should have its CSS "display" property set to "none".
11         
12         If SWFUpload loads successfully the SWFUpload container will be displayed ("display" set to "block") and the
13         degraded container will be hidden ("display" set to "none").
14         
15         Use the settings "swfupload_element_id" and "degraded_element_id" to indicate your container IDs.  The default values are "swfupload_container" and "degraded_container".
16         
17 */
18
19 var SWFUpload;
20 if (typeof(SWFUpload) === "function") {
21         SWFUpload.gracefulDegradation = {};
22         SWFUpload.prototype.initSettings = function (old_initSettings) {
23                 return function (init_settings) {
24                         if (typeof(old_initSettings) === "function") {
25                                 old_initSettings.call(this, init_settings);
26                         }
27                         
28                         this.addSetting("swfupload_element_id",                         init_settings.swfupload_element_id,                             "swfupload_container");
29                         this.addSetting("degraded_element_id",                          init_settings.degraded_element_id,                              "degraded_container");
30                         this.addSetting("user_swfUploadLoaded_handler",         init_settings.swfupload_loaded_handler,                 SWFUpload.swfUploadLoaded);
31
32                         this.swfUploadLoaded_handler = SWFUpload.gracefulDegradation.swfUploadLoaded;
33                 };
34         }(SWFUpload.prototype.initSettings);
35
36         SWFUpload.gracefulDegradation.swfUploadLoaded = function () {
37                 var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler;
38                 try {
39                         if (uploadDegradeOptions.is_lighttpd_before_150) throw "Lighttpd versions earlier than 1.5.0 aren't supported!";
40                         swfupload_element_id = this.getSetting("swfupload_element_id");
41                         degraded_element_id = this.getSetting("degraded_element_id");
42                         
43                         // Show the UI container
44                         swfupload_container = document.getElementById(swfupload_element_id);
45                         if (swfupload_container !== null) {
46                                 swfupload_container.style.display = "block";
47
48                                 // Now take care of hiding the degraded UI
49                                 degraded_container = document.getElementById(degraded_element_id);
50                                 if (degraded_container !== null) {
51                                         degraded_container.style.display = "none";
52                                 }
53                         }
54                 } catch (ex) {
55                         this.debug(ex);
56                 }
57                 
58                 user_swfUploadLoaded_handler = this.getSetting("user_swfUploadLoaded_handler");
59                 if (typeof(user_swfUploadLoaded_handler) === "function") {
60                         user_swfUploadLoaded_handler.apply(this);
61                 }
62         };
63
64 }