Bug 5917 : Converted templates
[koha.git] / koha-tt / intranet-tmpl / prog / en / lib / yui / uploader / uploader-debug.js
1 /*
2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
5 version: 2.8.0r4
6 */
7 /*extern ActiveXObject, __flash_unloadHandler, __flash_savedUnloadHandler */
8 /*!
9  * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
10  *
11  * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
12  * http://www.opensource.org/licenses/mit-license.php
13  * @namespace YAHOO
14  */
15
16 YAHOO.namespace("deconcept"); 
17         
18 YAHOO.deconcept = YAHOO.deconcept || {};
19
20 if(typeof YAHOO.deconcept.util == "undefined" || !YAHOO.deconcept.util)
21 {
22         YAHOO.deconcept.util = {};
23 }
24
25 if(typeof YAHOO.deconcept.SWFObjectUtil == "undefined" || !YAHOO.deconcept.SWFObjectUtil)
26 {
27         YAHOO.deconcept.SWFObjectUtil = {};
28 }
29
30 YAHOO.deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey)
31 {
32         if(!document.getElementById) { return; }
33         this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
34         this.skipDetect = YAHOO.deconcept.util.getRequestParameter(this.DETECT_KEY);
35         this.params = {};
36         this.variables = {};
37         this.attributes = [];
38         if(swf) { this.setAttribute('swf', swf); }
39         if(id) { this.setAttribute('id', id); }
40         if(w) { this.setAttribute('width', w); }
41         if(h) { this.setAttribute('height', h); }
42         if(ver) { this.setAttribute('version', new YAHOO.deconcept.PlayerVersion(ver.toString().split("."))); }
43         this.installedVer = YAHOO.deconcept.SWFObjectUtil.getPlayerVersion();
44         if (!window.opera && document.all && this.installedVer.major > 7)
45         {
46                 // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
47                 YAHOO.deconcept.SWFObject.doPrepUnload = true;
48         }
49         if(c)
50         {
51                 this.addParam('bgcolor', c);
52         }
53         var q = quality ? quality : 'high';
54         this.addParam('quality', q);
55         this.setAttribute('useExpressInstall', false);
56         this.setAttribute('doExpressInstall', false);
57         var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
58         this.setAttribute('xiRedirectUrl', xir);
59         this.setAttribute('redirectUrl', '');
60         if(redirectUrl)
61         {
62                 this.setAttribute('redirectUrl', redirectUrl);
63         }
64 };
65
66 YAHOO.deconcept.SWFObject.prototype =
67 {
68         useExpressInstall: function(path)
69         {
70                 this.xiSWFPath = !path ? "expressinstall.swf" : path;
71                 this.setAttribute('useExpressInstall', true);
72         },
73         setAttribute: function(name, value){
74                 this.attributes[name] = value;
75         },
76         getAttribute: function(name){
77                 return this.attributes[name];
78         },
79         addParam: function(name, value){
80                 this.params[name] = value;
81         },
82         getParams: function(){
83                 return this.params;
84         },
85         addVariable: function(name, value){
86                 this.variables[name] = value;
87         },
88         getVariable: function(name){
89                 return this.variables[name];
90         },
91         getVariables: function(){
92                 return this.variables;
93         },
94         getVariablePairs: function(){
95                 var variablePairs = [];
96                 var key;
97                 var variables = this.getVariables();
98                 for(key in variables)
99                 {
100                         if(variables.hasOwnProperty(key))
101                         {
102                                 variablePairs[variablePairs.length] = key +"="+ variables[key];
103                         }
104                 }
105                 return variablePairs;
106         },
107         getSWFHTML: function() {
108                 var swfNode = "";
109                 var params = {};
110                 var key = "";
111                 var pairs = "";
112                 if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
113                         if (this.getAttribute("doExpressInstall")) {
114                                 this.addVariable("MMplayerType", "PlugIn");
115                                 this.setAttribute('swf', this.xiSWFPath);
116                         }
117                         swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
118                         swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
119                         params = this.getParams();
120                         for(key in params)
121                         {
122                                 if(params.hasOwnProperty(key))
123                                 {
124                                         swfNode += [key] +'="'+ params[key] +'" ';
125                                 }
126                         }
127                         pairs = this.getVariablePairs().join("&");
128                         if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
129                         swfNode += '/>';
130                 } else { // PC IE
131                         if (this.getAttribute("doExpressInstall")) {
132                                 this.addVariable("MMplayerType", "ActiveX");
133                                 this.setAttribute('swf', this.xiSWFPath);
134                         }
135                         swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
136                         swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
137                         params = this.getParams();
138                         for(key in params)
139                         {
140                                 if(params.hasOwnProperty(key))
141                                 {
142                                         swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
143                                 }
144                         }
145                         pairs = this.getVariablePairs().join("&");
146                         if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
147                         swfNode += "</object>";
148                 }
149                 return swfNode;
150         },
151         write: function(elementId)
152         {
153                 if(this.getAttribute('useExpressInstall')) {
154                         // check to see if we need to do an express install
155                         var expressInstallReqVer = new YAHOO.deconcept.PlayerVersion([6,0,65]);
156                         if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
157                                 this.setAttribute('doExpressInstall', true);
158                                 this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
159                                 document.title = document.title.slice(0, 47) + " - Flash Player Installation";
160                                 this.addVariable("MMdoctitle", document.title);
161                         }
162                 }
163                 if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version')))
164                 {
165                         var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
166                         n.innerHTML = this.getSWFHTML();
167                         return true;
168                 }
169                 else
170                 {
171                         if(this.getAttribute('redirectUrl') !== "")
172                         {
173                                 document.location.replace(this.getAttribute('redirectUrl'));
174                         }
175                 }
176                 return false;
177         }
178 };
179
180 /* ---- detection functions ---- */
181 YAHOO.deconcept.SWFObjectUtil.getPlayerVersion = function()
182 {
183         var axo = null;
184         var PlayerVersion = new YAHOO.deconcept.PlayerVersion([0,0,0]);
185         if(navigator.plugins && navigator.mimeTypes.length)
186         {
187                 var x = navigator.plugins["Shockwave Flash"];
188                 if(x && x.description)
189                 {
190                         PlayerVersion = new YAHOO.deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
191                 }
192         }
193         else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0)
194         { // if Windows CE
195                 var counter = 3;
196                 while(axo)
197                 {
198                         try
199                         {
200                                 counter++;
201                                 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
202 //                              document.write("player v: "+ counter);
203                                 PlayerVersion = new YAHOO.deconcept.PlayerVersion([counter,0,0]);
204                         }
205                         catch(e)
206                         {
207                                 axo = null;
208                         }
209                 }
210         }
211         else
212         { // Win IE (non mobile)
213                 // do minor version lookup in IE, but avoid fp6 crashing issues
214                 // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
215                 try
216                 {
217                         axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
218                 }
219                 catch(e)
220                 {
221                         try
222                         {
223                                 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
224                                 PlayerVersion = new YAHOO.deconcept.PlayerVersion([6,0,21]);
225                                 axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
226                         }
227                         catch(e)
228                         {
229                                 if(PlayerVersion.major == 6)
230                                 {
231                                         return PlayerVersion;
232                                 }
233                         }
234                         try
235                         {
236                                 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
237                         }
238                         catch(e) {}
239                 }
240                 
241                 if(axo !== null)
242                 {
243                         PlayerVersion = new YAHOO.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
244                 }
245         }
246         return PlayerVersion;
247 };
248
249 YAHOO.deconcept.PlayerVersion = function(arrVersion)
250 {
251         this.major = arrVersion[0] !== null ? parseInt(arrVersion[0], 0) : 0;
252         this.minor = arrVersion[1] !== null ? parseInt(arrVersion[1], 0) : 0;
253         this.rev = arrVersion[2] !== null ? parseInt(arrVersion[2], 0) : 0;
254 };
255
256 YAHOO.deconcept.PlayerVersion.prototype.versionIsValid = function(fv)
257 {
258         if(this.major < fv.major)
259         {
260                 return false;
261         }
262         if(this.major > fv.major)
263         {
264                 return true;
265         }
266         if(this.minor < fv.minor)
267         {
268                 return false;
269         }
270         if(this.minor > fv.minor)
271         {
272                 return true;
273         }
274         if(this.rev < fv.rev)
275         {
276                 return false;
277         }
278         return true;
279 };
280
281 /* ---- get value of query string param ---- */
282 YAHOO.deconcept.util =
283 {
284         getRequestParameter: function(param)
285         {
286                 var q = document.location.search || document.location.hash;
287                 if(param === null) { return q; }
288                 if(q)
289                 {
290                         var pairs = q.substring(1).split("&");
291                         for(var i=0; i < pairs.length; i++)
292                         {
293                                 if (pairs[i].substring(0, pairs[i].indexOf("=")) == param)
294                                 {
295                                         return pairs[i].substring((pairs[i].indexOf("=") + 1));
296                                 }
297                         }
298                 }
299                 return "";
300         }
301 };
302
303 /* fix for video streaming bug */
304 YAHOO.deconcept.SWFObjectUtil.cleanupSWFs = function()
305 {
306         var objects = document.getElementsByTagName("OBJECT");
307         for(var i = objects.length - 1; i >= 0; i--)
308         {
309                 objects[i].style.display = 'none';
310                 for(var x in objects[i])
311                 {
312                         if(typeof objects[i][x] == 'function')
313                         {
314                                 objects[i][x] = function(){};
315                         }
316                 }
317         }
318 };
319
320 // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
321 if(YAHOO.deconcept.SWFObject.doPrepUnload)
322 {
323         if(!YAHOO.deconcept.unloadSet)
324         {
325                 YAHOO.deconcept.SWFObjectUtil.prepUnload = function()
326                 {
327                         __flash_unloadHandler = function(){};
328                         __flash_savedUnloadHandler = function(){};
329                         window.attachEvent("onunload", YAHOO.deconcept.SWFObjectUtil.cleanupSWFs);
330                 };
331                 window.attachEvent("onbeforeunload", YAHOO.deconcept.SWFObjectUtil.prepUnload);
332                 YAHOO.deconcept.unloadSet = true;
333         }
334 }
335
336 /* add document.getElementById if needed (mobile IE < 5) */
337 if(!document.getElementById && document.all)
338 {
339         document.getElementById = function(id) { return document.all[id]; };
340 }
341 /**
342  * Wraps Flash embedding functionality and allows communication with SWF through
343  * attributes.
344  *
345  * @namespace YAHOO.widget
346  * @class FlashAdapter
347  * @uses YAHOO.util.AttributeProvider
348  */
349 YAHOO.widget.FlashAdapter = function(swfURL, containerID, attributes, buttonSkin)
350 {
351         
352         this._queue = this._queue || [];
353         this._events = this._events || {};
354         this._configs = this._configs || {};
355         attributes = attributes || {};
356         
357         //the Flash Player external interface code from Adobe doesn't play nicely
358         //with the default value, yui-gen, in IE
359         this._id = attributes.id = attributes.id || YAHOO.util.Dom.generateId(null, "yuigen");
360         attributes.version = attributes.version || "9.0.45";
361         attributes.backgroundColor = attributes.backgroundColor || "#ffffff";
362         
363         //we can't use the initial attributes right away
364         //so save them for once the SWF finishes loading
365         this._attributes = attributes;
366         
367         this._swfURL = swfURL;
368         this._containerID = containerID;
369         
370         //embed the SWF file in the page
371         this._embedSWF(this._swfURL, this._containerID, attributes.id, attributes.version,
372                 attributes.backgroundColor, attributes.expressInstall, attributes.wmode, buttonSkin);
373         
374         /**
375          * Fires when the SWF is initialized and communication is possible.
376          * @event contentReady
377          */
378         //Fix for iframe cross-domain issue with FF2x 
379         try
380         {
381                 this.createEvent("contentReady");
382         }
383         catch(e){}
384 };
385
386 YAHOO.widget.FlashAdapter.owners = YAHOO.widget.FlashAdapter.owners || {};
387
388 YAHOO.extend(YAHOO.widget.FlashAdapter, YAHOO.util.AttributeProvider,
389 {
390         /**
391          * The URL of the SWF file.
392          * @property _swfURL
393          * @type String
394          * @private
395          */
396         _swfURL: null,
397
398         /**
399          * The ID of the containing DIV.
400          * @property _containerID
401          * @type String
402          * @private
403          */
404         _containerID: null,
405
406         /**
407          * A reference to the embedded SWF file.
408          * @property _swf
409          * @private
410          */
411         _swf: null,
412
413         /**
414          * The id of this instance.
415          * @property _id
416          * @type String
417          * @private
418          */
419         _id: null,
420
421         /**
422          * Indicates whether the SWF has been initialized and is ready
423          * to communicate with JavaScript
424          * @property _initialized
425          * @type Boolean
426          * @private
427          */
428         _initialized: false,
429         
430         /**
431          * The initializing attributes are stored here until the SWF is ready.
432          * @property _attributes
433          * @type Object
434          * @private
435          */
436         _attributes: null, //the intializing attributes
437
438         /**
439          * Public accessor to the unique name of the FlashAdapter instance.
440          *
441          * @method toString
442          * @return {String} Unique name of the FlashAdapter instance.
443          */
444         toString: function()
445         {
446                 return "FlashAdapter " + this._id;
447         },
448
449         /**
450          * Nulls out the entire FlashAdapter instance and related objects and removes attached
451          * event listeners and clears out DOM elements inside the container. After calling
452          * this method, the instance reference should be expliclitly nulled by implementer,
453          * as in myChart = null. Use with caution!
454          *
455          * @method destroy
456          */
457         destroy: function()
458         {
459                 //kill the Flash Player instance
460                 if(this._swf)
461                 {
462                         var container = YAHOO.util.Dom.get(this._containerID);
463                         container.removeChild(this._swf);
464                 }
465                 
466                 var instanceName = this._id;
467                 
468                 //null out properties
469                 for(var prop in this)
470                 {
471                         if(YAHOO.lang.hasOwnProperty(this, prop))
472                         {
473                                 this[prop] = null;
474                         }
475                 }
476                 
477                 YAHOO.log("FlashAdapter instance destroyed: " + instanceName);
478         },
479
480         /**
481          * Embeds the SWF in the page and associates it with this instance.
482          *
483          * @method _embedSWF
484          * @private
485          */
486         _embedSWF: function(swfURL, containerID, swfID, version, backgroundColor, expressInstall, wmode, buttonSkin)
487         {
488                 //standard SWFObject embed
489                 var swfObj = new YAHOO.deconcept.SWFObject(swfURL, swfID, "100%", "100%", version, backgroundColor);
490
491                 if(expressInstall)
492                 {
493                         swfObj.useExpressInstall(expressInstall);
494                 }
495
496                 //make sure we can communicate with ExternalInterface
497                 swfObj.addParam("allowScriptAccess", "always");
498                 
499                 if(wmode)
500                 {
501                         swfObj.addParam("wmode", wmode);
502                 }
503                 
504                 swfObj.addParam("menu", "false");
505                 
506                 //again, a useful ExternalInterface trick
507                 swfObj.addVariable("allowedDomain", document.location.hostname);
508
509                 //tell the SWF which HTML element it is in
510                 swfObj.addVariable("elementID", swfID);
511
512                 // set the name of the function to call when the swf has an event
513                 swfObj.addVariable("eventHandler", "YAHOO.widget.FlashAdapter.eventHandler");
514                 if (buttonSkin) {
515                 swfObj.addVariable("buttonSkin", buttonSkin);
516                 }
517                 var container = YAHOO.util.Dom.get(containerID);
518                 var result = swfObj.write(container);
519                 if(result)
520                 {
521                         this._swf = YAHOO.util.Dom.get(swfID);
522                         YAHOO.widget.FlashAdapter.owners[swfID] = this;
523                 }
524                 else
525                 {
526                         YAHOO.log("Unable to load SWF " + swfURL);
527                 }
528         },
529
530         /**
531          * Handles or re-dispatches events received from the SWF.
532          *
533          * @method _eventHandler
534          * @private
535          */
536         _eventHandler: function(event)
537         {
538                 var type = event.type;
539                 switch(type)
540                 {
541                         case "swfReady":
542                                 this._loadHandler();
543                                 return;
544                         case "log":
545                                 YAHOO.log(event.message, event.category, this.toString());
546                                 return;
547                 }
548                 
549                 
550                 //be sure to return after your case or the event will automatically fire!
551                 this.fireEvent(type, event);
552         },
553
554         /**
555          * Called when the SWF has been initialized.
556          *
557          * @method _loadHandler
558          * @private
559          */
560         _loadHandler: function()
561         {
562                 this._initialized = false;
563                 this._initAttributes(this._attributes);
564                 this.setAttributes(this._attributes, true);
565                 
566                 this._initialized = true;
567                 this.fireEvent("contentReady");
568         },
569         
570         set: function(name, value)
571         {
572                 //save all the attributes in case the swf reloads
573                 //so that we can pass them in again
574                 this._attributes[name] = value;
575                 YAHOO.widget.FlashAdapter.superclass.set.call(this, name, value);
576         },
577         
578         /**
579          * Initializes the attributes.
580          *
581          * @method _initAttributes
582          * @private
583          */
584         _initAttributes: function(attributes)
585         {
586                 //should be overridden if other attributes need to be set up
587
588                 /**
589                  * @attribute wmode
590                  * @description Sets the window mode of the Flash Player control. May be
591                  *              "window", "opaque", or "transparent". Only available in the constructor
592                  *              because it may not be set after Flash Player has been embedded in the page.
593                  * @type String
594                  */
595                  
596                 /**
597                  * @attribute expressInstall
598                  * @description URL pointing to a SWF file that handles Flash Player's express
599                  *              install feature. Only available in the constructor because it may not be
600                  *              set after Flash Player has been embedded in the page.
601                  * @type String
602                  */
603
604                 /**
605                  * @attribute version
606                  * @description Minimum required version for the SWF file. Only available in the constructor because it may not be
607                  *              set after Flash Player has been embedded in the page.
608                  * @type String
609                  */
610
611                 /**
612                  * @attribute backgroundColor
613                  * @description The background color of the SWF. Only available in the constructor because it may not be
614                  *              set after Flash Player has been embedded in the page.
615                  * @type String
616                  */
617                  
618                 /**
619                  * @attribute altText
620                  * @description The alternative text to provide for screen readers and other assistive technology.
621                  * @type String
622                  */
623                 this.getAttributeConfig("altText",
624                 {
625                         method: this._getAltText
626                 });
627                 this.setAttributeConfig("altText",
628                 {
629                         method: this._setAltText
630                 });
631                 
632                 /**
633                  * @attribute swfURL
634                  * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be
635                  *              set after Flash Player has been embedded in the page.
636                  * @type String
637                  */
638                 this.getAttributeConfig("swfURL",
639                 {
640                         method: this._getSWFURL
641                 });
642         },
643         
644         /**
645          * Getter for swfURL attribute.
646          *
647          * @method _getSWFURL
648          * @private
649          */
650         _getSWFURL: function()
651         {
652                 return this._swfURL;
653         },
654         
655         /**
656          * Getter for altText attribute.
657          *
658          * @method _getAltText
659          * @private
660          */
661         _getAltText: function()
662         {
663                 return this._swf.getAltText();
664         },
665
666         /**
667          * Setter for altText attribute.
668          *
669          * @method _setAltText
670          * @private
671          */
672         _setAltText: function(value)
673         {
674                 return this._swf.setAltText(value);
675         }
676 });
677
678
679 /**
680  * Receives event messages from SWF and passes them to the correct instance
681  * of FlashAdapter.
682  *
683  * @method YAHOO.widget.FlashAdapter.eventHandler
684  * @static
685  * @private
686  */
687 YAHOO.widget.FlashAdapter.eventHandler = function(elementID, event)
688 {
689
690         if(!YAHOO.widget.FlashAdapter.owners[elementID])
691         {
692                 //fix for ie: if owner doesn't exist yet, try again in a moment
693                 setTimeout(function() { YAHOO.widget.FlashAdapter.eventHandler( elementID, event ); }, 0);
694         }
695         else
696         {
697                 YAHOO.widget.FlashAdapter.owners[elementID]._eventHandler(event);
698         }
699 };
700
701 /**
702  * The number of proxy functions that have been created.
703  * @static
704  * @private
705  */
706 YAHOO.widget.FlashAdapter.proxyFunctionCount = 0;
707
708 /**
709  * Creates a globally accessible function that wraps a function reference.
710  * Returns the proxy function's name as a string for use by the SWF through
711  * ExternalInterface.
712  *
713  * @method YAHOO.widget.FlashAdapter.createProxyFunction
714  * @static
715  * @private
716  */
717 YAHOO.widget.FlashAdapter.createProxyFunction = function(func)
718 {
719         var index = YAHOO.widget.FlashAdapter.proxyFunctionCount;
720         YAHOO.widget.FlashAdapter["proxyFunction" + index] = function()
721         {
722                 return func.apply(null, arguments);
723         };
724         YAHOO.widget.FlashAdapter.proxyFunctionCount++;
725         return "YAHOO.widget.FlashAdapter.proxyFunction" + index.toString();
726 };
727
728 /**
729  * Removes a function created with createProxyFunction()
730  * 
731  * @method YAHOO.widget.FlashAdapter.removeProxyFunction
732  * @static
733  * @private
734  */
735 YAHOO.widget.FlashAdapter.removeProxyFunction = function(funcName)
736 {
737         //quick error check
738         if(!funcName || funcName.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0)
739         {
740                 return;
741         }
742         
743         funcName = funcName.substr(26);
744         YAHOO.widget.FlashAdapter[funcName] = null;
745 };
746 /**
747  * The YUI Uploader Control
748  * @module uploader
749  * @description <p>YUI Uploader provides file upload functionality that goes beyond the basic browser-based methods. 
750  * Specifically, the YUI Uploader allows for:
751  * <ol>
752  * <li> Multiple file selection in a single "Open File" dialog.</li>
753  * <li> File extension filters to facilitate the user's selection.</li>
754  * <li> Progress tracking for file uploads.</li>
755  * <li> A range of file metadata: filename, size, date created, date modified, and author.</li>
756  * <li> A set of events dispatched on various aspects of the file upload process: file selection, upload progress, upload completion, etc.</li>
757  * <li> Inclusion of additional data in the file upload POST request.</li>
758  * <li> Faster file upload on broadband connections due to the modified SEND buffer size.</li>
759  * <li> Same-page server response upon completion of the file upload.</li>
760  * </ol>
761  * </p>
762  * @title Uploader
763  * @namespace YAHOO.widget
764  * @requires yahoo, dom, element, event
765  */
766 /**
767  * Uploader class for the YUI Uploader component.
768  *
769  * @namespace YAHOO.widget
770  * @class Uploader
771  * @uses YAHOO.widget.FlashAdapter
772  * @constructor
773  * @param containerId {HTMLElement} Container element for the Flash Player instance.
774  * @param buttonSkin {String} [optional]. If defined, the uploader is 
775  * rendered as a button. This parameter must provide the URL of a button
776  * skin sprite image. Acceptable types are: jpg, gif, png and swf. The 
777  * sprite is divided evenly into four sections along its height (e.g., if
778  * the sprite is 200 px tall, it's divided into four sections 50px each).
779  * Each section is used as a skin for a specific state of the button: top
780  * section is "up", second section is "over", third section is "down", and
781  * fourth section is "disabled". 
782  * If the parameter is not supplied, the uploader is rendered transparent,
783  * and it's the developer's responsibility to create a visible UI below it.
784  * @param forceTransparent {Boolean} This parameter, if true, forces the Flash
785  * UI to be rendered with wmode set to "transparent". This behavior is useful 
786  * in conjunction with non-rectangular button skins with PNG transparency. 
787  * The parameter is false by default, and ignored if no buttonSkin is defined.
788   */
789 YAHOO.widget.Uploader = function(containerId, buttonSkin, forceTransparent)
790 {
791         var newWMode = "window";
792
793         if (!(buttonSkin) || (buttonSkin && forceTransparent)) {
794                 newWMode = "transparent";
795         }
796
797         
798         YAHOO.widget.Uploader.superclass.constructor.call(this, YAHOO.widget.Uploader.SWFURL, containerId, {wmode:newWMode}, buttonSkin);
799
800         /**
801          * Fires when the mouse is pressed over the Uploader.
802          * Only fires when the Uploader UI is enabled and
803          * the render type is 'transparent'.
804          *
805          * @event mouseDown
806          * @param event.type {String} The event type
807          */
808         this.createEvent("mouseDown");
809         
810         /**
811          * Fires when the mouse is released over the Uploader.
812          * Only fires when the Uploader UI is enabled and
813          * the render type is 'transparent'.
814          *
815          * @event mouseUp
816          * @param event.type {String} The event type
817          */
818         this.createEvent("mouseUp");
819
820         /**
821          * Fires when the mouse rolls over the Uploader.
822          *
823          * @event rollOver
824          * @param event.type {String} The event type
825          */
826         this.createEvent("rollOver");
827         
828         /**
829          * Fires when the mouse rolls out of the Uploader.
830          *
831          * @event rollOut
832          * @param event.type {String} The event type
833          */
834         this.createEvent("rollOut");
835         
836         /**
837          * Fires when the uploader is clicked.
838          *
839          * @event click
840          * @param event.type {String} The event type
841          */
842         this.createEvent("click");
843         
844         /**
845          * Fires when the user has finished selecting files in the "Open File" dialog.
846          *
847          * @event fileSelect
848          * @param event.type {String} The event type
849          * @param event.fileList {Object} A dictionary of objects with file information
850          * @param event.fileList[].size {Number} File size in bytes for a specific file in fileList
851          * @param event.fileList[].cDate {Date} Creation date for a specific file in fileList
852          * @param event.fileList[].mDate {Date} Modification date for a specific file in fileList
853          * @param event.fileList[].name {String} File name for a specific file in fileList
854          * @param event.fileList[].id {String} Unique file id of a specific file in fileList
855          */
856         this.createEvent("fileSelect");
857
858         /**
859          * Fires when an upload of a specific file has started.
860          *
861          * @event uploadStart
862          * @param event.type {String} The event type
863          * @param event.id {String} The id of the file that's started to upload
864          */
865         this.createEvent("uploadStart");
866
867         /**
868          * Fires when new information about the upload progress for a specific file is available.
869          *
870          * @event uploadProgress
871          * @param event.type {String} The event type
872          * @param event.id {String} The id of the file with which the upload progress data is associated
873          * @param bytesLoaded {Number} The number of bytes of the file uploaded so far
874          * @param bytesTotal {Number} The total size of the file
875          */
876         this.createEvent("uploadProgress");
877         
878         /**
879          * Fires when an upload for a specific file is cancelled.
880          *
881          * @event uploadCancel
882          * @param event.type {String} The event type
883          * @param event.id {String} The id of the file with which the upload has been cancelled.
884          */     
885         this.createEvent("uploadCancel");
886
887         /**
888          * Fires when an upload for a specific file is complete.
889          *
890          * @event uploadComplete
891          * @param event.type {String} The event type
892          * @param event.id {String} The id of the file for which the upload has been completed.
893          */     
894         this.createEvent("uploadComplete");
895
896         /**
897          * Fires when the server sends data in response to a completed upload.
898          *
899          * @event uploadCompleteData
900          * @param event.type {String} The event type
901          * @param event.id {String} The id of the file for which the upload has been completed.
902          * @param event.data {String} The raw data returned by the server in response to the upload.
903          */     
904         this.createEvent("uploadCompleteData");
905         
906         /**
907          * Fires when an upload error occurs.
908          *
909          * @event uploadError
910          * @param event.type {String} The event type
911          * @param event.id {String} The id of the file that was being uploaded when the error has occurred.
912          * @param event.status {String} The status message associated with the error.
913          */     
914         this.createEvent("uploadError");
915 }
916
917 /**
918  * Location of the Uploader SWF
919  *
920  * @property Chart.SWFURL
921  * @private
922  * @static
923  * @final
924  * @default "assets/uploader.swf"
925  */
926 YAHOO.widget.Uploader.SWFURL = "assets/uploader.swf";
927
928 YAHOO.extend(YAHOO.widget.Uploader, YAHOO.widget.FlashAdapter,
929 {       
930 /**
931  * Starts the upload of the file specified by fileID to the location specified by uploadScriptPath.
932  *
933  * @param fileID {String} The id of the file to start uploading.
934  * @param uploadScriptPath {String} The URL of the upload location.
935  * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
936  * @param vars {Object} The object containing variables to be sent in the same request as the file upload.
937  * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default.
938  * </code> 
939  */
940         upload: function(fileID, uploadScriptPath, method, vars, fieldName)
941         {
942                 this._swf.upload(fileID, uploadScriptPath, method, vars, fieldName);
943         },
944         
945 /**
946  * Starts the upload of the files specified by fileIDs, or adds them to a currently running queue. The upload queue is automatically managed.
947  *
948  * @param fileIDs {Array} The ids of the files to start uploading.
949  * @param uploadScriptPath {String} The URL of the upload location.
950  * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
951  * @param vars {Object} The object containing variables to be sent in the same request as the file upload.
952  * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default.
953  * </code> 
954  */
955         uploadThese: function(fileIDs, uploadScriptPath, method, vars, fieldName)
956         {
957                 this._swf.uploadThese(fileIDs, uploadScriptPath, method, vars, fieldName);
958         },
959         
960 /**
961  * Starts uploading all files in the queue. If this function is called, the upload queue is automatically managed.
962  *
963  * @param uploadScriptPath {String} The URL of the upload location.
964  * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
965  * @param vars {Object} The object containing variables to be sent in the same request as the file upload.
966  * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default.
967  * </code> 
968  */
969         uploadAll: function(uploadScriptPath, method, vars, fieldName)
970         {
971                 this._swf.uploadAll(uploadScriptPath, method, vars, fieldName);
972         },
973
974 /**
975  * Cancels the upload of a specified file. If no file id is specified, all ongoing uploads are cancelled.
976  *
977  * @param fileID {String} The ID of the file whose upload should be cancelled.
978  */
979         cancel: function(fileID)
980         {
981                 this._swf.cancel(fileID);
982         },
983
984 /**
985  * Clears the list of files queued for upload.
986  *
987  */
988         clearFileList: function()
989         {
990                 this._swf.clearFileList();
991         },
992         
993 /**
994  * Removes the specified file from the upload queue. 
995  *
996  * @param fileID {String} The id of the file to remove from the upload queue. 
997  */
998         removeFile: function (fileID) 
999         {
1000                 this._swf.removeFile(fileID);
1001         },
1002
1003 /**
1004  * Turns the logging functionality on.
1005  * Uses Flash internal trace logging, as well as YUI Logger, if available.
1006  *
1007  * @param allowLogging {Boolean} If true, logs are output; otherwise, no logs are produced.
1008  */
1009     setAllowLogging: function (allowLogging)
1010     {
1011         this._swf.setAllowLogging(allowLogging);
1012     },
1013
1014 /**
1015  * Sets the number of simultaneous uploads when using uploadAll()
1016  * The minimum value is 1, and maximum value is 5. The default value is 2.
1017  *
1018  * @param simUploadLimit {int} Number of simultaneous uploads, between 1 and 5.
1019  */
1020     setSimUploadLimit : function (simUploadLimit)
1021     {
1022        this._swf.setSimUploadLimit(simUploadLimit);
1023     },
1024
1025 /**
1026  * Sets the flag allowing users to select multiple files for the upload.
1027  *
1028  * @param allowMultipleFiles {Boolean} If true, multiple files can be selected. False by default.
1029  */     
1030     setAllowMultipleFiles : function (allowMultipleFiles) 
1031     {
1032        this._swf.setAllowMultipleFiles(allowMultipleFiles);
1033     },
1034
1035 /**
1036  * Sets the file filters for the "Browse" dialog.
1037  *
1038  *  @param newFilterArray An array of sets of key-value pairs of the form
1039  *  {extensions: extensionString, description: descriptionString, [optional]macType: macTypeString}
1040  *  The extensions string is a semicolon-delimited list of elements of the form "*.xxx", 
1041  *  e.g. "*.jpg;*.gif;*.png". 
1042  */       
1043     setFileFilters : function (fileFilters) 
1044     {
1045        this._swf.setFileFilters(fileFilters);
1046     },
1047
1048         /**
1049          * Enables the mouse events on the Uploader.
1050          * If the uploader is being rendered as a button,
1051          * then the button's skin is set to "up"
1052          * (first section of the button skin sprite).
1053          *
1054          */
1055         enable : function ()
1056         {
1057                 this._swf.enable();
1058         },
1059
1060         /**
1061          * Disables the mouse events on the Uploader.
1062          * If the uploader is being rendered as a button,
1063          * then the button's skin is set to "disabled"
1064          * (fourth section of the button skin sprite).
1065          *
1066          */
1067         disable : function () 
1068         {
1069                 this._swf.disable();
1070         }
1071 });
1072 YAHOO.register("uploader", YAHOO.widget.Uploader, {version: "2.8.0r4", build: "2449"});