/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.6.0
*/
/*extern ActiveXObject, __flash_unloadHandler, __flash_savedUnloadHandler */
/*!
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
var deconcept = deconcept || {};
if(typeof deconcept.util == "undefined" || !deconcept.util)
{
deconcept.util = {};
}
if(typeof deconcept.SWFObjectUtil == "undefined" || !deconcept.SWFObjectUtil)
{
deconcept.SWFObjectUtil = {};
}
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey)
{
if(!document.getElementById) { return; }
this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params = {};
this.variables = {};
this.attributes = [];
if(swf) { this.setAttribute('swf', swf); }
if(id) { this.setAttribute('id', id); }
if(w) { this.setAttribute('width', w); }
if(h) { this.setAttribute('height', h); }
if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
if (!window.opera && document.all && this.installedVer.major > 7)
{
// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
deconcept.SWFObject.doPrepUnload = true;
}
if(c)
{
this.addParam('bgcolor', c);
}
var q = quality ? quality : 'high';
this.addParam('quality', q);
this.setAttribute('useExpressInstall', false);
this.setAttribute('doExpressInstall', false);
var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
this.setAttribute('xiRedirectUrl', xir);
this.setAttribute('redirectUrl', '');
if(redirectUrl)
{
this.setAttribute('redirectUrl', redirectUrl);
}
};
deconcept.SWFObject.prototype =
{
useExpressInstall: function(path)
{
this.xiSWFPath = !path ? "expressinstall.swf" : path;
this.setAttribute('useExpressInstall', true);
},
setAttribute: function(name, value){
this.attributes[name] = value;
},
getAttribute: function(name){
return this.attributes[name];
},
addParam: function(name, value){
this.params[name] = value;
},
getParams: function(){
return this.params;
},
addVariable: function(name, value){
this.variables[name] = value;
},
getVariable: function(name){
return this.variables[name];
},
getVariables: function(){
return this.variables;
},
getVariablePairs: function(){
var variablePairs = [];
var key;
var variables = this.getVariables();
for(key in variables)
{
if(variables.hasOwnProperty(key))
{
variablePairs[variablePairs.length] = key +"="+ variables[key];
}
}
return variablePairs;
},
getSWFHTML: function() {
var swfNode = "";
var params = {};
var key = "";
var pairs = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
if (this.getAttribute("doExpressInstall")) {
this.addVariable("MMplayerType", "PlugIn");
this.setAttribute('swf', this.xiSWFPath);
}
swfNode = '
* @title Uploader
* @namespace YAHOO.widget
* @requires yahoo, dom, element, event
*/
/**
* Uploader class for the YUI Uploader component.
*
* @namespace YAHOO.widget
* @class Uploader
* @uses YAHOO.widget.FlashAdapter
* @constructor
* @param containerId {HTMLElement} Container element for the Flash Player instance.
* @param buttonSkin {String} [optional]. If defined, the uploader is
* rendered as a button. This parameter must provide the URL of a button
* skin sprite image. Acceptable types are: jpg, gif, png and swf. The
* sprite is divided evenly into four sections along its height (e.g., if
* the sprite is 200 px tall, it's divided into four sections 50px each).
* Each section is used as a skin for a specific state of the button: top
* section is "up", second section is "over", third section is "down", and
* fourth section is "disabled".
* If the parameter is not supplied, the uploader is rendered transparent,
* and it's the developer's responsibility to create a visible UI below it.
*/
YAHOO.widget.Uploader = function(containerId, buttonSkin)
{
var newWMode = "window";
if (!(buttonSkin)) {
newWMode = "transparent";
}
YAHOO.widget.Uploader.superclass.constructor.call(this, YAHOO.widget.Uploader.SWFURL, containerId, {wmode:newWMode}, buttonSkin);
this._swf.tabIndex="1";
/**
* Fires when the mouse is pressed over the Uploader.
* Only fires when the Uploader UI is enabled and
* the render type is 'transparent'.
*
* @event mouseDown
* @param event.type {String} The event type
*/
this.createEvent("mouseDown");
/**
* Fires when the mouse is released over the Uploader.
* Only fires when the Uploader UI is enabled and
* the render type is 'transparent'.
*
* @event mouseUp
* @param event.type {String} The event type
*/
this.createEvent("mouseUp");
/**
* Fires when the mouse rolls over the Uploader.
*
* @event rollOver
* @param event.type {String} The event type
*/
this.createEvent("rollOver");
/**
* Fires when the mouse rolls out of the Uploader.
*
* @event rollOut
* @param event.type {String} The event type
*/
this.createEvent("rollOut");
/**
* Fires when the uploader is clicked.
*
* @event click
* @param event.type {String} The event type
*/
this.createEvent("click");
/**
* Fires when the user has finished selecting files in the "Open File" dialog.
*
* @event fileSelect
* @param event.type {String} The event type
* @param event.fileList {Array} An array of objects with file information
* @param event.fileList[].size {Number} File size in bytes for a specific file in fileList
* @param event.fileList[].cDate {Date} Creation date for a specific file in fileList
* @param event.fileList[].mDate {Date} Modification date for a specific file in fileList
* @param event.fileList[].name {String} File name for a specific file in fileList
* @param event.fileList[].id {String} Unique file id of a specific file in fileList
*/
this.createEvent("fileSelect");
/**
* Fires when an upload of a specific file has started.
*
* @event uploadStart
* @param event.type {String} The event type
* @param event.id {String} The id of the file that's started to upload
*/
this.createEvent("uploadStart");
/**
* Fires when new information about the upload progress for a specific file is available.
*
* @event uploadProgress
* @param event.type {String} The event type
* @param event.id {String} The id of the file with which the upload progress data is associated
* @param bytesLoaded {Number} The number of bytes of the file uploaded so far
* @param bytesTotal {Number} The total size of the file
*/
this.createEvent("uploadProgress");
/**
* Fires when an upload for a specific file is cancelled.
*
* @event uploadCancel
* @param event.type {String} The event type
* @param event.id {String} The id of the file with which the upload has been cancelled.
*/
this.createEvent("uploadCancel");
/**
* Fires when an upload for a specific file is complete.
*
* @event uploadComplete
* @param event.type {String} The event type
* @param event.id {String} The id of the file for which the upload has been completed.
*/
this.createEvent("uploadComplete");
/**
* Fires when the server sends data in response to a completed upload.
*
* @event uploadCompleteData
* @param event.type {String} The event type
* @param event.id {String} The id of the file for which the upload has been completed.
* @param event.data {String} The raw data returned by the server in response to the upload.
*/
this.createEvent("uploadCompleteData");
/**
* Fires when an upload error occurs.
*
* @event uploadError
* @param event.type {String} The event type
* @param event.id {String} The id of the file that was being uploaded when the error has occurred.
* @param event.status {String} The status message associated with the error.
*/
this.createEvent("uploadError");
}
/**
* Location of the Uploader SWF
*
* @property Chart.SWFURL
* @private
* @static
* @final
* @default "assets/uploader.swf"
*/
YAHOO.widget.Uploader.SWFURL = "assets/uploader.swf";
YAHOO.extend(YAHOO.widget.Uploader, YAHOO.widget.FlashAdapter,
{
/**
* Starts the upload of the file specified by fileID to the location specified by uploadScriptPath.
*
* @param fileID {String} The id of the file to start uploading.
* @param uploadScriptPath {String} The URL of the upload location.
* @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
* @param vars {Object} The object containing variables to be sent in the same request as the file upload.
* @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default.
* @param headers {Object} An object containing variables that should be set as headers in the POST request. The following header names
* cannot be used:
*
* Accept-Charset, Accept-Encoding, Accept-Ranges, Age, Allow, Allowed, Authorization, Charge-To, Connect, Connection,
* Content-Length, Content-Location, Content-Range, Cookie, Date, Delete, ETag, Expect, Get, Head, Host, Keep-Alive,
* Last-Modified, Location, Max-Forwards, Options, Post, Proxy-Authenticate, Proxy-Authorization, Proxy-Connection,
* Public, Put, Range, Referer, Request-Range, Retry-After, Server, TE, Trace, Trailer, Transfer-Encoding, Upgrade,
* URI, User-Agent, Vary, Via, Warning, WWW-Authenticate, x-flash-version.
*
*/
upload: function(fileID, uploadScriptPath, method, vars, fieldName)
{
this._swf.upload(fileID, uploadScriptPath, method, vars, fieldName);
},
/**
* Starts uploading all files in the queue. If this function is called, the upload queue is automatically managed.
*
* @param uploadScriptPath {String} The URL of the upload location.
* @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
* @param vars {Object} The object containing variables to be sent in the same request as the file upload.
* @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default.
* @param headers {Object} An object containing variables that should be set as headers in the POST request. The following header names
* cannot be used:
*
* Accept-Charset, Accept-Encoding, Accept-Ranges, Age, Allow, Allowed, Authorization, Charge-To, Connect, Connection,
* Content-Length, Content-Location, Content-Range, Cookie, Date, Delete, ETag, Expect, Get, Head, Host, Keep-Alive,
* Last-Modified, Location, Max-Forwards, Options, Post, Proxy-Authenticate, Proxy-Authorization, Proxy-Connection,
* Public, Put, Range, Referer, Request-Range, Retry-After, Server, TE, Trace, Trailer, Transfer-Encoding, Upgrade,
* URI, User-Agent, Vary, Via, Warning, WWW-Authenticate, x-flash-version.
*
*/
uploadAll: function(uploadScriptPath, method, vars, fieldName)
{
this._swf.uploadAll(uploadScriptPath, method, vars, fieldName);
},
/**
* Cancels the upload of a specified file. If no file id is specified, all ongoing uploads are cancelled.
*
* @param fileID {String} The ID of the file whose upload should be cancelled.
*/
cancel: function(fileID)
{
this._swf.cancel(fileID);
},
/**
* Clears the list of files queued for upload.
*
*/
clearFileList: function()
{
this._swf.clearFileList();
},
/**
* Removes the specified file from the upload queue.
*
* @param fileID {String} The id of the file to remove from the upload queue.
*/
removeFile: function (fileID)
{
this._swf.removeFile(fileID);
},
/**
* Turns the logging functionality on.
* Uses Flash internal trace logging, as well as YUI Logger, if available.
*
* @param allowLogging {Boolean} If true, logs are output; otherwise, no logs are produced.
*/
setAllowLogging: function (allowLogging)
{
this._swf.setAllowLogging(allowLogging);
},
/**
* Sets the number of simultaneous uploads when using uploadAll()
* The minimum value is 1, and maximum value is 5. The default value is 2.
*
* @param simUploadLimit {int} Number of simultaneous uploads, between 1 and 5.
*/
setSimUploadLimit : function (simUploadLimit)
{
this._swf.setSimUploadLimit(simUploadLimit);
},
/**
* Sets the flag allowing users to select multiple files for the upload.
*
* @param allowMultipleFiles {Boolean} If true, multiple files can be selected. False by default.
*/
setAllowMultipleFiles : function (allowMultipleFiles)
{
this._swf.setAllowMultipleFiles(allowMultipleFiles);
},
/**
* Sets the file filters for the "Browse" dialog.
*
* @param newFilterArray An array of sets of key-value pairs of the form
* {extensions: extensionString, description: descriptionString, [optional]macType: macTypeString}
* The extensions string is a semicolon-delimited list of elements of the form "*.xxx",
* e.g. "*.jpg;*.gif;*.png".
*/
setFileFilters : function (fileFilters)
{
this._swf.setFileFilters(fileFilters);
},
/**
* Enables the mouse events on the Uploader.
* If the uploader is being rendered as a button,
* then the button's skin is set to "up"
* (first section of the button skin sprite).
*
*/
enable : function ()
{
this._swf.enable();
},
/**
* Disables the mouse events on the Uploader.
* If the uploader is being rendered as a button,
* then the button's skin is set to "disabled"
* (fourth section of the button skin sprite).
*
*/
disable : function ()
{
this._swf.disable();
}
});
YAHOO.register("uploader", YAHOO.widget.Uploader, {version: "2.6.0", build: "1321"});