[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/uploader-flash/ -> uploader-flash-debug.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('uploader-flash', function (Y, NAME) {
   9  
  10  /**
  11  * This module provides a UI for file selection and multiple file upload capability using
  12  * Flash as a transport engine.
  13  * The supported features include: automatic upload queue management, upload progress
  14  * tracking, file filtering, server response retrieval and error reporting.
  15  *
  16  * @module uploader-flash
  17  * @deprecated
  18  */
  19  
  20  // Shorthands for external modules
  21  var substitute            = Y.Lang.sub,
  22      UploaderQueue         = Y.Uploader.Queue;
  23  
  24  
  25  /**
  26   * Embed a Flash applications in a standard manner and communicate with it
  27   * via External Interface.
  28   * @module swf
  29   */
  30  
  31      var Event = Y.Event,
  32          SWFDetect = Y.SWFDetect,
  33          Lang = Y.Lang,
  34          uA = Y.UA,
  35          Node = Y.Node,
  36          Escape = Y.Escape,
  37  
  38          // private
  39          FLASH_CID = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
  40          FLASH_TYPE = "application/x-shockwave-flash",
  41          FLASH_VER = "10.0.22",
  42          EXPRESS_INSTALL_URL = "http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?" + Math.random(),
  43          EVENT_HANDLER = "SWF.eventHandler",
  44          possibleAttributes = {align:"", allowFullScreen:"", allowNetworking:"", allowScriptAccess:"", base:"", bgcolor:"", loop:"", menu:"", name:"", play: "", quality:"", salign:"", scale:"", tabindex:"", wmode:""};
  45  
  46          /**
  47           * The SWF utility is a tool for embedding Flash applications in HTML pages.
  48           * @module swf
  49           * @title SWF Utility
  50           * @requires event-custom, node, swfdetect
  51           */
  52  
  53          /**
  54           * Creates the SWF instance and keeps the configuration data
  55           *
  56           * @class SWF
  57           * @uses Y.Event.Target
  58           * @constructor
  59           * @param {String|HTMLElement} id The id of the element, or the element itself that the SWF will be inserted into.
  60           *        The width and height of the SWF will be set to the width and height of this container element.
  61           * @param {String} swfURL The URL of the SWF to be embedded into the page.
  62           * @param {Object} p_oAttributes (optional) Configuration parameters for the Flash application and values for Flashvars
  63           *        to be passed to the SWF. The p_oAttributes object allows the following additional properties:
  64           *        <dl>
  65           *          <dt>version : String</dt>
  66           *          <dd>The minimum version of Flash required on the user's machine.</dd>
  67           *          <dt>fixedAttributes : Object</dt>
  68           *          <dd>An object literal containing one or more of the following String keys and their values: <code>align,
  69           *              allowFullScreen, allowNetworking, allowScriptAccess, base, bgcolor, menu, name, quality, salign, scale,
  70           *              tabindex, wmode.</code> event from the thumb</dd>
  71           *        </dl>
  72           */
  73  
  74  function SWF (p_oElement /*:String*/, swfURL /*:String*/, p_oAttributes /*:Object*/ ) {
  75  
  76      this._id = Y.guid("yuiswf");
  77  
  78  
  79      var _id = this._id;
  80      var oElement = Node.one(p_oElement);
  81  
  82      var p_oAttributes = p_oAttributes || {};
  83  
  84      var flashVersion = p_oAttributes.version || FLASH_VER;
  85  
  86      var flashVersionSplit = (flashVersion + '').split(".");
  87      var isFlashVersionRight = SWFDetect.isFlashVersionAtLeast(parseInt(flashVersionSplit[0], 10), parseInt(flashVersionSplit[1], 10), parseInt(flashVersionSplit[2], 10));
  88      var canExpressInstall = (SWFDetect.isFlashVersionAtLeast(8,0,0));
  89      var shouldExpressInstall = canExpressInstall && !isFlashVersionRight && p_oAttributes.useExpressInstall;
  90      var flashURL = (shouldExpressInstall)?EXPRESS_INSTALL_URL:swfURL;
  91      var objstring = '<object ';
  92      var w, h;
  93      var flashvarstring = "yId=" + Y.id + "&YUISwfId=" + _id + "&YUIBridgeCallback=" + EVENT_HANDLER + "&allowedDomain=" + document.location.hostname;
  94  
  95      Y.SWF._instances[_id] = this;
  96      if (oElement && (isFlashVersionRight || shouldExpressInstall) && flashURL) {
  97          objstring += 'id="' + _id + '" ';
  98          if (uA.ie) {
  99              objstring += 'classid="' + FLASH_CID + '" ';
 100          } else {
 101              objstring += 'type="' + FLASH_TYPE + '" data="' + Escape.html(flashURL) + '" ';
 102          }
 103  
 104          w = "100%";
 105          h = "100%";
 106  
 107          objstring += 'width="' + w + '" height="' + h + '">';
 108  
 109          if (uA.ie) {
 110              objstring += '<param name="movie" value="' + Escape.html(flashURL) + '"/>';
 111          }
 112  
 113          for (var attribute in p_oAttributes.fixedAttributes) {
 114              if (possibleAttributes.hasOwnProperty(attribute)) {
 115                  objstring += '<param name="' + Escape.html(attribute) + '" value="' + Escape.html(p_oAttributes.fixedAttributes[attribute]) + '"/>';
 116              }
 117          }
 118  
 119          for (var flashvar in p_oAttributes.flashVars) {
 120              var fvar = p_oAttributes.flashVars[flashvar];
 121              if (Lang.isString(fvar)) {
 122                  flashvarstring += "&" + Escape.html(flashvar) + "=" + Escape.html(encodeURIComponent(fvar));
 123              }
 124          }
 125  
 126          if (flashvarstring) {
 127              objstring += '<param name="flashVars" value="' + flashvarstring + '"/>';
 128          }
 129  
 130          objstring += "</object>";
 131          //using innerHTML as setHTML/setContent causes some issues with ExternalInterface for IE versions of the player
 132          oElement.set("innerHTML", objstring);
 133  
 134          this._swf = Node.one("#" + _id);
 135      } else {
 136          /**
 137           * Fired when the Flash player version on the user's machine is
 138           * below the required value.
 139           *
 140           * @event wrongflashversion
 141           */
 142          var event = {};
 143          event.type = "wrongflashversion";
 144          this.publish("wrongflashversion", {fireOnce:true});
 145          this.fire("wrongflashversion", event);
 146      }
 147  }
 148  
 149  /**
 150   * @private
 151   * The static collection of all instances of the SWFs on the page.
 152   * @property _instances
 153   * @type Object
 154   */
 155  
 156  SWF._instances = SWF._instances || {};
 157  
 158  /**
 159   * @private
 160   * Handles an event coming from within the SWF and delegate it
 161   * to a specific instance of SWF.
 162   * @method eventHandler
 163   * @param swfid {String} the id of the SWF dispatching the event
 164   * @param event {Object} the event being transmitted.
 165   */
 166  SWF.eventHandler = function (swfid, event) {
 167      SWF._instances[swfid]._eventHandler(event);
 168  };
 169  
 170  SWF.prototype = {
 171      /**
 172       * @private
 173       * Propagates a specific event from Flash to JS.
 174       * @method _eventHandler
 175       * @param event {Object} The event to be propagated from Flash.
 176       */
 177      _eventHandler: function(event) {
 178          if (event.type === "swfReady") {
 179              this.publish("swfReady", {fireOnce:true});
 180              this.fire("swfReady", event);
 181          } else if(event.type === "log") {
 182              Y.log(event.message, event.category, this.toString());
 183          } else {
 184              this.fire(event.type, event);
 185          }
 186      },
 187  
 188          /**
 189       * Calls a specific function exposed by the SWF's
 190       * ExternalInterface.
 191       * @method callSWF
 192       * @param func {String} the name of the function to call
 193       * @param args {Array} the set of arguments to pass to the function.
 194       */
 195  
 196      callSWF: function (func, args)
 197      {
 198      if (!args) {
 199            args= [];
 200      }
 201          if (this._swf._node[func]) {
 202          return(this._swf._node[func].apply(this._swf._node, args));
 203          } else {
 204          return null;
 205          }
 206      },
 207  
 208      /**
 209       * Public accessor to the unique name of the SWF instance.
 210       *
 211       * @method toString
 212       * @return {String} Unique name of the SWF instance.
 213       */
 214      toString: function()
 215      {
 216          return "SWF " + this._id;
 217      }
 218  };
 219  
 220  Y.augment(SWF, Y.EventTarget);
 221  
 222  Y.SWF = SWF;
 223      /**
 224       * The FileFlash class provides a wrapper for a file pointer stored in Flash. The File wrapper
 225       * also implements the mechanics for uploading a file and tracking its progress.
 226       * @module file-flash
 227       */
 228      /**
 229       * The class provides a wrapper for a file pointer in Flash.
 230       * @class FileFlash
 231       * @extends Base
 232       * @constructor
 233       * @param {Object} config Configuration object.
 234       */
 235  
 236      var FileFlash = function(o) {
 237          FileFlash.superclass.constructor.apply(this, arguments);
 238      };
 239  
 240      Y.extend(FileFlash, Y.Base, {
 241  
 242         /**
 243          * Construction logic executed during FileFlash instantiation.
 244          *
 245          * @method initializer
 246          * @protected
 247          */
 248          initializer : function (cfg) {
 249              if (!this.get("id")) {
 250                  this._set("id", Y.guid("file"));
 251              }
 252          },
 253  
 254         /**
 255          * Handler of events dispatched by the Flash player.
 256          *
 257          * @method _swfEventHandler
 258          * @param {Event} event The event object received from the Flash player.
 259          * @protected
 260          */
 261          _swfEventHandler: function (event) {
 262            if (event.id === this.get("id")) {
 263            switch (event.type) {
 264              /**
 265               * Signals that this file's upload has started.
 266               *
 267               * @event uploadstart
 268               * @param event {Event} The event object for the `uploadstart` with the
 269               *                      following payload:
 270               *  <dl>
 271               *      <dt>uploader</dt>
 272               *          <dd>The Y.SWF instance of Flash uploader that's handling the upload.</dd>
 273               *  </dl>
 274               */
 275              case "uploadstart":
 276                   this.fire("uploadstart", {uploader: this.get("uploader")});
 277                   break;
 278              case "uploadprogress":
 279  
 280                    /**
 281                     * Signals that progress has been made on the upload of this file.
 282                     *
 283                     * @event uploadprogress
 284                     * @param event {Event} The event object for the `uploadprogress` with the
 285                     *                      following payload:
 286                     *  <dl>
 287                     *      <dt>originEvent</dt>
 288                     *          <dd>The original event fired by the Flash uploader instance.</dd>
 289                     *      <dt>bytesLoaded</dt>
 290                     *          <dd>The number of bytes of the file that has been uploaded.</dd>
 291                     *      <dt>bytesTotal</dt>
 292                     *          <dd>The total number of bytes in the file (the file size)</dd>
 293                     *      <dt>percentLoaded</dt>
 294                     *          <dd>The fraction of the file that has been uploaded, out of 100.</dd>
 295                     *  </dl>
 296                     */
 297                   this.fire("uploadprogress", {originEvent: event,
 298                                                bytesLoaded: event.bytesLoaded,
 299                                                bytesTotal: event.bytesTotal,
 300                                                percentLoaded: Math.min(100, Math.round(10000*event.bytesLoaded/event.bytesTotal)/100)
 301                                               });
 302                   this._set("bytesUploaded", event.bytesLoaded);
 303                   break;
 304              case "uploadcomplete":
 305  
 306                    /**
 307                     * Signals that this file's upload has completed, but data has not yet been received from the server.
 308                     *
 309                     * @event uploadfinished
 310                     * @param event {Event} The event object for the `uploadfinished` with the
 311                     *                      following payload:
 312                     *  <dl>
 313                     *      <dt>originEvent</dt>
 314                     *          <dd>The original event fired by the Flash player instance.</dd>
 315                     *  </dl>
 316                     */
 317                   this.fire("uploadfinished", {originEvent: event});
 318                   break;
 319              case "uploadcompletedata":
 320                  /**
 321                   * Signals that this file's upload has completed and data has been received from the server.
 322                   *
 323                   * @event uploadcomplete
 324                   * @param event {Event} The event object for the `uploadcomplete` with the
 325                   *                      following payload:
 326                   *  <dl>
 327                   *      <dt>originEvent</dt>
 328                   *          <dd>The original event fired by the Flash player instance.</dd>
 329                   *      <dt>data</dt>
 330                   *          <dd>The data returned by the server.</dd>
 331                   *  </dl>
 332                   */
 333                   this.fire("uploadcomplete", {originEvent: event,
 334                                                data: event.data});
 335                   break;
 336              case "uploadcancel":
 337  
 338                  /**
 339                   * Signals that this file's upload has been cancelled.
 340                   *
 341                   * @event uploadcancel
 342                   * @param event {Event} The event object for the `uploadcancel` with the
 343                   *                      following payload:
 344                   *  <dl>
 345                   *      <dt>originEvent</dt>
 346                   *          <dd>The original event fired by the Flash player instance.</dd>
 347                   *  </dl>
 348                   */
 349                   this.fire("uploadcancel", {originEvent: event});
 350                   break;
 351              case "uploaderror":
 352  
 353                  /**
 354                   * Signals that this file's upload has encountered an error.
 355                   *
 356                   * @event uploaderror
 357                   * @param event {Event} The event object for the `uploaderror` with the
 358                   *                      following payload:
 359                   *  <dl>
 360                   *      <dt>originEvent</dt>
 361                   *          <dd>The original event fired by the Flash player instance.</dd>
 362                   *      <dt>status</dt>
 363                   *          <dd>The status code reported by the Flash Player. If it's an HTTP error,
 364                   *                then this corresponds to the HTTP status code received by the uploader.</dd>
 365                   *      <dt>statusText</dt>
 366                   *          <dd>The text of the error event reported by the Flash Player.</dd>
 367                   *      <dt>source</dt>
 368                   *          <dd>Either "http" (if it's an HTTP error), or "io" (if it's a network transmission
 369                   *              error.)</dd>
 370                   *  </dl>
 371                   */
 372                   this.fire("uploaderror", {originEvent: event, status: event.status, statusText: event.message, source: event.source});
 373  
 374            }
 375          }
 376          },
 377  
 378         /**
 379          * Starts the upload of a specific file.
 380          *
 381          * @method startUpload
 382          * @param url {String} The URL to upload the file to.
 383          * @param parameters {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
 384          * @param fileFieldName {String} (optional) The name of the POST variable that should contain the uploaded file ('Filedata' by default)
 385          */
 386          startUpload: function(url, parameters, fileFieldName) {
 387  
 388          if (this.get("uploader")) {
 389  
 390              var myUploader = this.get("uploader"),
 391                  fileField = fileFieldName || "Filedata",
 392                  id = this.get("id"),
 393                  params = parameters || null;
 394  
 395              this._set("bytesUploaded", 0);
 396  
 397              myUploader.on("uploadstart", this._swfEventHandler, this);
 398              myUploader.on("uploadprogress", this._swfEventHandler, this);
 399              myUploader.on("uploadcomplete", this._swfEventHandler, this);
 400              myUploader.on("uploadcompletedata", this._swfEventHandler, this);
 401              myUploader.on("uploaderror", this._swfEventHandler, this);
 402  
 403              myUploader.callSWF("upload", [id, url, params, fileField]);
 404           }
 405  
 406          },
 407  
 408         /**
 409          * Cancels the upload of a specific file, if currently in progress.
 410          *
 411          * @method cancelUpload
 412          */
 413          cancelUpload: function () {
 414           if (this.get("uploader")) {
 415             this.get("uploader").callSWF("cancel", [this.get("id")]);
 416             this.fire("uploadcancel");
 417           }
 418          }
 419  
 420      }, {
 421  
 422         /**
 423          * The identity of the class.
 424          *
 425          * @property NAME
 426          * @type String
 427          * @default 'file'
 428          * @readOnly
 429          * @protected
 430          * @static
 431          */
 432          NAME: 'file',
 433  
 434         /**
 435          * The type of transport.
 436          *
 437          * @property TYPE
 438          * @type String
 439          * @default 'flash'
 440          * @readOnly
 441          * @protected
 442          * @static
 443          */
 444          TYPE: "flash",
 445  
 446         /**
 447          * Static property used to define the default attribute configuration of
 448          * the File.
 449          *
 450          * @property ATTRS
 451          * @type {Object}
 452          * @protected
 453          * @static
 454          */
 455          ATTRS: {
 456  
 457         /**
 458          * A String containing the unique id of the file wrapped by the FileFlash instance.
 459          * The id is supplied by the Flash player uploader.
 460          *
 461          * @attribute id
 462          * @type {String}
 463          * @initOnly
 464          */
 465          id: {
 466              writeOnce: "initOnly",
 467              value: null
 468          },
 469  
 470         /**
 471          * The size of the file wrapped by FileFlash. This value is supplied by the Flash player uploader.
 472          *
 473          * @attribute size
 474          * @type {Number}
 475          * @initOnly
 476          */
 477          size: {
 478              writeOnce: "initOnly",
 479              value: 0
 480          },
 481  
 482         /**
 483          * The name of the file wrapped by FileFlash. This value is supplied by the Flash player uploader.
 484          *
 485          * @attribute name
 486          * @type {String}
 487          * @initOnly
 488          */
 489          name: {
 490              writeOnce: "initOnly",
 491              value: null
 492          },
 493  
 494         /**
 495          * The date that the file wrapped by FileFlash was created on. This value is supplied by the Flash player uploader.
 496          *
 497          * @attribute dateCreated
 498          * @type {Date}
 499          * @initOnly
 500          */
 501          dateCreated: {
 502              writeOnce: "initOnly",
 503              value: null
 504          },
 505  
 506         /**
 507          * The date that the file wrapped by FileFlash was last modified on. This value is supplied by the Flash player uploader.
 508          *
 509          * @attribute dateModified
 510          * @type {Date}
 511          * @initOnly
 512          */
 513          dateModified: {
 514              writeOnce: "initOnly",
 515              value: null
 516          },
 517  
 518         /**
 519          * The number of bytes of the file that has been uploaded to the server. This value is
 520          * non-zero only while a file is being uploaded.
 521          *
 522          * @attribute bytesUploaded
 523          * @type {Date}
 524          * @readOnly
 525          */
 526          bytesUploaded: {
 527              readOnly: true,
 528              value: 0
 529          },
 530  
 531         /**
 532          * The type of the file wrapped by FileFlash. This value is provided by the Flash player
 533          * uploader.
 534          *
 535          * @attribute type
 536          * @type {String}
 537          * @initOnly
 538          */
 539          type: {
 540              writeOnce: "initOnly",
 541              value: null
 542          },
 543  
 544         /**
 545          * The instance of Y.SWF wrapping the Flash player uploader associated with this file.
 546          *
 547          * @attribute uploder
 548          * @type {SWF}
 549          * @initOnly
 550          */
 551          uploader: {
 552              writeOnce: "initOnly",
 553              value: null
 554          }
 555          }
 556      });
 557  
 558      Y.FileFlash = FileFlash;
 559  /**
 560  * This module provides a UI for file selection and multiple file upload capability
 561  * using Flash as a transport engine.
 562  * @class UploaderFlash
 563  * @extends Widget
 564  * @param {Object} config Configuration object.
 565  * @constructor
 566  * @deprecated
 567  */
 568  
 569  function UploaderFlash() {
 570      UploaderFlash.superclass.constructor.apply ( this, arguments );
 571  }
 572  
 573  
 574  
 575  Y.UploaderFlash = Y.extend(UploaderFlash, Y.Widget, {
 576  
 577      /**
 578      * Stored value of the current button state (based on
 579      * mouse events dispatched by the Flash player)
 580      * @property _buttonState
 581      * @type {String}
 582      * @protected
 583      */
 584      _buttonState: "up",
 585  
 586      /**
 587      * Stored value of the current button focus state (based
 588      * on keyboard and mouse events).
 589      * @property _buttonFocus
 590      * @type {Boolean}
 591      * @protected
 592      */
 593      _buttonFocus: false,
 594  
 595      /**
 596      * Stored value of the unique id for the container that holds the
 597      * Flash uploader.
 598      *
 599      * @property _swfContainerId
 600      * @type {String}
 601      * @protected
 602      */
 603      _swfContainerId: null,
 604  
 605      /**
 606      * Stored reference to the instance of SWF used to host the
 607      * Flash uploader.
 608      *
 609      * @property _swfReference
 610      * @type {SWF}
 611      * @protected
 612      */
 613      _swfReference: null,
 614  
 615      /**
 616      * Stored reference to the instance of Uploader.Queue used to manage
 617      * the upload process. This is a read-only property that only exists
 618      * during an active upload process. Only one queue can be active at
 619      * a time; if an upload start is attempted while a queue is active,
 620      * it will be ignored.
 621      *
 622      * @property queue
 623      * @type {Uploader.Queue}
 624      */
 625      queue: null,
 626  
 627      /**
 628      * Stored event bindings for keyboard navigation to and from the uploader.
 629      *
 630      * @property _tabElementBindings
 631      * @type {Object}
 632      * @protected
 633      */
 634      _tabElementBindings: null,
 635  
 636  
 637      /**
 638      * Construction logic executed during UploaderFlash instantiation.
 639      *
 640      * @method initializer
 641      * @protected
 642      */
 643      initializer : function () {
 644  
 645          // Assign protected variable values
 646          this._swfContainerId = Y.guid("uploader");
 647          this._swfReference = null;
 648          this.queue = null;
 649          this._buttonState = "up";
 650          this._buttonFocus = null;
 651          this._tabElementBindings = null;
 652          this._fileList = [];
 653  
 654          // Publish available events
 655  
 656          /**
 657          * Signals that files have been selected.
 658          *
 659          * @event fileselect
 660          * @param event {Event} The event object for the `fileselect` with the
 661          *                      following payload:
 662          *  <dl>
 663          *      <dt>fileList</dt>
 664          *          <dd>An `Array` of files selected by the user, encapsulated
 665          *              in Y.FileFlash objects.</dd>
 666          *  </dl>
 667          */
 668          this.publish("fileselect");
 669  
 670          /**
 671          * Signals that an upload of multiple files has been started.
 672          *
 673          * @event uploadstart
 674          * @param event {Event} The event object for the `uploadstart`.
 675          */
 676          this.publish("uploadstart");
 677  
 678          /**
 679          * Signals that an upload of a specific file has started.
 680          *
 681          * @event fileuploadstart
 682          * @param event {Event} The event object for the `fileuploadstart` with the
 683          *                      following payload:
 684          *  <dl>
 685          *      <dt>file</dt>
 686          *          <dd>A reference to the Y.File that dispatched the event.</dd>
 687          *      <dt>originEvent</dt>
 688          *          <dd>The original event dispatched by Y.File.</dd>
 689          *  </dl>
 690          */
 691          this.publish("fileuploadstart");
 692  
 693          /**
 694          * Reports on upload progress of a specific file.
 695          *
 696          * @event uploadprogress
 697          * @param event {Event} The event object for the `uploadprogress` with the
 698          *                      following payload:
 699          *  <dl>
 700          *      <dt>bytesLoaded</dt>
 701          *          <dd>The number of bytes of the file that has been uploaded</dd>
 702          *      <dt>bytesTotal</dt>
 703          *          <dd>The total number of bytes in the file</dd>
 704          *      <dt>percentLoaded</dt>
 705          *          <dd>The fraction of the file that has been uploaded, out of 100</dd>
 706          *      <dt>originEvent</dt>
 707          *          <dd>The original event dispatched by the SWF uploader</dd>
 708          *  </dl>
 709          */
 710          this.publish("uploadprogress");
 711  
 712          /**
 713          * Reports on the total upload progress of the file list.
 714          *
 715          * @event totaluploadprogress
 716          * @param event {Event} The event object for the `totaluploadprogress` with the
 717          *                      following payload:
 718          *  <dl>
 719          *      <dt>bytesLoaded</dt>
 720          *          <dd>The number of bytes of the file list that has been uploaded</dd>
 721          *      <dt>bytesTotal</dt>
 722          *          <dd>The total number of bytes in the file list</dd>
 723          *      <dt>percentLoaded</dt>
 724          *          <dd>The fraction of the file list that has been uploaded, out of 100</dd>
 725          *  </dl>
 726          */
 727          this.publish("totaluploadprogress");
 728  
 729          /**
 730          * Signals that a single file upload has been completed.
 731          *
 732          * @event uploadcomplete
 733          * @param event {Event} The event object for the `uploadcomplete` with the
 734          *                      following payload:
 735          *  <dl>
 736          *      <dt>file</dt>
 737          *          <dd>The pointer to the instance of `Y.File` whose upload has been completed.</dd>
 738          *      <dt>originEvent</dt>
 739          *          <dd>The original event fired by the SWF Uploader</dd>
 740          *      <dt>data</dt>
 741          *          <dd>Data returned by the server.</dd>
 742          *  </dl>
 743          */
 744          this.publish("uploadcomplete");
 745  
 746          /**
 747          * Signals that the upload process of the entire file list has been completed.
 748          *
 749          * @event alluploadscomplete
 750          * @param event {Event} The event object for the `alluploadscomplete`.
 751          */
 752          this.publish("alluploadscomplete");
 753  
 754          /**
 755          * Signals that a error has occurred in a specific file's upload process.
 756          *
 757          * @event uploaderror
 758          * @param event {Event} The event object for the `uploaderror` with the
 759          *                      following payload:
 760          *  <dl>
 761          *      <dt>originEvent</dt>
 762          *          <dd>The original error event fired by the SWF Uploader. </dd>
 763          *      <dt>file</dt>
 764          *          <dd>The pointer at the instance of Y.FileFlash that returned the error.</dd>
 765          *      <dt>source</dt>
 766          *          <dd>The source of the upload error, either "io" or "http"</dd>
 767          *      <dt>message</dt>
 768          *          <dd>The message that accompanied the error. Corresponds to the text of
 769          *              the error in cases where source is "io", and to the HTTP status for
 770                                       cases where source is "http".</dd>
 771          *  </dl>
 772          */
 773          this.publish("uploaderror");
 774  
 775          /**
 776          * Signals that a mouse has begun hovering over the `Select Files` button.
 777          *
 778          * @event mouseenter
 779          * @param event {Event} The event object for the `mouseenter` event.
 780          */
 781          this.publish("mouseenter");
 782  
 783          /**
 784          * Signals that a mouse has stopped hovering over the `Select Files` button.
 785          *
 786          * @event mouseleave
 787          * @param event {Event} The event object for the `mouseleave` event.
 788          */
 789          this.publish("mouseleave");
 790  
 791          /**
 792          * Signals that a mouse button has been pressed over the `Select Files` button.
 793          *
 794          * @event mousedown
 795          * @param event {Event} The event object for the `mousedown` event.
 796          */
 797          this.publish("mousedown");
 798  
 799          /**
 800          * Signals that a mouse button has been released over the `Select Files` button.
 801          *
 802          * @event mouseup
 803          * @param event {Event} The event object for the `mouseup` event.
 804          */
 805          this.publish("mouseup");
 806  
 807          /**
 808          * Signals that a mouse has been clicked over the `Select Files` button.
 809          *
 810          * @event click
 811          * @param event {Event} The event object for the `click` event.
 812          */
 813          this.publish("click");
 814      },
 815  
 816      /**
 817      * Creates the DOM structure for the UploaderFlash.
 818      * UploaderFlash's DOM structure consists of two layers: the base "Select Files"
 819      * button that can be replaced by the developer's widget of choice; and a transparent
 820      * Flash overlay positoned above the button that captures all input events.
 821      * The `position` style attribute of the `boundingBox` of the `Uploader` widget
 822      * is forced to be `relative`, in order to accommodate the Flash player overlay
 823      * (which is `position`ed `absolute`ly).
 824      *
 825      * @method renderUI
 826      * @protected
 827      */
 828      renderUI : function () {
 829          var boundingBox = this.get("boundingBox"),
 830              contentBox = this.get('contentBox'),
 831              selFilesButton = this.get("selectFilesButton"),
 832              flashContainer = Y.Node.create(substitute(UploaderFlash.FLASH_CONTAINER, {
 833                  swfContainerId: this._swfContainerId
 834              })),
 835              params = {
 836                  version: "10.0.45",
 837                  fixedAttributes: {
 838                      wmode: "transparent",
 839                      allowScriptAccess:"always",
 840                      allowNetworking:"all",
 841                      scale: "noscale"
 842                  }
 843              };
 844  
 845          boundingBox.setStyle("position", "relative");
 846          selFilesButton.setStyles({width: "100%", height: "100%"});
 847          contentBox.append(selFilesButton);
 848          contentBox.append(flashContainer);
 849  
 850          this._swfReference = new Y.SWF(flashContainer, this.get("swfURL"), params);
 851      },
 852  
 853      /**
 854      * Binds handlers to the UploaderFlash UI events and propagates attribute
 855      * values to the Flash player.
 856      * The propagation of initial values is set to occur once the Flash player
 857      * instance is ready (as indicated by the `swfReady` event.)
 858      *
 859      * @method bindUI
 860      * @protected
 861      */
 862      bindUI : function () {
 863  
 864          this._swfReference.on("swfReady", function () {
 865              this._setMultipleFiles();
 866              this._setFileFilters();
 867              this._triggerEnabled();
 868              this._attachTabElements();
 869              this.after("multipleFilesChange", this._setMultipleFiles, this);
 870              this.after("fileFiltersChange", this._setFileFilters, this);
 871              this.after("enabledChange", this._triggerEnabled, this);
 872              this.after("tabElementsChange", this._attachTabElements);
 873          }, this);
 874  
 875          this._swfReference.on("fileselect", this._updateFileList, this);
 876  
 877  
 878  
 879          // this._swfReference.on("trace", function (ev) {console.log(ev.message);});
 880  
 881          this._swfReference.on("mouseenter", function () {
 882              this.fire("mouseenter");
 883              this._setButtonClass("hover", true);
 884              if (this._buttonState === "down") {
 885                  this._setButtonClass("active", true);
 886              }
 887          }, this);
 888  
 889          this._swfReference.on("mouseleave", function () {
 890              this.fire("mouseleave");
 891              this._setButtonClass("hover", false);
 892              this._setButtonClass("active", false);
 893          }, this);
 894  
 895          this._swfReference.on("mousedown", function () {
 896              this.fire("mousedown");
 897              this._buttonState = "down";
 898              this._setButtonClass("active", true);
 899          }, this);
 900  
 901          this._swfReference.on("mouseup", function () {
 902              this.fire("mouseup");
 903              this._buttonState = "up";
 904              this._setButtonClass("active", false);
 905          }, this);
 906  
 907          this._swfReference.on("click", function () {
 908              this.fire("click");
 909              this._buttonFocus = true;
 910              this._setButtonClass("focus", true);
 911              Y.one("body").focus();
 912              this._swfReference._swf.focus();
 913          }, this);
 914      },
 915  
 916      /**
 917      * Attaches keyboard bindings to enabling tabbing to and from the instance of the Flash
 918      * player in the Uploader widget. If the previous and next elements are specified, the
 919      * keyboard bindings enable the user to tab from the `tabElements["from"]` node to the
 920      * Flash-powered "Select Files" button, and to the `tabElements["to"]` node.
 921      *
 922      * @method _attachTabElements
 923      * @protected
 924      * @param ev {Event} Optional event payload if called as a `tabElementsChange` handler.
 925      */
 926      _attachTabElements : function () {
 927          if (this.get("tabElements") !== null && this.get("tabElements").from !== null && this.get("tabElements").to !== null) {
 928  
 929              if (this._tabElementBindings !== null) {
 930                  this._tabElementBindings.from.detach();
 931                  this._tabElementBindings.to.detach();
 932                  this._tabElementBindings.tabback.detach();
 933                  this._tabElementBindings.tabforward.detach();
 934                  this._tabElementBindings.focus.detach();
 935                  this._tabElementBindings.blur.detach();
 936              }
 937              else {
 938                  this._tabElementBindings = {};
 939              }
 940  
 941              var fromElement = Y.one(this.get("tabElements").from),
 942                  toElement = Y.one(this.get("tabElements").to);
 943  
 944  
 945              this._tabElementBindings.from = fromElement.on("keydown", function (ev) {
 946                  if (ev.keyCode === 9 && !ev.shiftKey) {
 947                      ev.preventDefault();
 948                      this._swfReference._swf.setAttribute("tabindex", 0);
 949                      this._swfReference._swf.setAttribute("role", "button");
 950                      this._swfReference._swf.setAttribute("aria-label", this.get("selectButtonLabel"));
 951                      this._swfReference._swf.focus();
 952                  }
 953              }, this);
 954  
 955              this._tabElementBindings.to = toElement.on("keydown", function (ev) {
 956                  if (ev.keyCode === 9 && ev.shiftKey) {
 957                      ev.preventDefault();
 958                      this._swfReference._swf.setAttribute("tabindex", 0);
 959                      this._swfReference._swf.setAttribute("role", "button");
 960                      this._swfReference._swf.setAttribute("aria-label", this.get("selectButtonLabel"));
 961                      this._swfReference._swf.focus();
 962                  }
 963              }, this);
 964  
 965              this._tabElementBindings.tabback = this._swfReference.on("tabback", function () {
 966                  this._swfReference._swf.blur();
 967                  setTimeout(function () {
 968                      fromElement.focus();
 969                  }, 30);
 970              }, this);
 971  
 972              this._tabElementBindings.tabforward = this._swfReference.on("tabforward", function () {
 973                  this._swfReference._swf.blur();
 974                  setTimeout(function () {
 975                      toElement.focus();
 976                  }, 30);
 977              }, this);
 978  
 979              this._tabElementBindings.focus = this._swfReference._swf.on("focus", function () {
 980                  this._buttonFocus = true;
 981                  this._setButtonClass("focus", true);
 982              }, this);
 983  
 984              this._tabElementBindings.blur = this._swfReference._swf.on("blur", function () {
 985                  this._buttonFocus = false;
 986                  this._setButtonClass("focus", false);
 987              }, this);
 988          }
 989          else if (this._tabElementBindings !== null) {
 990              this._tabElementBindings.from.detach();
 991              this._tabElementBindings.to.detach();
 992              this._tabElementBindings.tabback.detach();
 993              this._tabElementBindings.tabforward.detach();
 994              this._tabElementBindings.focus.detach();
 995              this._tabElementBindings.blur.detach();
 996          }
 997      },
 998  
 999  
1000      /**
1001      * Adds or removes a specified state CSS class to the underlying uploader button.
1002      *
1003      * @method _setButtonClass
1004      * @protected
1005      * @param state {String} The name of the state enumerated in `buttonClassNames` attribute
1006      * from which to derive the needed class name.
1007      * @param add {Boolean} A Boolean indicating whether to add or remove the class.
1008      */
1009      _setButtonClass : function (state, add) {
1010          if (add) {
1011              this.get("selectFilesButton").addClass(this.get("buttonClassNames")[state]);
1012          }
1013          else {
1014              this.get("selectFilesButton").removeClass(this.get("buttonClassNames")[state]);
1015          }
1016      },
1017  
1018  
1019      /**
1020      * Syncs the state of the `fileFilters` attribute between the instance of UploaderFlash
1021      * and the Flash player.
1022      *
1023      * @method _setFileFilters
1024      * @private
1025      */
1026      _setFileFilters : function () {
1027          if (this._swfReference && this.get("fileFilters").length > 0) {
1028              this._swfReference.callSWF("setFileFilters", [this.get("fileFilters")]);
1029          }
1030      },
1031  
1032  
1033  
1034      /**
1035      * Syncs the state of the `multipleFiles` attribute between this class
1036      * and the Flash uploader.
1037      *
1038      * @method _setMultipleFiles
1039      * @private
1040      */
1041      _setMultipleFiles : function () {
1042          if (this._swfReference) {
1043              this._swfReference.callSWF("setAllowMultipleFiles", [this.get("multipleFiles")]);
1044          }
1045      },
1046  
1047      /**
1048      * Syncs the state of the `enabled` attribute between this class
1049      * and the Flash uploader.
1050      *
1051      * @method _triggerEnabled
1052      * @private
1053      */
1054      _triggerEnabled : function () {
1055          if (this.get("enabled")) {
1056              this._swfReference.callSWF("enable");
1057              this._swfReference._swf.setAttribute("aria-disabled", "false");
1058              this._setButtonClass("disabled", false);
1059          }
1060          else {
1061              this._swfReference.callSWF("disable");
1062              this._swfReference._swf.setAttribute("aria-disabled", "true");
1063              this._setButtonClass("disabled", true);
1064          }
1065      },
1066  
1067      /**
1068      * Getter for the `fileList` attribute
1069      *
1070      * @method _getFileList
1071      * @private
1072      */
1073      _getFileList : function () {
1074          return this._fileList.concat();
1075      },
1076  
1077      /**
1078      * Setter for the `fileList` attribute
1079      *
1080      * @method _setFileList
1081      * @private
1082      */
1083      _setFileList : function (val) {
1084          this._fileList = val.concat();
1085          return this._fileList.concat();
1086      },
1087  
1088      /**
1089      * Adjusts the content of the `fileList` based on the results of file selection
1090      * and the `appendNewFiles` attribute. If the `appendNewFiles` attribute is true,
1091      * then selected files are appended to the existing list; otherwise, the list is
1092      * cleared and populated with the newly selected files.
1093      *
1094      * @method _updateFileList
1095      * @param ev {Event} The file selection event received from the uploader.
1096      * @private
1097      */
1098      _updateFileList : function (ev) {
1099  
1100          Y.one("body").focus();
1101          this._swfReference._swf.focus();
1102  
1103  
1104          var newfiles = ev.fileList,
1105              fileConfObjects = [],
1106              parsedFiles = [],
1107              swfRef = this._swfReference,
1108              filterFunc = this.get("fileFilterFunction"),
1109              oldfiles;
1110  
1111          Y.each(newfiles, function (value) {
1112              var newFileConf = {};
1113              newFileConf.id = value.fileId;
1114              newFileConf.name = value.fileReference.name;
1115              newFileConf.size = value.fileReference.size;
1116              newFileConf.type = value.fileReference.type;
1117              newFileConf.dateCreated = value.fileReference.creationDate;
1118              newFileConf.dateModified = value.fileReference.modificationDate;
1119              newFileConf.uploader = swfRef;
1120  
1121              fileConfObjects.push(newFileConf);
1122          });
1123  
1124           if (filterFunc) {
1125              Y.each(fileConfObjects, function (value) {
1126                  var newfile = new Y.FileFlash(value);
1127                  if (filterFunc(newfile)) {
1128                      parsedFiles.push(newfile);
1129                  }
1130              });
1131           }
1132           else {
1133              Y.each(fileConfObjects, function (value) {
1134                  parsedFiles.push(new Y.FileFlash(value));
1135              });
1136           }
1137  
1138          if (parsedFiles.length > 0) {
1139              oldfiles = this.get("fileList");
1140  
1141              this.set("fileList",
1142                               this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles );
1143  
1144              this.fire("fileselect", { fileList: parsedFiles });
1145          }
1146  
1147      },
1148  
1149  
1150  
1151      /**
1152      * Handles and retransmits events fired by `Y.FileFlash` and `Y.Uploader.Queue`.
1153      *
1154      * @method _uploadEventHandler
1155      * @param event The event dispatched during the upload process.
1156      * @private
1157      */
1158      _uploadEventHandler : function (event) {
1159  
1160          switch (event.type) {
1161              case "file:uploadstart":
1162                   this.fire("fileuploadstart", event);
1163                  break;
1164              case "file:uploadprogress":
1165                   this.fire("uploadprogress", event);
1166                  break;
1167              case "uploaderqueue:totaluploadprogress":
1168                   this.fire("totaluploadprogress", event);
1169                  break;
1170              case "file:uploadcomplete":
1171                   this.fire("uploadcomplete", event);
1172                  break;
1173              case "uploaderqueue:alluploadscomplete":
1174                   this.queue = null;
1175                   this.fire("alluploadscomplete", event);
1176                  break;
1177              case "file:uploaderror": //overflow intentional
1178              case "uploaderqueue:uploaderror":
1179                   this.fire("uploaderror", event);
1180                  break;
1181              case "file:uploadcancel": // overflow intentional
1182              case "uploaderqueue:uploadcancel":
1183                   this.fire("uploadcancel", event);
1184              break;
1185          }
1186  
1187      },
1188  
1189  
1190  
1191      /**
1192      * Starts the upload of a specific file.
1193      *
1194      * @method upload
1195      * @param file {FileFlash} Reference to the instance of the file to be uploaded.
1196      * @param url {String} The URL to upload the file to.
1197      * @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request.
1198      *                          If not specified, the values from the attribute `postVarsPerFile` are used instead.
1199      */
1200      upload : function (file, url, postvars) {
1201  
1202          var uploadURL = url || this.get("uploadURL"),
1203              postVars = postvars || this.get("postVarsPerFile"),
1204              fileId = file.get("id");
1205  
1206              postVars = postVars.hasOwnProperty(fileId) ? postVars[fileId] : postVars;
1207  
1208          if (file instanceof Y.FileFlash) {
1209  
1210              file.on("uploadstart", this._uploadEventHandler, this);
1211              file.on("uploadprogress", this._uploadEventHandler, this);
1212              file.on("uploadcomplete", this._uploadEventHandler, this);
1213              file.on("uploaderror", this._uploadEventHandler, this);
1214              file.on("uploadcancel", this._uploadEventHandler, this);
1215  
1216              file.startUpload(uploadURL, postVars, this.get("fileFieldName"));
1217          }
1218      },
1219  
1220      /**
1221      * Starts the upload of all files on the file list, using an automated queue.
1222      *
1223      * @method uploadAll
1224      * @param url {String} The URL to upload the files to.
1225      * @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request.
1226      *                          If not specified, the values from the attribute `postVarsPerFile` are used instead.
1227      */
1228      uploadAll : function (url, postvars) {
1229          this.uploadThese(this.get("fileList"), url, postvars);
1230      },
1231  
1232      /**
1233      * Starts the upload of the files specified in the first argument, using an automated queue.
1234      *
1235      * @method uploadThese
1236      * @param files {Array} The list of files to upload.
1237      * @param url {String} The URL to upload the files to.
1238      * @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request.
1239      *                          If not specified, the values from the attribute `postVarsPerFile` are used instead.
1240      */
1241      uploadThese : function (files, url, postvars) {
1242          if (!this.queue) {
1243              var uploadURL = url || this.get("uploadURL"),
1244                  postVars = postvars || this.get("postVarsPerFile");
1245  
1246              this.queue = new UploaderQueue({
1247                  simUploads: this.get("simLimit"),
1248                  errorAction: this.get("errorAction"),
1249                  fileFieldName: this.get("fileFieldName"),
1250                  fileList: files,
1251                  uploadURL: uploadURL,
1252                  perFileParameters: postVars,
1253                  retryCount: this.get("retryCount")
1254              });
1255  
1256              this.queue.on("uploadstart", this._uploadEventHandler, this);
1257              this.queue.on("uploadprogress", this._uploadEventHandler, this);
1258              this.queue.on("totaluploadprogress", this._uploadEventHandler, this);
1259              this.queue.on("uploadcomplete", this._uploadEventHandler, this);
1260              this.queue.on("alluploadscomplete", this._uploadEventHandler, this);
1261              this.queue.on("alluploadscancelled", function () {this.queue = null;}, this);
1262              this.queue.on("uploaderror", this._uploadEventHandler, this);
1263              this.queue.startUpload();
1264  
1265              this.fire("uploadstart");
1266          }
1267      }
1268  },
1269  
1270  {
1271      /**
1272      * The template for the Flash player container. Since the Flash player container needs
1273      * to completely overlay the &lquot;Select Files&rqot; control, it's positioned absolutely,
1274      * with width and height set to 100% of the parent.
1275      *
1276      * @property FLASH_CONTAINER
1277      * @type {String}
1278      * @static
1279      * @default '<div id="{swfContainerId}" style="position:absolute; top:0px; left: 0px; margin: 0; padding: 0;
1280      *           border: 0; width:100%; height:100%"></div>'
1281      */
1282      FLASH_CONTAINER: '<div id="{swfContainerId}" style="position:absolute; top:0px; left: 0px; margin: 0; ' +
1283                       'padding: 0; border: 0; width:100%; height:100%"></div>',
1284  
1285      /**
1286      * The template for the "Select Files" button.
1287      *
1288      * @property SELECT_FILES_BUTTON
1289      * @type {String}
1290      * @static
1291      * @default "<button type='button' class='yui3-button' tabindex='-1'>{selectButtonLabel}</button>"
1292      */
1293      SELECT_FILES_BUTTON: "<button type='button' class='yui3-button' tabindex='-1'>{selectButtonLabel}</button>",
1294  
1295      /**
1296      * The static property reflecting the type of uploader that `Y.Uploader`
1297      * aliases. The UploaderFlash value is `"flash"`.
1298      *
1299      * @property TYPE
1300      * @type {String}
1301      * @static
1302      */
1303      TYPE: "flash",
1304  
1305      /**
1306      * The identity of the widget.
1307      *
1308      * @property NAME
1309      * @type String
1310      * @default 'uploader'
1311      * @readOnly
1312      * @protected
1313      * @static
1314      */
1315      NAME: "uploader",
1316  
1317      /**
1318      * Static property used to define the default attribute configuration of
1319      * the Widget.
1320      *
1321      * @property ATTRS
1322      * @type {Object}
1323      * @protected
1324      * @static
1325      */
1326      ATTRS: {
1327  
1328          /**
1329          * A Boolean indicating whether newly selected files should be appended
1330          * to the existing file list, or whether they should replace it.
1331          *
1332          * @attribute appendNewFiles
1333          * @type {Boolean}
1334          * @default true
1335          */
1336          appendNewFiles : {
1337              value: true
1338          },
1339  
1340          /**
1341          * The names of CSS classes that correspond to different button states
1342          * of the "Select Files" control. These classes are assigned to the
1343          * "Select Files" control based on the mouse states reported by the
1344          * Flash player. The keys for the class names are:
1345          * <ul>
1346          *   <li> <strong>`hover`</strong>: the class corresponding to mouse hovering over
1347          *      the "Select Files" button.</li>
1348          *   <li> <strong>`active`</strong>: the class corresponding to mouse down state of
1349          *      the "Select Files" button.</li>
1350          *   <li> <strong>`disabled`</strong>: the class corresponding to the disabled state
1351          *      of the "Select Files" button.</li>
1352          *   <li> <strong>`focus`</strong>: the class corresponding to the focused state of
1353          *      the "Select Files" button.</li>
1354          * </ul>
1355          * @attribute buttonClassNames
1356          * @type {Object}
1357          * @default { hover: "yui3-button-hover",
1358          *            active: "yui3-button-active",
1359          *            disabled: "yui3-button-disabled",
1360          *            focus: "yui3-button-selected"
1361          *          }
1362          */
1363          buttonClassNames: {
1364              value: {
1365                  "hover": "yui3-button-hover",
1366                  "active": "yui3-button-active",
1367                  "disabled": "yui3-button-disabled",
1368                  "focus": "yui3-button-selected"
1369              }
1370          },
1371  
1372          /**
1373          * A Boolean indicating whether the uploader is enabled or disabled for user input.
1374          *
1375          * @attribute enabled
1376          * @type {Boolean}
1377          * @default true
1378          */
1379          enabled : {
1380              value: true
1381          },
1382  
1383          /**
1384          * The action  performed when an upload error occurs for a specific file being uploaded.
1385          * The possible values are:
1386          * <ul>
1387          *   <li> <strong>`UploaderQueue.CONTINUE`</strong>: the error is ignored and the upload process is continued.</li>
1388          *   <li> <strong>`UploaderQueue.STOP`</strong>: the upload process is stopped as soon as any other parallel file
1389          *     uploads are finished.</li>
1390          *   <li> <strong>`UploaderQueue.RESTART_ASAP`</strong>: the file is added back to the front of the queue.</li>
1391          *   <li> <strong>`UploaderQueue.RESTART_AFTER`</strong>: the file is added to the back of the queue.</li>
1392          * </ul>
1393          * @attribute errorAction
1394          * @type {String}
1395          * @default UploaderQueue.CONTINUE
1396          */
1397          errorAction: {
1398              value: "continue",
1399              validator: function (val) {
1400                  return (
1401                      val === UploaderQueue.CONTINUE ||
1402                      val === UploaderQueue.STOP ||
1403                      val === UploaderQueue.RESTART_ASAP ||
1404                      val === UploaderQueue.RESTART_AFTER
1405                  );
1406              }
1407          },
1408  
1409          /**
1410          * An array indicating what fileFilters should be applied to the file
1411          * selection dialog. Each element in the array should be an object with
1412          * the following key-value pairs:
1413          * {
1414          *   description : String
1415           extensions: String of the form &lquot;*.ext1;*.ext2;*.ext3;...&rquot;
1416          * }
1417          * @attribute fileFilters
1418          * @type {Array}
1419          * @default []
1420          */
1421          fileFilters: {
1422              value: []
1423          },
1424  
1425          /**
1426          * A filtering function that is applied to every file selected by the user.
1427          * The function receives the `Y.File` object and must return a Boolean value.
1428          * If a `false` value is returned, the file in question is not added to the
1429          * list of files to be uploaded.
1430          * Use this function to put limits on file sizes or check the file names for
1431          * correct extension, but make sure that a server-side check is also performed,
1432          * since any client-side restrictions are only advisory and can be circumvented.
1433          *
1434          * @attribute fileFilterFunction
1435          * @type {Function}
1436          * @default null
1437          */
1438          fileFilterFunction: {
1439              value: null
1440          },
1441  
1442          /**
1443          * A String specifying what should be the POST field name for the file
1444          * content in the upload request.
1445          *
1446          * @attribute fileFieldName
1447          * @type {String}
1448          * @default Filedata
1449          */
1450          fileFieldName: {
1451              value: "Filedata"
1452          },
1453  
1454          /**
1455          * The array of files to be uploaded. All elements in the array
1456          * must be instances of `Y.FileFlash` and be instantiated with a `fileId`
1457          * retrieved from an instance of the uploader.
1458          *
1459          * @attribute fileList
1460          * @type {Array}
1461          * @default []
1462          */
1463          fileList: {
1464              value: [],
1465              getter: "_getFileList",
1466              setter: "_setFileList"
1467          },
1468  
1469          /**
1470          * A Boolean indicating whether multiple file selection is enabled.
1471          *
1472          * @attribute multipleFiles
1473          * @type {Boolean}
1474          * @default false
1475          */
1476          multipleFiles: {
1477              value: false
1478          },
1479  
1480          /**
1481          * An object, keyed by `fileId`, containing sets of key-value pairs
1482          * that should be passed as POST variables along with each corresponding
1483          * file. This attribute is only used if no POST variables are specifed
1484          * in the upload method call.
1485          *
1486          * @attribute postVarsPerFile
1487          * @type {Object}
1488          * @default {}
1489          */
1490          postVarsPerFile: {
1491              value: {}
1492          },
1493  
1494          /**
1495          * The label for the "Select Files" widget. This is the value that replaces the
1496          * `{selectButtonLabel}` token in the `SELECT_FILES_BUTTON` template.
1497          *
1498          * @attribute selectButtonLabel
1499          * @type {String}
1500          * @default "Select Files"
1501          */
1502          selectButtonLabel: {
1503              value: "Select Files"
1504          },
1505  
1506          /**
1507          * The widget that serves as the "Select Files" control for the file uploader
1508          *
1509          *
1510          * @attribute selectFilesButton
1511          * @type {Node | Widget}
1512          * @default A standard HTML button with YUI CSS Button skin.
1513          */
1514          selectFilesButton : {
1515              valueFn: function () {
1516                  return Y.Node.create(substitute(Y.UploaderFlash.SELECT_FILES_BUTTON, {selectButtonLabel: this.get("selectButtonLabel")}));
1517               }
1518          },
1519  
1520          /**
1521          * The number of files that can be uploaded
1522          * simultaneously if the automatic queue management
1523          * is used. This value can be in the range between 2
1524          * and 5.
1525          *
1526          * @attribute simLimit
1527          * @type {Number}
1528          * @default 2
1529          */
1530          simLimit: {
1531              value: 2,
1532              validator: function (val) {
1533                      return (val >= 2 && val <= 5);
1534              }
1535          },
1536  
1537          /**
1538          * The URL to the SWF file of the flash uploader. A copy local to
1539          * the server that hosts the page on which the uploader appears is
1540          * recommended.
1541          *
1542          * @attribute swfURL
1543          * @type {String}
1544          * @default "flashuploader.swf" with a
1545          * random GET parameter for IE (to prevent buggy behavior when the SWF
1546          * is cached).
1547          */
1548          swfURL: {
1549              valueFn: function () {
1550                  var prefix = "flashuploader.swf";
1551  
1552                  if (Y.UA.ie > 0) {
1553                      return (prefix + "?t=" + Y.guid("uploader"));
1554                  }
1555  
1556                  return prefix;
1557              }
1558          },
1559  
1560          /**
1561          * The id's or `Node` references of the DOM elements that precede
1562          * and follow the `Select Files` button in the tab order. Specifying
1563          * these allows keyboard navigation to and from the Flash player
1564          * layer of the uploader.
1565          * The two keys corresponding to the DOM elements are:
1566          <ul>
1567          *   <li> `from`: the id or the `Node` reference corresponding to the
1568          *     DOM element that precedes the `Select Files` button in the tab order.</li>
1569          *   <li> `to`: the id or the `Node` reference corresponding to the
1570          *     DOM element that follows the `Select Files` button in the tab order.</li>
1571          * </ul>
1572          * @attribute tabElements
1573          * @type {Object}
1574          * @default null
1575          */
1576          tabElements: {
1577              value: null
1578          },
1579  
1580          /**
1581          * The URL to which file upload requested are POSTed. Only used if a different url is not passed to the upload method call.
1582          *
1583          * @attribute uploadURL
1584          * @type {String}
1585          * @default ""
1586          */
1587          uploadURL: {
1588              value: ""
1589          },
1590  
1591          /**
1592          * The number of times to try re-uploading a file that failed to upload before
1593          * cancelling its upload.
1594          *
1595          * @attribute retryCount
1596          * @type {Number}
1597          * @default 3
1598          */
1599          retryCount: {
1600              value: 3
1601          }
1602      }
1603  });
1604  
1605  Y.UploaderFlash.Queue = UploaderQueue;
1606  
1607  
1608  }, '3.17.2', {
1609      "requires": [
1610          "swfdetect",
1611          "escape",
1612          "widget",
1613          "base",
1614          "cssbutton",
1615          "node",
1616          "event-custom",
1617          "uploader-queue"
1618      ]
1619  });


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1