uploader-flash.js revision 66900b43227bf441b6a6b1084af2c96ce2c747c8
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * This module provides a UI for file selection and multiple file upload capability using
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Flash as a transport engine.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The supported features include: automatic upload queue management, upload progress
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * tracking, server response retrieval and error reporting.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @module uploader-flash
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovichvar substitute = Y.substitute,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich UploaderQueue = Y.Uploader.Queue;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * This module provides a UI for file selection and multiple file upload capability
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * using Flash as a transport engine.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @class UploaderFlash
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @extends Widget
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @constructor
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovichfunction UploaderFlash(config) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich UploaderFlash.superclass.constructor.apply ( this, arguments );
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen RabinovichY.UploaderFlash = Y.extend(UploaderFlash, Y.Widget, {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Stored reference to the instance of SWF used to host the
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Flash uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property _swfReference
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {SWF}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _swfReference: null,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Stored reference to the instance of Uploader.Queue used to manage
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the upload process.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property _uploaderQueue
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Y.Uploader.Queue}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _uploaderQueue: null,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Stored value of the unique id for the container that holds the
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Flash uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property _swfContainerId
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {String}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _swfContainerId: null,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Y.UploaderFlash prototype
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Construction logic executed during UploaderFlash instantiation.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method initializer
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich initializer : function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Assign a unique id for the SWF container
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfContainerId = Y.guid("uploader");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Publish available events
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("fileselect");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("uploadprogress");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("totaluploadprogress");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("uploadcomplete");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("alluploadscomplete");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.publish("uploaderror");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Handles and retransmits events fired by `Y.File` and `Y.Uploader.Queue`.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method _uploadEventHandler
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param event The event dispatched during the upload process.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @private
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _uploadEventHandler : function (event) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich switch (event.type) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich case "file:uploadprogress":
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("uploadprogress", event);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich break;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich case "uploaderqueue:totaluploadprogress":
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("totaluploadprogress", event);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich break;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich case "file:uploadcomplete":
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("uploadcomplete", event);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich break;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich case "uploaderqueue:alluploadscomplete":
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("alluploadscomplete", event);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich break;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich case "uploaderqueue:uploaderror":
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("uploaderror", event);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich break;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Syncs the state of the `multipleFiles` attribute between this class
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * and the Flash uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method _setMultipleFiles
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @private
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _setMultipleFiles : function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich if (this._swfReference) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfReference.callSWF("setAllowMultipleFiles", [this.get("multipleFiles")]);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Syncs the state of the `fileFilters` attribute between this class
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * and the Flash uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method _setFileFilters
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @private
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _setFileFilters : function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich if (this._swfReference && this.get("fileFilters") != null) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfReference.callSWF("setFileFilters", [this.get("fileFilters")]);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Adjusts the content of the `fileList` based on the results of file selection
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * and the `appendNewFiles` attribute. If the `appendNewFiles` attribute is true,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * then selected files are appended to the existing list; otherwise, the list is
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * cleared and populated with the newly selected files.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method _updateFileList
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param ev {Event} The file selection event received from the uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @private
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich _updateFileList : function (ev) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var newfiles = ev.fileList,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileConfObjects = [],
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich parsedFiles = [],
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich swfRef = this._swfReference;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich Y.each(newfiles, function (value) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var newFileConf = {};
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.id = value.fileId;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.name = value.fileReference.name;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.size = value.fileReference.size;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.type = value.fileReference.type;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.dateCreated = value.fileReference.creationDate;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.dateModified = value.fileReference.modificationDate;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich newFileConf.uploader = swfRef;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileConfObjects.push(newFileConf);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich });
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich Y.each(fileConfObjects, function (value) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich parsedFiles.push(new Y.File(value));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich });
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.fire("fileselect", {fileList: parsedFiles});
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var oldfiles = this.get("fileList");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.set("fileList",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles );
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Create the DOM structure for the UploaderFlash.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * UploaderFlash's DOM structure consists of two layers: the base "Select Files"
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * button that can be replaced by the developer's widget of choice; and a transparent
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Flash overlay positoned above the button that captures all input events.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method renderUI
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich renderUI : function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var contentBox = this.get('contentBox');
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich contentBox.append(this.get("selectFilesButton"));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich contentBox.append(Y.Node.create(substitute(UploaderFlash.FLASH_CONTAINER,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich {swfContainerId: this._swfContainerId})));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var flashContainer = Y.one("#" + this._swfContainerId);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var params = {version: "10.0.45",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fixedAttributes: {wmode: "transparent",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich allowScriptAccess:"always",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich allowNetworking:"all",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich scale: "noscale"},
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich };
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfReference = new Y.SWF(flashContainer, this.get("swfURL"), params);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Binds to the UploaderFlash UI and subscribes to the necessary events.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The binding is set to occur once the Flash player instance is ready
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * (as indicated by the `swfReady` event.)
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method bindUI
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich bindUI : function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfReference.on("swfReady", function () {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._setMultipleFiles();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._setFileFilters();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.after("multipleFilesChange", this._setMultipleFiles, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this.after("fileFiltersChange", this._setFileFilters, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._swfReference.on("fileselect", this._updateFileList, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Starts the upload of a specific file.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method upload
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param file {Y.File} Reference to the instance of the file to be uploaded.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param url {String} The URL to upload the file to.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * If not specified, the values from the attribute `postVarsPerFile` are used instead.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich upload : function (file, url, postvars) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var uploadURL = url || this.get("uploadURL"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich postVars = postvars || this.get("postVarsPerFile");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich if (file instanceof Y.File) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue = new UploaderQueue({simUploads: this.get("simLimit"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich errorAction: "restart",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileList: [file],
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadURL: uploadURL,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich perFileParameters: postVars
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich });
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("totaluploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadcomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("alluploadscomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.set("fileFieldName", this.get("fileFieldName"));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.startUpload();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Starts the upload of all files on the file list, using an automated queue.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method uploadAll
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param url {String} The URL to upload the files to.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * If not specified, the values from the attribute `postVarsPerFile` are used instead.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadAll : function (url, postvars) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Starting upload of all selected files.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich console.log("Starting upload of all selected files");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var uploadURL = url || this.get("uploadURL"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich postVars = postvars || this.get("postVarsPerFile");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Creating a new upload queue with the current file list
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich console.log("Creating a new instance of upload queue");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue = new UploaderQueue({simUploads: this.get("simLimit"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich errorAction: "restart",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileList: this.get("fileList"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadURL: uploadURL,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich perFileParameters: postVars
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich });
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Subscribing to events
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich console.log("Subscribing to uploaderqueue's events");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("totaluploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadcomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("alluploadscomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.set("fileFieldName", this.get("fileFieldName"));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich // Starting the upload.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich console.log("Starting upload in the queue");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.startUpload();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Starts the upload of the files specified in the first argument, using an automated queue.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @method uploadThese
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param files {Array} The list of files to upload.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param url {String} The URL to upload the files to.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * If not specified, the values from the attribute `postVarsPerFile` are used instead.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadThese : function (files, url, postvars) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich var uploadURL = url || this.get("uploadURL"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich postVars = postvars || this.get("postVarsPerFile");
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue = new UploaderQueue({simUploads: this.get("simLimit"),
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich errorAction: "restart",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileList: files,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadURL: uploadURL,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich perFileParameters: postVars
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich });
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("totaluploadprogress", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploadcomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("alluploadscomplete", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.on("uploaderror", this._uploadEventHandler, this);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.set("fileFieldName", this.get("fileFieldName"));
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich this._uploaderQueue.startUpload();
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich},
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich{
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The template for the Flash player container. Since the Flash player container needs
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * to completely overlay the &lquot;Select Files&rqot; control, it's positioned absolutely,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * with width and height set to 100% of the parent.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property FLASH_CONTAINER
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {String}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @static
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich FLASH_CONTAINER: "<div id='{swfContainerId}' style='position:absolute; top:0px; left: 0px; width:100%; height:100%'></div>",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The identity of the widget.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property NAME
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type String
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default 'uploaderflash'
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @readOnly
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @static
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich NAME: "uploader",
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * Static property used to define the default attribute configuration of
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the Widget.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @property ATTRS
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Object}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @protected
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @static
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich ATTRS: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The widget that serves as the &lquot;Select Files&rquot; control for the file uploader
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute selectFilesButton
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Node | Widget}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default A standard HTML button.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich selectFilesButton : {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: Y.Node.create("<button type='button' style='height:100%;width:100%'>Select Files</button>")
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * A Boolean indicating whether multiple file selection is enabled.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute multipleFiles
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Boolean}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default false
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich multipleFiles: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: false
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * An array indicating what fileFilters should be applied to the file
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * selection dialog. Each element in the array should be an object with
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the following key-value pairs:
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * description : String
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich extensions: String of the form &lquot;*.ext1;*.ext2;*.ext3;...&rquot;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute fileFilters
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Array}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default null
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileFilters: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: null
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * A String specifying what should be the POST field name for the file
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * content in the upload request.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute fileFieldName
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {String}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default Filedata
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileFieldName: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: "Filedata"
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * A Boolean indicating whether newly selected files should be appended
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * to the existing file list, or whether they should replace it.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute appendNewFiles
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Boolean}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default true
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich appendNewFiles : {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: true
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The number of files that can be uploaded
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * simultaneously if the automatic queue management
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * is used. This value can be in the range between 2
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * and 5.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute simLimit
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Number}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default 2
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich simLimit: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: 2,
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich validator: function (val, name) {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich return (val >= 2 && val <= 5);
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The array of files to be uploaded. All elements in the array
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * must be instances of `Y.File` and be instantiated with a `fileId`
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * retrieved from an instance of the uploader.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute fileList
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Array}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default []
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich fileList: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: []
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * An object, keyed by `fileId`, containing sets of key-value pairs
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * that should be passed as POST variables along with each corresponding
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * file. This attribute is only used if no POST variables are specifed
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * in the upload request (only possible when calling the `upload()` method.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute postVarsPerFile
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {Object}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default {}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich postVarsPerFile: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: {}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The URL to POST the file upload requests to.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute uploadURL
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {String}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default ""
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich uploadURL: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: ""
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich },
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich /**
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * The URL to the SWF file of the flash uploader. A copy local to
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * the server that hosts the page on which the uploader appears is
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * recommended.
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich *
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @attribute swfURL
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @type {String}
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich * @default "CDN Prefix + assets/flashuploader.swf"
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich */
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich swfURL: {
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich value: "assets/flashuploader.swf"
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich }
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich});
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen RabinovichY.UploaderFlash.Queue = UploaderQueue;
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich