~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/uploader-deprecated/uploader-deprecated.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('uploader-deprecated', function(Y) {
 
8
 
 
9
/**
 
10
 * Attention: this is the 3.4.1 `uploader` module has been deprecated in favor of a new 
 
11
 * uploader with an HTML5 layer. Please refer to the new Uploader User Guide for migration 
 
12
 * information.
 
13
 * 
 
14
 * This module uses Flash player transport to upload files to the server, with support for 
 
15
 * file filtering, multiple file uploads and progress monitoring.
 
16
 * @module uploader-deprecated
 
17
 * @deprecated
 
18
 */
 
19
        
 
20
var Event = Y.Event,
 
21
    Node = Y.Node;
 
22
 
 
23
var SWFURL = Y.Env.cdn + "uploader-deprecated/assets/uploader.swf";
 
24
 
 
25
/*
 
26
 * <p><strong><span style="color:#ff0000;">Attention: this is the 3.4.1 uploader module, which has 
 
27
 * been deprecated in favor of a new uploader with an HTML5 layer. Please refer to the new 
 
28
 * Uploader User Guide for migration information.</span></strong></p>
 
29
 * <p>The Uploader widget is a tool for uploading files to the server.</p>
 
30
 * @module uploader-deprecated
 
31
 * @title Uploader
 
32
 * @requires base, node, event, swf
 
33
 */
 
34
 
 
35
/*
 
36
 * <p><strong><span style="color:#ff0000;">Attention: this is the 3.4.1 uploader module, which has 
 
37
 * been deprecated in favor of a new uploader with an HTML5 layer. Please refer to the new 
 
38
 * Uploader User Guide for migration information.</span></strong></p>
 
39
 * <p>Creates the Uploader instance and keeps the initialization data.</p>
 
40
 *
 
41
 * @class Uploader
 
42
 * @extends Y.Base
 
43
 * @constructor
 
44
 * @param {Object} config (optional) Configuration parameters for the Uploader. The following parameters are available:
 
45
 *        <dl>
 
46
 *          <dt>boundingBox : String|Node (required)</dt>
 
47
 *          <dd></dd>
 
48
 *          <dt>buttonSkin : String (optional)</dt>
 
49
 *          <dd></dd>
 
50
 *          <dt>transparent : String (optional)</dt>
 
51
 *          <dd></dd>
 
52
 *          <dt>swfURL : String (optional)</dt>
 
53
 *          <dd></dd>
 
54
 *        </dl>
 
55
 * @deprecated
 
56
 */
 
57
                                
 
58
function Uploader (config /*Object*/) {
 
59
        
 
60
        Uploader.superclass.constructor.apply(this, arguments);
 
61
 
 
62
        if (config.hasOwnProperty("boundingBox")) {
 
63
                this.set("boundingBox", config.boundingBox);
 
64
        };
 
65
 
 
66
        if (config.hasOwnProperty("buttonSkin")) {
 
67
                this.set("buttonSkin", config.buttonSkin);
 
68
        };
 
69
        if (config.hasOwnProperty("transparent")) {
 
70
                this.set("transparent", config.transparent);
 
71
        };
 
72
        if (config.hasOwnProperty("swfURL")) {
 
73
                this.set("swfURL", config.swfURL);
 
74
        };
 
75
};
 
76
 
 
77
 
 
78
Y.extend(Uploader, Y.Base, {
 
79
        
 
80
   /*
 
81
    * The reference to the instance of Y.SWF that encapsulates the instance of the Flash player with uploader logic.
 
82
    *
 
83
    * @private
 
84
    * @property uploaderswf
 
85
    * @type {SWF}
 
86
    * @default null
 
87
    * @deprecated
 
88
    */
 
89
        uploaderswf:null,
 
90
 
 
91
   /*
 
92
    * The id of this instance of uploader.
 
93
    *
 
94
    * @private
 
95
    * @property _id
 
96
    * @type {String}
 
97
    * @deprecated
 
98
    */
 
99
        _id:"",
 
100
 
 
101
   /*
 
102
    * Construction logic executed during Uploader instantiation.
 
103
    *
 
104
    * @method initializer
 
105
    * @protected
 
106
    * @deprecated
 
107
    */
 
108
        initializer : function () {
 
109
                
 
110
        this._id = Y.guid("uploader");
 
111
    var oElement = Node.one(this.get("boundingBox"));
 
112
 
 
113
        var params = {version: "10.0.45",
 
114
                          fixedAttributes: {allowScriptAccess:"always", allowNetworking:"all", scale: "noscale"},
 
115
                      flashVars: {}};
 
116
 
 
117
        if (this.get("buttonSkin") != "") {
 
118
                params.flashVars["buttonSkin"] = this.get("buttonSkin");
 
119
        }
 
120
        if (this.get("transparent")) {
 
121
                params.fixedAttributes["wmode"] = "transparent";
 
122
        }
 
123
 
 
124
    this.uploaderswf = new Y.SWF(oElement, this.get("swfURL"), params);
 
125
 
 
126
        var upswf = this.uploaderswf;
 
127
        var relEvent = Y.bind(this._relayEvent, this);
 
128
 
 
129
        /*
 
130
        * Announces that the uploader is ready and available for calling methods
 
131
        * and setting properties
 
132
        *
 
133
        * @event uploaderReady
 
134
        * @param event {Event} The event object for the uploaderReady.
 
135
    * @deprecated
 
136
    */
 
137
        upswf.on ("swfReady", Y.bind(this._initializeUploader, this));
 
138
        
 
139
        /*
 
140
        * Fired when the mouse button is clicked on the Uploader's 'Browse' button.
 
141
        *
 
142
        * @event click
 
143
        * @param event {Event} The event object for the click.
 
144
    * @deprecated
 
145
    */
 
146
        upswf.on ("click", relEvent);
 
147
 
 
148
        /*
 
149
        * Fires when the user has finished selecting a set of files to be uploaded.
 
150
        *
 
151
        * @event fileselect
 
152
        * @param event {Event} The event object for the fileSelect.
 
153
        *  <dl>
 
154
        *      <dt>fileList</dt>
 
155
        *          <dd>The file list Object with entries in the following format: 
 
156
                       fileList[fileID] = {id: fileID, name: fileName, cDate: fileCDate, mDate: fileMDate, size: fileSize}</dd>
 
157
        *  </dl>
 
158
    * @deprecated
 
159
    */
 
160
        upswf.on ("fileselect", relEvent);
 
161
 
 
162
        /*
 
163
        * Fired when the mouse button is pressed on the Uploader's 'Browse' button.
 
164
        *
 
165
        * @event mousedown
 
166
        * @param event {Event} The event object for the mousedown.
 
167
    * @deprecated
 
168
    */
 
169
        upswf.on ("mousedown", relEvent);
 
170
 
 
171
        /*
 
172
        * Fired when the mouse button is raised on the Uploader's 'Browse' button.
 
173
        *
 
174
        * @event mouseup
 
175
        * @param event {Event} The event object for the mouseup.
 
176
    * @deprecated
 
177
    */
 
178
        upswf.on ("mouseup", relEvent);
 
179
 
 
180
        /*
 
181
        * Fired when the mouse leaves the Uploader's 'Browse' button.
 
182
        *
 
183
        * @event mouseleave
 
184
        * @param event {Event} The event object for the mouseleave.
 
185
    * @deprecated
 
186
    */
 
187
        upswf.on ("mouseleave", relEvent);
 
188
 
 
189
        /*
 
190
        * Fired when the mouse enters the Uploader's 'Browse' button.
 
191
        *
 
192
        * @event mouseenter
 
193
        * @param event {Event} The event object for the mouseenter.
 
194
    * @deprecated
 
195
    */
 
196
        upswf.on ("mouseenter", relEvent);
 
197
 
 
198
        /*
 
199
        * Announces that the uploader is ready and available for calling methods
 
200
        * and setting properties
 
201
        *
 
202
        * @event uploadcancel
 
203
        * @param event {Event} The event object for the uploaderReady.
 
204
        *  <dl>
 
205
        *      <dt>ddEvent</dt>
 
206
        *          <dd><code>drag:start</code> event from the thumb</dd>
 
207
        *  </dl>
 
208
    * @deprecated
 
209
    */
 
210
        upswf.on ("uploadcancel", relEvent);
 
211
 
 
212
        /*
 
213
        * Fires when a specific file's upload is cancelled.
 
214
        *
 
215
        * @event uploadcomplete
 
216
        * @param event {Event} The event object for the uploadcancel.
 
217
        *  <dl>
 
218
        *      <dt>id</dt>
 
219
        *          <dd>The id of the file whose upload has been cancelled.</dd>
 
220
        *  </dl>
 
221
    * @deprecated
 
222
    */
 
223
        upswf.on ("uploadcomplete", relEvent);
 
224
 
 
225
        /*
 
226
        * If the server has sent a response to the file upload, this event is
 
227
        * fired and the response is added to its payload.
 
228
        *
 
229
        * @event uploadcompletedata
 
230
        * @param event {Event} The event object for the uploadcompletedata.
 
231
        *  <dl>
 
232
        *      <dt>id</dt>
 
233
        *          <dd>The id of the file for which the response is being provided.</dd>
 
234
        *      <dt>data</dt>
 
235
        *          <dd>The content of the server response.</dd>
 
236
        *  </dl>
 
237
    * @deprecated
 
238
    */
 
239
        upswf.on ("uploadcompletedata", relEvent);
 
240
 
 
241
        /*
 
242
        * Provides error information if an error has occurred during the upload.
 
243
        *
 
244
        * @event uploaderror
 
245
        * @param event {Event} The event object for the uploadeerror.
 
246
        *  <dl>
 
247
        *      <dt>id</dt>
 
248
        *          <dd>The id of the file for which the upload error has occurred.</dd>
 
249
        *      <dt>status</dt>
 
250
        *          <dd>Relevant error information.</dd>
 
251
        *  </dl>
 
252
    * @deprecated
 
253
    */
 
254
        upswf.on ("uploaderror", relEvent);
 
255
 
 
256
        /*
 
257
        * Provides progress information on a specific file upload.
 
258
        *
 
259
        * @event uploadprogress
 
260
        * @param event {Event} The event object for the uploadprogress.
 
261
        *  <dl>
 
262
        *      <dt>id</dt>
 
263
        *          <dd>The id of the file for which the progress information is being provided.</dd>
 
264
        *      <dt>bytesLoaded</dt>
 
265
        *          <dd>The number of bytes of the file that has been uploaded.</dd>
 
266
        *      <dt>bytesTotal</dt>
 
267
        *          <dd>The total number of bytes in the file that is being uploaded.</dd>
 
268
        *  </dl>
 
269
    * @deprecated
 
270
    */
 
271
        upswf.on ("uploadprogress", relEvent);
 
272
 
 
273
        /*
 
274
        * Announces that the upload has been started for a specific file.
 
275
        *
 
276
        * @event uploadstart
 
277
        * @param event {Event} The event object for the uploadstart.
 
278
        *  <dl>
 
279
        *      <dt>id</dt>
 
280
        *          <dd>The id of the file whose upload has been started.</dd>
 
281
        *  </dl>
 
282
    * @deprecated
 
283
    */ 
 
284
        upswf.on ("uploadstart", relEvent);
 
285
        },
 
286
 
 
287
   /*
 
288
    * Removes a specific file from the upload queue.
 
289
    *
 
290
    * @method removeFile
 
291
    * @param fileID {String} The ID of the file to be removed
 
292
    * @return {Object} The updated file list, which is an object of the format:
 
293
    * fileList[fileID] = {id: fileID, name: fileName, cDate: fileCDate, mDate: fileMDate, size: fileSize}
 
294
    * @deprecated
 
295
    */
 
296
        removeFile : function (fileID /*String*/) {
 
297
                return this.uploaderswf.callSWF("removeFile", [fileID]);
 
298
        },
 
299
        
 
300
   /*
 
301
    * Clears the upload queue.
 
302
    *
 
303
    * @method clearFileList
 
304
    * @return {Boolean} This method always returns true.
 
305
    * @deprecated
 
306
    */
 
307
        clearFileList : function () {
 
308
                return this.uploaderswf.callSWF("clearFileList", []);
 
309
        },
 
310
 
 
311
   /*
 
312
    * Starts the upload of a specific file.
 
313
    *
 
314
    * @method upload
 
315
    * @param fileID {String} The ID of the file to be uploaded.
 
316
    * @param url {String} The URL to upload the file to.
 
317
    * @param method {String} (optional) The HTTP method to use for sending additional variables, either 'GET' or 'POST' ('GET' by default)
 
318
        * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
 
319
        * @param postFileVarName {String} (optional) The name of the POST variable that should contain the uploaded file ('Filedata' by default)
 
320
    * @return {Boolean} This method always returns true.
 
321
    * @deprecated
 
322
    */
 
323
        upload : function (fileID /*String*/, url /*String*/, method /*String*/, postVars /*Object*/, postFileVarName /*String*/) {
 
324
            if (Y.Lang.isArray(fileID)) {
 
325
                        return this.uploaderswf.callSWF("uploadThese", [fileID, url, method, postVars, postFileVarName]);
 
326
                }
 
327
                else if (Y.Lang.isString(fileID)) {
 
328
                        return this.uploaderswf.callSWF("upload", [fileID, url, method, postVars, postFileVarName]);
 
329
                        
 
330
                }
 
331
        },
 
332
 
 
333
   /*
 
334
    * Starts the upload of a set of files, as specified in the first argument. 
 
335
    * The upload queue is managed automatically.
 
336
    *
 
337
    * @method uploadThese
 
338
    * @param fileIDs {Array} The array of IDs of the files to be uploaded.
 
339
    * @param url {String} The URL to upload the files to.
 
340
    * @param method {String} (optional) The HTTP method to use for sending additional variables, either 'GET' or 'POST' ('GET' by default)
 
341
        * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
 
342
        * @param postFileVarName {String} (optional) The name of the POST variable that should contain the uploaded file ('Filedata' by default)
 
343
    * @deprecated
 
344
    */
 
345
        uploadThese : function (fileIDs /*Array*/, url /*String*/, method /*String*/, postVars /*Object*/, postFileVarName /*String*/) {
 
346
                return this.uploaderswf.callSWF("uploadThese", [fileIDs, url, method, postVars, postFileVarName]);
 
347
        },
 
348
 
 
349
   /*
 
350
    * Starts the upload of the files in the upload queue. 
 
351
    * The upload queue is managed automatically.
 
352
    *
 
353
    * @method uploadAll
 
354
    * @param url {String} The URL to upload the files to.
 
355
    * @param method {String} (optional) The HTTP method to use for sending additional variables, either 'GET' or 'POST' ('GET' by default)
 
356
        * @param postVars {Object} (optional) A set of key-value pairs to send as variables along with the file upload HTTP request.
 
357
        * @param postFileVarName {String} (optional) The name of the POST variable that should contain the uploaded file ('Filedata' by default).
 
358
    * @deprecated
 
359
    */  
 
360
        uploadAll : function (url /*String*/, method /*String*/, postVars /*Object*/, postFileVarName /*String*/) {
 
361
                return this.uploaderswf.callSWF("uploadAll", [url, method, postVars,postFileVarName]);
 
362
        },
 
363
 
 
364
   /*
 
365
    * Cancels the upload of a specific file, if currently in progress.
 
366
    *
 
367
    * @method cancel
 
368
    * @param fileID {String} (optional) The ID of the file whose upload should be cancelled. If no ID is specified, all uploads are cancelled.
 
369
    * @deprecated
 
370
    */  
 
371
        cancel : function (fileID /*String*/) {
 
372
                return this.uploaderswf.callSWF("cancel", [fileID]);
 
373
        },
 
374
 
 
375
        /*
 
376
         * @private
 
377
         * Setter for the 'log' property.
 
378
         * @method setAllowLogging
 
379
         * @param value {Boolean} The value for the 'log' property.
 
380
     * @deprecated
 
381
         */
 
382
        setAllowLogging : function (value /*Boolean*/) {
 
383
                this.uploaderswf.callSWF("setAllowLogging", [value]);
 
384
        },
 
385
 
 
386
        /*
 
387
         * @private
 
388
         * Setter for the 'multiFiles' property.
 
389
         * @method setAllowMultipleFiles
 
390
         * @param value {Boolean} The value for the 'multiFiles' property.
 
391
     * @deprecated
 
392
         */
 
393
        setAllowMultipleFiles : function (value /*Boolean*/) {
 
394
                this.uploaderswf.callSWF("setAllowMultipleFiles", [value]);
 
395
        },
 
396
 
 
397
        /*
 
398
         * @private
 
399
         * Setter for the 'simLimit' property.
 
400
         * @method setSimUploadLimit
 
401
         * @param value {Boolean} The value for the 'simLimit' property.
 
402
     * @deprecated
 
403
         */
 
404
        setSimUploadLimit : function (value /*int*/) {
 
405
                this.uploaderswf.callSWF("setSimUploadLimit", [value]);
 
406
        },
 
407
 
 
408
        /*
 
409
         * @private
 
410
         * Setter for the 'fileFilters' property.
 
411
         * @method setFileFilters
 
412
         * @param value {Boolean} The value for the 'fileFilters' property.
 
413
     * @deprecated
 
414
         */     
 
415
        setFileFilters : function (fileFilters /*Array*/) {
 
416
                this.uploaderswf.callSWF("setFileFilters", [fileFilters]);
 
417
        },
 
418
 
 
419
   /*
 
420
    * Enables the uploader user input (mouse clicks on the 'Browse' button). If the button skin 
 
421
    * is applied, the sprite is reset from the "disabled" state.
 
422
    *
 
423
    * @method enable
 
424
    * @deprecated
 
425
    */  
 
426
        enable : function () {
 
427
                this.uploaderswf.callSWF("enable");
 
428
        },
 
429
 
 
430
   /*
 
431
    * Disables the uploader user input (mouse clicks on the 'Browse' button). If the button skin 
 
432
    * is applied, the sprite is set to the 'disabled' state.
 
433
    *
 
434
    * @method enable
 
435
    * @deprecated
 
436
    */  
 
437
        disable : function () {
 
438
                this.uploaderswf.callSWF("disable");
 
439
        },
 
440
 
 
441
        /*
 
442
         * @private
 
443
         * Called when the uploader SWF is initialized
 
444
         * @method _initializeUploader
 
445
         * @param event {Object} The event to be propagated from Flash.
 
446
     * @deprecated
 
447
         */
 
448
        _initializeUploader: function (event) {
 
449
                        this.publish("uploaderReady", {fireOnce:true});
 
450
                this.fire("uploaderReady", {});
 
451
        },
 
452
 
 
453
        /*
 
454
         * @private
 
455
         * Called when an event is dispatched from Uploader
 
456
         * @method _relayEvent
 
457
         * @param event {Object} The event to be propagated from Flash.
 
458
     * @deprecated
 
459
         */     
 
460
        _relayEvent: function (event) {
 
461
                    this.fire(event.type, event);
 
462
        },
 
463
        
 
464
        toString: function()
 
465
        {
 
466
                return "Uploader " + this._id;
 
467
        }
 
468
 
 
469
},
 
470
{
 
471
        ATTRS: {
 
472
        /*
 
473
         * The flag that allows Flash player to 
 
474
         * output debug messages to its trace stack 
 
475
         * (if the Flash debug player is used).
 
476
         *
 
477
         * @attribute log
 
478
         * @type {Boolean}
 
479
         * @default false
 
480
         * @deprecated
 
481
         */
 
482
                log: {
 
483
                        value: false,
 
484
                        setter : "setAllowLogging"
 
485
                },
 
486
 
 
487
        /*
 
488
         * The flag that allows the user to select
 
489
         * more than one files during the 'Browse'
 
490
         * dialog (using 'Shift' or 'Ctrl' keys).
 
491
         *
 
492
         * @attribute multiFiles
 
493
         * @type {Boolean}
 
494
         * @default false
 
495
         * @deprecated
 
496
         */
 
497
                multiFiles : {
 
498
                        value: false,
 
499
                        setter : "setAllowMultipleFiles"
 
500
                },
 
501
        
 
502
        /*
 
503
         * The number of files that can be uploaded
 
504
         * simultaneously if the automatic queue management
 
505
         * is used. This value can be in the range between 2
 
506
         * and 5.
 
507
         *
 
508
         * @attribute simLimit
 
509
         * @type {Number}
 
510
         * @default 2
 
511
         * @deprecated
 
512
         */
 
513
                simLimit : {
 
514
                        value: 2,
 
515
                        setter : "setSimUploadLimit"
 
516
                },
 
517
 
 
518
        /*
 
519
         * The array of filters on file extensions for
 
520
         * the 'Browse' dialog. These filters only provide
 
521
         * convenience for the user and do not strictly
 
522
         * limit the selection to certain file extensions.
 
523
         * Each item in the array must contain a 'description'
 
524
         * property, and an 'extensions' property that must be
 
525
         * in the form "*.ext;*.ext;*.ext;..."
 
526
         *
 
527
         * @attribute fileFilters
 
528
         * @type {Array}
 
529
         * @default []
 
530
         * @deprecated
 
531
         */
 
532
                fileFilters : {
 
533
                        value: [],
 
534
                        setter : "setFileFilters"
 
535
                },
 
536
                
 
537
        /*
 
538
         * The Node containing the uploader's 'Browse' button.
 
539
         *
 
540
         * @attribute boundingBox
 
541
         * @type {Node}
 
542
         * @default null
 
543
         * @writeOnce
 
544
         * @deprecated
 
545
         */
 
546
                boundingBox : {
 
547
                        value: null,
 
548
                        writeOnce: 'initOnly'
 
549
                },
 
550
                
 
551
        /*
 
552
         * The URL of the image sprite for skinning the uploader's 'Browse' button.
 
553
         *
 
554
         * @attribute buttonSkin
 
555
         * @type {String}
 
556
         * @default null
 
557
         * @writeOnce
 
558
         * @deprecated
 
559
         */
 
560
                buttonSkin : {
 
561
                        value: null,
 
562
                        writeOnce: 'initOnly'
 
563
                },
 
564
                
 
565
        /*
 
566
         * The flag indicating whether the uploader is rendered 
 
567
         * with a transparent background.
 
568
         *
 
569
         * @attribute transparent
 
570
         * @type {Boolean}
 
571
         * @default true
 
572
         * @writeOnce
 
573
         * @deprecated
 
574
         */
 
575
                transparent : {
 
576
                        value: true,
 
577
                        writeOnce: 'initOnly'
 
578
                },
 
579
                
 
580
        /*
 
581
         * The URL of the uploader's SWF.
 
582
         *
 
583
         * @attribute swfURL
 
584
         * @type {String}
 
585
         * @default "assets/uploader.swf"
 
586
         * @writeOnce
 
587
         * @deprecated
 
588
         */
 
589
                swfURL : {
 
590
                        value : SWFURL,
 
591
                        writeOnce: 'initOnly'
 
592
                }
 
593
                
 
594
        }
 
595
}
 
596
);
 
597
Y.Uploader = Uploader;
 
598
 
 
599
 
 
600
}, '3.5.1' ,{requires:['swf', 'base', 'node', 'event-custom']});