Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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