|
525
|
1 |
/* |
|
|
2 |
YUI 3.10.3 (build 2fb5187) |
|
|
3 |
Copyright 2013 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 |
*/ |
|
|
18 |
|
|
|
19 |
// Shorthands for external modules |
|
|
20 |
var substitute = Y.Lang.sub, |
|
|
21 |
UploaderQueue = Y.Uploader.Queue; |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
/** |
|
|
25 |
* This module provides a UI for file selection and multiple file upload capability |
|
|
26 |
* using Flash as a transport engine. |
|
|
27 |
* @class UploaderFlash |
|
|
28 |
* @extends Widget |
|
|
29 |
* @param {Object} config Configuration object. |
|
|
30 |
* @constructor |
|
|
31 |
*/ |
|
|
32 |
|
|
|
33 |
function UploaderFlash() { |
|
|
34 |
UploaderFlash.superclass.constructor.apply ( this, arguments ); |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
Y.UploaderFlash = Y.extend(UploaderFlash, Y.Widget, { |
|
|
40 |
|
|
|
41 |
/** |
|
|
42 |
* Stored value of the current button state (based on |
|
|
43 |
* mouse events dispatched by the Flash player) |
|
|
44 |
* @property _buttonState |
|
|
45 |
* @type {String} |
|
|
46 |
* @protected |
|
|
47 |
*/ |
|
|
48 |
_buttonState: "up", |
|
|
49 |
|
|
|
50 |
/** |
|
|
51 |
* Stored value of the current button focus state (based |
|
|
52 |
* on keyboard and mouse events). |
|
|
53 |
* @property _buttonFocus |
|
|
54 |
* @type {Boolean} |
|
|
55 |
* @protected |
|
|
56 |
*/ |
|
|
57 |
_buttonFocus: false, |
|
|
58 |
|
|
|
59 |
/** |
|
|
60 |
* Stored value of the unique id for the container that holds the |
|
|
61 |
* Flash uploader. |
|
|
62 |
* |
|
|
63 |
* @property _swfContainerId |
|
|
64 |
* @type {String} |
|
|
65 |
* @protected |
|
|
66 |
*/ |
|
|
67 |
_swfContainerId: null, |
|
|
68 |
|
|
|
69 |
/** |
|
|
70 |
* Stored reference to the instance of SWF used to host the |
|
|
71 |
* Flash uploader. |
|
|
72 |
* |
|
|
73 |
* @property _swfReference |
|
|
74 |
* @type {SWF} |
|
|
75 |
* @protected |
|
|
76 |
*/ |
|
|
77 |
_swfReference: null, |
|
|
78 |
|
|
|
79 |
/** |
|
|
80 |
* Stored reference to the instance of Uploader.Queue used to manage |
|
|
81 |
* the upload process. This is a read-only property that only exists |
|
|
82 |
* during an active upload process. Only one queue can be active at |
|
|
83 |
* a time; if an upload start is attempted while a queue is active, |
|
|
84 |
* it will be ignored. |
|
|
85 |
* |
|
|
86 |
* @property queue |
|
|
87 |
* @type {Y.Uploader.Queue} |
|
|
88 |
*/ |
|
|
89 |
queue: null, |
|
|
90 |
|
|
|
91 |
/** |
|
|
92 |
* Stored event bindings for keyboard navigation to and from the uploader. |
|
|
93 |
* |
|
|
94 |
* @property _tabElementBindings |
|
|
95 |
* @type {Object} |
|
|
96 |
* @protected |
|
|
97 |
*/ |
|
|
98 |
_tabElementBindings: null, |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
/** |
|
|
102 |
* Construction logic executed during UploaderFlash instantiation. |
|
|
103 |
* |
|
|
104 |
* @method initializer |
|
|
105 |
* @protected |
|
|
106 |
*/ |
|
|
107 |
initializer : function () { |
|
|
108 |
|
|
|
109 |
// Assign protected variable values |
|
|
110 |
this._swfContainerId = Y.guid("uploader"); |
|
|
111 |
this._swfReference = null; |
|
|
112 |
this.queue = null; |
|
|
113 |
this._buttonState = "up"; |
|
|
114 |
this._buttonFocus = null; |
|
|
115 |
this._tabElementBindings = null; |
|
|
116 |
this._fileList = []; |
|
|
117 |
|
|
|
118 |
// Publish available events |
|
|
119 |
|
|
|
120 |
/** |
|
|
121 |
* Signals that files have been selected. |
|
|
122 |
* |
|
|
123 |
* @event fileselect |
|
|
124 |
* @param event {Event} The event object for the `fileselect` with the |
|
|
125 |
* following payload: |
|
|
126 |
* <dl> |
|
|
127 |
* <dt>fileList</dt> |
|
|
128 |
* <dd>An `Array` of files selected by the user, encapsulated |
|
|
129 |
* in Y.FileFlash objects.</dd> |
|
|
130 |
* </dl> |
|
|
131 |
*/ |
|
|
132 |
this.publish("fileselect"); |
|
|
133 |
|
|
|
134 |
/** |
|
|
135 |
* Signals that an upload of multiple files has been started. |
|
|
136 |
* |
|
|
137 |
* @event uploadstart |
|
|
138 |
* @param event {Event} The event object for the `uploadstart`. |
|
|
139 |
*/ |
|
|
140 |
this.publish("uploadstart"); |
|
|
141 |
|
|
|
142 |
/** |
|
|
143 |
* Signals that an upload of a specific file has started. |
|
|
144 |
* |
|
|
145 |
* @event fileuploadstart |
|
|
146 |
* @param event {Event} The event object for the `fileuploadstart` with the |
|
|
147 |
* following payload: |
|
|
148 |
* <dl> |
|
|
149 |
* <dt>file</dt> |
|
|
150 |
* <dd>A reference to the Y.File that dispatched the event.</dd> |
|
|
151 |
* <dt>originEvent</dt> |
|
|
152 |
* <dd>The original event dispatched by Y.File.</dd> |
|
|
153 |
* </dl> |
|
|
154 |
*/ |
|
|
155 |
this.publish("fileuploadstart"); |
|
|
156 |
|
|
|
157 |
/** |
|
|
158 |
* Reports on upload progress of a specific file. |
|
|
159 |
* |
|
|
160 |
* @event uploadprogress |
|
|
161 |
* @param event {Event} The event object for the `uploadprogress` with the |
|
|
162 |
* following payload: |
|
|
163 |
* <dl> |
|
|
164 |
* <dt>bytesLoaded</dt> |
|
|
165 |
* <dd>The number of bytes of the file that has been uploaded</dd> |
|
|
166 |
* <dt>bytesTotal</dt> |
|
|
167 |
* <dd>The total number of bytes in the file</dd> |
|
|
168 |
* <dt>percentLoaded</dt> |
|
|
169 |
* <dd>The fraction of the file that has been uploaded, out of 100</dd> |
|
|
170 |
* <dt>originEvent</dt> |
|
|
171 |
* <dd>The original event dispatched by the SWF uploader</dd> |
|
|
172 |
* </dl> |
|
|
173 |
*/ |
|
|
174 |
this.publish("uploadprogress"); |
|
|
175 |
|
|
|
176 |
/** |
|
|
177 |
* Reports on the total upload progress of the file list. |
|
|
178 |
* |
|
|
179 |
* @event totaluploadprogress |
|
|
180 |
* @param event {Event} The event object for the `totaluploadprogress` with the |
|
|
181 |
* following payload: |
|
|
182 |
* <dl> |
|
|
183 |
* <dt>bytesLoaded</dt> |
|
|
184 |
* <dd>The number of bytes of the file list that has been uploaded</dd> |
|
|
185 |
* <dt>bytesTotal</dt> |
|
|
186 |
* <dd>The total number of bytes in the file list</dd> |
|
|
187 |
* <dt>percentLoaded</dt> |
|
|
188 |
* <dd>The fraction of the file list that has been uploaded, out of 100</dd> |
|
|
189 |
* </dl> |
|
|
190 |
*/ |
|
|
191 |
this.publish("totaluploadprogress"); |
|
|
192 |
|
|
|
193 |
/** |
|
|
194 |
* Signals that a single file upload has been completed. |
|
|
195 |
* |
|
|
196 |
* @event uploadcomplete |
|
|
197 |
* @param event {Event} The event object for the `uploadcomplete` with the |
|
|
198 |
* following payload: |
|
|
199 |
* <dl> |
|
|
200 |
* <dt>file</dt> |
|
|
201 |
* <dd>The pointer to the instance of `Y.File` whose upload has been completed.</dd> |
|
|
202 |
* <dt>originEvent</dt> |
|
|
203 |
* <dd>The original event fired by the SWF Uploader</dd> |
|
|
204 |
* <dt>data</dt> |
|
|
205 |
* <dd>Data returned by the server.</dd> |
|
|
206 |
* </dl> |
|
|
207 |
*/ |
|
|
208 |
this.publish("uploadcomplete"); |
|
|
209 |
|
|
|
210 |
/** |
|
|
211 |
* Signals that the upload process of the entire file list has been completed. |
|
|
212 |
* |
|
|
213 |
* @event alluploadscomplete |
|
|
214 |
* @param event {Event} The event object for the `alluploadscomplete`. |
|
|
215 |
*/ |
|
|
216 |
this.publish("alluploadscomplete"); |
|
|
217 |
|
|
|
218 |
/** |
|
|
219 |
* Signals that a error has occurred in a specific file's upload process. |
|
|
220 |
* |
|
|
221 |
* @event uploaderror |
|
|
222 |
* @param event {Event} The event object for the `uploaderror` with the |
|
|
223 |
* following payload: |
|
|
224 |
* <dl> |
|
|
225 |
* <dt>originEvent</dt> |
|
|
226 |
* <dd>The original error event fired by the SWF Uploader. </dd> |
|
|
227 |
* <dt>file</dt> |
|
|
228 |
* <dd>The pointer at the instance of Y.FileFlash that returned the error.</dd> |
|
|
229 |
* <dt>source</dt> |
|
|
230 |
* <dd>The source of the upload error, either "io" or "http"</dd> |
|
|
231 |
* <dt>message</dt> |
|
|
232 |
* <dd>The message that accompanied the error. Corresponds to the text of |
|
|
233 |
* the error in cases where source is "io", and to the HTTP status for |
|
|
234 |
cases where source is "http".</dd> |
|
|
235 |
* </dl> |
|
|
236 |
*/ |
|
|
237 |
this.publish("uploaderror"); |
|
|
238 |
|
|
|
239 |
/** |
|
|
240 |
* Signals that a mouse has begun hovering over the `Select Files` button. |
|
|
241 |
* |
|
|
242 |
* @event mouseenter |
|
|
243 |
* @param event {Event} The event object for the `mouseenter` event. |
|
|
244 |
*/ |
|
|
245 |
this.publish("mouseenter"); |
|
|
246 |
|
|
|
247 |
/** |
|
|
248 |
* Signals that a mouse has stopped hovering over the `Select Files` button. |
|
|
249 |
* |
|
|
250 |
* @event mouseleave |
|
|
251 |
* @param event {Event} The event object for the `mouseleave` event. |
|
|
252 |
*/ |
|
|
253 |
this.publish("mouseleave"); |
|
|
254 |
|
|
|
255 |
/** |
|
|
256 |
* Signals that a mouse button has been pressed over the `Select Files` button. |
|
|
257 |
* |
|
|
258 |
* @event mousedown |
|
|
259 |
* @param event {Event} The event object for the `mousedown` event. |
|
|
260 |
*/ |
|
|
261 |
this.publish("mousedown"); |
|
|
262 |
|
|
|
263 |
/** |
|
|
264 |
* Signals that a mouse button has been released over the `Select Files` button. |
|
|
265 |
* |
|
|
266 |
* @event mouseup |
|
|
267 |
* @param event {Event} The event object for the `mouseup` event. |
|
|
268 |
*/ |
|
|
269 |
this.publish("mouseup"); |
|
|
270 |
|
|
|
271 |
/** |
|
|
272 |
* Signals that a mouse has been clicked over the `Select Files` button. |
|
|
273 |
* |
|
|
274 |
* @event click |
|
|
275 |
* @param event {Event} The event object for the `click` event. |
|
|
276 |
*/ |
|
|
277 |
this.publish("click"); |
|
|
278 |
}, |
|
|
279 |
|
|
|
280 |
/** |
|
|
281 |
* Creates the DOM structure for the UploaderFlash. |
|
|
282 |
* UploaderFlash's DOM structure consists of two layers: the base "Select Files" |
|
|
283 |
* button that can be replaced by the developer's widget of choice; and a transparent |
|
|
284 |
* Flash overlay positoned above the button that captures all input events. |
|
|
285 |
* The `position` style attribute of the `boundingBox` of the `Uploader` widget |
|
|
286 |
* is forced to be `relative`, in order to accommodate the Flash player overlay |
|
|
287 |
* (which is `position`ed `absolute`ly). |
|
|
288 |
* |
|
|
289 |
* @method renderUI |
|
|
290 |
* @protected |
|
|
291 |
*/ |
|
|
292 |
renderUI : function () { |
|
|
293 |
var boundingBox = this.get("boundingBox"), |
|
|
294 |
contentBox = this.get('contentBox'), |
|
|
295 |
selFilesButton = this.get("selectFilesButton"), |
|
|
296 |
flashContainer = Y.Node.create(substitute(UploaderFlash.FLASH_CONTAINER, { |
|
|
297 |
swfContainerId: this._swfContainerId |
|
|
298 |
})), |
|
|
299 |
params = { |
|
|
300 |
version: "10.0.45", |
|
|
301 |
fixedAttributes: { |
|
|
302 |
wmode: "transparent", |
|
|
303 |
allowScriptAccess:"always", |
|
|
304 |
allowNetworking:"all", |
|
|
305 |
scale: "noscale" |
|
|
306 |
} |
|
|
307 |
}; |
|
|
308 |
|
|
|
309 |
boundingBox.setStyle("position", "relative"); |
|
|
310 |
selFilesButton.setStyles({width: "100%", height: "100%"}); |
|
|
311 |
contentBox.append(selFilesButton); |
|
|
312 |
contentBox.append(flashContainer); |
|
|
313 |
|
|
|
314 |
this._swfReference = new Y.SWF(flashContainer, this.get("swfURL"), params); |
|
|
315 |
}, |
|
|
316 |
|
|
|
317 |
/** |
|
|
318 |
* Binds handlers to the UploaderFlash UI events and propagates attribute |
|
|
319 |
* values to the Flash player. |
|
|
320 |
* The propagation of initial values is set to occur once the Flash player |
|
|
321 |
* instance is ready (as indicated by the `swfReady` event.) |
|
|
322 |
* |
|
|
323 |
* @method bindUI |
|
|
324 |
* @protected |
|
|
325 |
*/ |
|
|
326 |
bindUI : function () { |
|
|
327 |
|
|
|
328 |
this._swfReference.on("swfReady", function () { |
|
|
329 |
this._setMultipleFiles(); |
|
|
330 |
this._setFileFilters(); |
|
|
331 |
this._triggerEnabled(); |
|
|
332 |
this._attachTabElements(); |
|
|
333 |
this.after("multipleFilesChange", this._setMultipleFiles, this); |
|
|
334 |
this.after("fileFiltersChange", this._setFileFilters, this); |
|
|
335 |
this.after("enabledChange", this._triggerEnabled, this); |
|
|
336 |
this.after("tabElementsChange", this._attachTabElements); |
|
|
337 |
}, this); |
|
|
338 |
|
|
|
339 |
this._swfReference.on("fileselect", this._updateFileList, this); |
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
// this._swfReference.on("trace", function (ev) {console.log(ev.message);}); |
|
|
344 |
|
|
|
345 |
this._swfReference.on("mouseenter", function () { |
|
|
346 |
this.fire("mouseenter"); |
|
|
347 |
this._setButtonClass("hover", true); |
|
|
348 |
if (this._buttonState === "down") { |
|
|
349 |
this._setButtonClass("active", true); |
|
|
350 |
} |
|
|
351 |
}, this); |
|
|
352 |
|
|
|
353 |
this._swfReference.on("mouseleave", function () { |
|
|
354 |
this.fire("mouseleave"); |
|
|
355 |
this._setButtonClass("hover", false); |
|
|
356 |
this._setButtonClass("active", false); |
|
|
357 |
}, this); |
|
|
358 |
|
|
|
359 |
this._swfReference.on("mousedown", function () { |
|
|
360 |
this.fire("mousedown"); |
|
|
361 |
this._buttonState = "down"; |
|
|
362 |
this._setButtonClass("active", true); |
|
|
363 |
}, this); |
|
|
364 |
|
|
|
365 |
this._swfReference.on("mouseup", function () { |
|
|
366 |
this.fire("mouseup"); |
|
|
367 |
this._buttonState = "up"; |
|
|
368 |
this._setButtonClass("active", false); |
|
|
369 |
}, this); |
|
|
370 |
|
|
|
371 |
this._swfReference.on("click", function () { |
|
|
372 |
this.fire("click"); |
|
|
373 |
this._buttonFocus = true; |
|
|
374 |
this._setButtonClass("focus", true); |
|
|
375 |
Y.one("body").focus(); |
|
|
376 |
this._swfReference._swf.focus(); |
|
|
377 |
}, this); |
|
|
378 |
}, |
|
|
379 |
|
|
|
380 |
/** |
|
|
381 |
* Attaches keyboard bindings to enabling tabbing to and from the instance of the Flash |
|
|
382 |
* player in the Uploader widget. If the previous and next elements are specified, the |
|
|
383 |
* keyboard bindings enable the user to tab from the `tabElements["from"]` node to the |
|
|
384 |
* Flash-powered "Select Files" button, and to the `tabElements["to"]` node. |
|
|
385 |
* |
|
|
386 |
* @method _attachTabElements |
|
|
387 |
* @protected |
|
|
388 |
* @param ev {Event} Optional event payload if called as a `tabElementsChange` handler. |
|
|
389 |
*/ |
|
|
390 |
_attachTabElements : function () { |
|
|
391 |
if (this.get("tabElements") !== null && this.get("tabElements").from !== null && this.get("tabElements").to !== null) { |
|
|
392 |
|
|
|
393 |
if (this._tabElementBindings !== null) { |
|
|
394 |
this._tabElementBindings.from.detach(); |
|
|
395 |
this._tabElementBindings.to.detach(); |
|
|
396 |
this._tabElementBindings.tabback.detach(); |
|
|
397 |
this._tabElementBindings.tabforward.detach(); |
|
|
398 |
this._tabElementBindings.focus.detach(); |
|
|
399 |
this._tabElementBindings.blur.detach(); |
|
|
400 |
} |
|
|
401 |
else { |
|
|
402 |
this._tabElementBindings = {}; |
|
|
403 |
} |
|
|
404 |
|
|
|
405 |
var fromElement = Y.one(this.get("tabElements").from), |
|
|
406 |
toElement = Y.one(this.get("tabElements").to); |
|
|
407 |
|
|
|
408 |
|
|
|
409 |
this._tabElementBindings.from = fromElement.on("keydown", function (ev) { |
|
|
410 |
if (ev.keyCode === 9 && !ev.shiftKey) { |
|
|
411 |
ev.preventDefault(); |
|
|
412 |
this._swfReference._swf.setAttribute("tabindex", 0); |
|
|
413 |
this._swfReference._swf.setAttribute("role", "button"); |
|
|
414 |
this._swfReference._swf.setAttribute("aria-label", this.get("selectButtonLabel")); |
|
|
415 |
this._swfReference._swf.focus(); |
|
|
416 |
} |
|
|
417 |
}, this); |
|
|
418 |
|
|
|
419 |
this._tabElementBindings.to = toElement.on("keydown", function (ev) { |
|
|
420 |
if (ev.keyCode === 9 && ev.shiftKey) { |
|
|
421 |
ev.preventDefault(); |
|
|
422 |
this._swfReference._swf.setAttribute("tabindex", 0); |
|
|
423 |
this._swfReference._swf.setAttribute("role", "button"); |
|
|
424 |
this._swfReference._swf.setAttribute("aria-label", this.get("selectButtonLabel")); |
|
|
425 |
this._swfReference._swf.focus(); |
|
|
426 |
} |
|
|
427 |
}, this); |
|
|
428 |
|
|
|
429 |
this._tabElementBindings.tabback = this._swfReference.on("tabback", function () { |
|
|
430 |
this._swfReference._swf.blur(); |
|
|
431 |
setTimeout(function () { |
|
|
432 |
fromElement.focus(); |
|
|
433 |
}, 30); |
|
|
434 |
}, this); |
|
|
435 |
|
|
|
436 |
this._tabElementBindings.tabforward = this._swfReference.on("tabforward", function () { |
|
|
437 |
this._swfReference._swf.blur(); |
|
|
438 |
setTimeout(function () { |
|
|
439 |
toElement.focus(); |
|
|
440 |
}, 30); |
|
|
441 |
}, this); |
|
|
442 |
|
|
|
443 |
this._tabElementBindings.focus = this._swfReference._swf.on("focus", function () { |
|
|
444 |
this._buttonFocus = true; |
|
|
445 |
this._setButtonClass("focus", true); |
|
|
446 |
}, this); |
|
|
447 |
|
|
|
448 |
this._tabElementBindings.blur = this._swfReference._swf.on("blur", function () { |
|
|
449 |
this._buttonFocus = false; |
|
|
450 |
this._setButtonClass("focus", false); |
|
|
451 |
}, this); |
|
|
452 |
} |
|
|
453 |
else if (this._tabElementBindings !== null) { |
|
|
454 |
this._tabElementBindings.from.detach(); |
|
|
455 |
this._tabElementBindings.to.detach(); |
|
|
456 |
this._tabElementBindings.tabback.detach(); |
|
|
457 |
this._tabElementBindings.tabforward.detach(); |
|
|
458 |
this._tabElementBindings.focus.detach(); |
|
|
459 |
this._tabElementBindings.blur.detach(); |
|
|
460 |
} |
|
|
461 |
}, |
|
|
462 |
|
|
|
463 |
|
|
|
464 |
/** |
|
|
465 |
* Adds or removes a specified state CSS class to the underlying uploader button. |
|
|
466 |
* |
|
|
467 |
* @method _setButtonClass |
|
|
468 |
* @protected |
|
|
469 |
* @param state {String} The name of the state enumerated in `buttonClassNames` attribute |
|
|
470 |
* from which to derive the needed class name. |
|
|
471 |
* @param add {Boolean} A Boolean indicating whether to add or remove the class. |
|
|
472 |
*/ |
|
|
473 |
_setButtonClass : function (state, add) { |
|
|
474 |
if (add) { |
|
|
475 |
this.get("selectFilesButton").addClass(this.get("buttonClassNames")[state]); |
|
|
476 |
} |
|
|
477 |
else { |
|
|
478 |
this.get("selectFilesButton").removeClass(this.get("buttonClassNames")[state]); |
|
|
479 |
} |
|
|
480 |
}, |
|
|
481 |
|
|
|
482 |
|
|
|
483 |
/** |
|
|
484 |
* Syncs the state of the `fileFilters` attribute between the instance of UploaderFlash |
|
|
485 |
* and the Flash player. |
|
|
486 |
* |
|
|
487 |
* @method _setFileFilters |
|
|
488 |
* @private |
|
|
489 |
*/ |
|
|
490 |
_setFileFilters : function () { |
|
|
491 |
if (this._swfReference && this.get("fileFilters").length > 0) { |
|
|
492 |
this._swfReference.callSWF("setFileFilters", [this.get("fileFilters")]); |
|
|
493 |
} |
|
|
494 |
}, |
|
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
/** |
|
|
499 |
* Syncs the state of the `multipleFiles` attribute between this class |
|
|
500 |
* and the Flash uploader. |
|
|
501 |
* |
|
|
502 |
* @method _setMultipleFiles |
|
|
503 |
* @private |
|
|
504 |
*/ |
|
|
505 |
_setMultipleFiles : function () { |
|
|
506 |
if (this._swfReference) { |
|
|
507 |
this._swfReference.callSWF("setAllowMultipleFiles", [this.get("multipleFiles")]); |
|
|
508 |
} |
|
|
509 |
}, |
|
|
510 |
|
|
|
511 |
/** |
|
|
512 |
* Syncs the state of the `enabled` attribute between this class |
|
|
513 |
* and the Flash uploader. |
|
|
514 |
* |
|
|
515 |
* @method _triggerEnabled |
|
|
516 |
* @private |
|
|
517 |
*/ |
|
|
518 |
_triggerEnabled : function () { |
|
|
519 |
if (this.get("enabled")) { |
|
|
520 |
this._swfReference.callSWF("enable"); |
|
|
521 |
this._swfReference._swf.setAttribute("aria-disabled", "false"); |
|
|
522 |
this._setButtonClass("disabled", false); |
|
|
523 |
} |
|
|
524 |
else { |
|
|
525 |
this._swfReference.callSWF("disable"); |
|
|
526 |
this._swfReference._swf.setAttribute("aria-disabled", "true"); |
|
|
527 |
this._setButtonClass("disabled", true); |
|
|
528 |
} |
|
|
529 |
}, |
|
|
530 |
|
|
|
531 |
/** |
|
|
532 |
* Getter for the `fileList` attribute |
|
|
533 |
* |
|
|
534 |
* @method _getFileList |
|
|
535 |
* @private |
|
|
536 |
*/ |
|
|
537 |
_getFileList : function () { |
|
|
538 |
return this._fileList.concat(); |
|
|
539 |
}, |
|
|
540 |
|
|
|
541 |
/** |
|
|
542 |
* Setter for the `fileList` attribute |
|
|
543 |
* |
|
|
544 |
* @method _setFileList |
|
|
545 |
* @private |
|
|
546 |
*/ |
|
|
547 |
_setFileList : function (val) { |
|
|
548 |
this._fileList = val.concat(); |
|
|
549 |
return this._fileList.concat(); |
|
|
550 |
}, |
|
|
551 |
|
|
|
552 |
/** |
|
|
553 |
* Adjusts the content of the `fileList` based on the results of file selection |
|
|
554 |
* and the `appendNewFiles` attribute. If the `appendNewFiles` attribute is true, |
|
|
555 |
* then selected files are appended to the existing list; otherwise, the list is |
|
|
556 |
* cleared and populated with the newly selected files. |
|
|
557 |
* |
|
|
558 |
* @method _updateFileList |
|
|
559 |
* @param ev {Event} The file selection event received from the uploader. |
|
|
560 |
* @private |
|
|
561 |
*/ |
|
|
562 |
_updateFileList : function (ev) { |
|
|
563 |
|
|
|
564 |
Y.one("body").focus(); |
|
|
565 |
this._swfReference._swf.focus(); |
|
|
566 |
|
|
|
567 |
|
|
|
568 |
var newfiles = ev.fileList, |
|
|
569 |
fileConfObjects = [], |
|
|
570 |
parsedFiles = [], |
|
|
571 |
swfRef = this._swfReference, |
|
|
572 |
filterFunc = this.get("fileFilterFunction"), |
|
|
573 |
oldfiles; |
|
|
574 |
|
|
|
575 |
Y.each(newfiles, function (value) { |
|
|
576 |
var newFileConf = {}; |
|
|
577 |
newFileConf.id = value.fileId; |
|
|
578 |
newFileConf.name = value.fileReference.name; |
|
|
579 |
newFileConf.size = value.fileReference.size; |
|
|
580 |
newFileConf.type = value.fileReference.type; |
|
|
581 |
newFileConf.dateCreated = value.fileReference.creationDate; |
|
|
582 |
newFileConf.dateModified = value.fileReference.modificationDate; |
|
|
583 |
newFileConf.uploader = swfRef; |
|
|
584 |
|
|
|
585 |
fileConfObjects.push(newFileConf); |
|
|
586 |
}); |
|
|
587 |
|
|
|
588 |
if (filterFunc) { |
|
|
589 |
Y.each(fileConfObjects, function (value) { |
|
|
590 |
var newfile = new Y.FileFlash(value); |
|
|
591 |
if (filterFunc(newfile)) { |
|
|
592 |
parsedFiles.push(newfile); |
|
|
593 |
} |
|
|
594 |
}); |
|
|
595 |
} |
|
|
596 |
else { |
|
|
597 |
Y.each(fileConfObjects, function (value) { |
|
|
598 |
parsedFiles.push(new Y.FileFlash(value)); |
|
|
599 |
}); |
|
|
600 |
} |
|
|
601 |
|
|
|
602 |
if (parsedFiles.length > 0) { |
|
|
603 |
oldfiles = this.get("fileList"); |
|
|
604 |
|
|
|
605 |
this.set("fileList", |
|
|
606 |
this.get("appendNewFiles") ? oldfiles.concat(parsedFiles) : parsedFiles ); |
|
|
607 |
|
|
|
608 |
this.fire("fileselect", { fileList: parsedFiles }); |
|
|
609 |
} |
|
|
610 |
|
|
|
611 |
}, |
|
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
/** |
|
|
616 |
* Handles and retransmits events fired by `Y.FileFlash` and `Y.Uploader.Queue`. |
|
|
617 |
* |
|
|
618 |
* @method _uploadEventHandler |
|
|
619 |
* @param event The event dispatched during the upload process. |
|
|
620 |
* @private |
|
|
621 |
*/ |
|
|
622 |
_uploadEventHandler : function (event) { |
|
|
623 |
|
|
|
624 |
switch (event.type) { |
|
|
625 |
case "file:uploadstart": |
|
|
626 |
this.fire("fileuploadstart", event); |
|
|
627 |
break; |
|
|
628 |
case "file:uploadprogress": |
|
|
629 |
this.fire("uploadprogress", event); |
|
|
630 |
break; |
|
|
631 |
case "uploaderqueue:totaluploadprogress": |
|
|
632 |
this.fire("totaluploadprogress", event); |
|
|
633 |
break; |
|
|
634 |
case "file:uploadcomplete": |
|
|
635 |
this.fire("uploadcomplete", event); |
|
|
636 |
break; |
|
|
637 |
case "uploaderqueue:alluploadscomplete": |
|
|
638 |
this.queue = null; |
|
|
639 |
this.fire("alluploadscomplete", event); |
|
|
640 |
break; |
|
|
641 |
case "file:uploaderror": //overflow intentional |
|
|
642 |
case "uploaderqueue:uploaderror": |
|
|
643 |
this.fire("uploaderror", event); |
|
|
644 |
break; |
|
|
645 |
case "file:uploadcancel": // overflow intentional |
|
|
646 |
case "uploaderqueue:uploadcancel": |
|
|
647 |
this.fire("uploadcancel", event); |
|
|
648 |
break; |
|
|
649 |
} |
|
|
650 |
|
|
|
651 |
}, |
|
|
652 |
|
|
|
653 |
|
|
|
654 |
|
|
|
655 |
/** |
|
|
656 |
* Starts the upload of a specific file. |
|
|
657 |
* |
|
|
658 |
* @method upload |
|
|
659 |
* @param file {Y.FileFlash} Reference to the instance of the file to be uploaded. |
|
|
660 |
* @param url {String} The URL to upload the file to. |
|
|
661 |
* @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request. |
|
|
662 |
* If not specified, the values from the attribute `postVarsPerFile` are used instead. |
|
|
663 |
*/ |
|
|
664 |
upload : function (file, url, postvars) { |
|
|
665 |
|
|
|
666 |
var uploadURL = url || this.get("uploadURL"), |
|
|
667 |
postVars = postvars || this.get("postVarsPerFile"), |
|
|
668 |
fileId = file.get("id"); |
|
|
669 |
|
|
|
670 |
postVars = postVars.hasOwnProperty(fileId) ? postVars[fileId] : postVars; |
|
|
671 |
|
|
|
672 |
if (file instanceof Y.FileFlash) { |
|
|
673 |
|
|
|
674 |
file.on("uploadstart", this._uploadEventHandler, this); |
|
|
675 |
file.on("uploadprogress", this._uploadEventHandler, this); |
|
|
676 |
file.on("uploadcomplete", this._uploadEventHandler, this); |
|
|
677 |
file.on("uploaderror", this._uploadEventHandler, this); |
|
|
678 |
file.on("uploadcancel", this._uploadEventHandler, this); |
|
|
679 |
|
|
|
680 |
file.startUpload(uploadURL, postVars, this.get("fileFieldName")); |
|
|
681 |
} |
|
|
682 |
}, |
|
|
683 |
|
|
|
684 |
/** |
|
|
685 |
* Starts the upload of all files on the file list, using an automated queue. |
|
|
686 |
* |
|
|
687 |
* @method uploadAll |
|
|
688 |
* @param url {String} The URL to upload the files to. |
|
|
689 |
* @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request. |
|
|
690 |
* If not specified, the values from the attribute `postVarsPerFile` are used instead. |
|
|
691 |
*/ |
|
|
692 |
uploadAll : function (url, postvars) { |
|
|
693 |
this.uploadThese(this.get("fileList"), url, postvars); |
|
|
694 |
}, |
|
|
695 |
|
|
|
696 |
/** |
|
|
697 |
* Starts the upload of the files specified in the first argument, using an automated queue. |
|
|
698 |
* |
|
|
699 |
* @method uploadThese |
|
|
700 |
* @param files {Array} The list of files to upload. |
|
|
701 |
* @param url {String} The URL to upload the files to. |
|
|
702 |
* @param [postVars] {Object} A set of key-value pairs to send as variables along with the file upload HTTP request. |
|
|
703 |
* If not specified, the values from the attribute `postVarsPerFile` are used instead. |
|
|
704 |
*/ |
|
|
705 |
uploadThese : function (files, url, postvars) { |
|
|
706 |
if (!this.queue) { |
|
|
707 |
var uploadURL = url || this.get("uploadURL"), |
|
|
708 |
postVars = postvars || this.get("postVarsPerFile"); |
|
|
709 |
|
|
|
710 |
this.queue = new UploaderQueue({ |
|
|
711 |
simUploads: this.get("simLimit"), |
|
|
712 |
errorAction: this.get("errorAction"), |
|
|
713 |
fileFieldName: this.get("fileFieldName"), |
|
|
714 |
fileList: files, |
|
|
715 |
uploadURL: uploadURL, |
|
|
716 |
perFileParameters: postVars, |
|
|
717 |
retryCount: this.get("retryCount") |
|
|
718 |
}); |
|
|
719 |
|
|
|
720 |
this.queue.on("uploadstart", this._uploadEventHandler, this); |
|
|
721 |
this.queue.on("uploadprogress", this._uploadEventHandler, this); |
|
|
722 |
this.queue.on("totaluploadprogress", this._uploadEventHandler, this); |
|
|
723 |
this.queue.on("uploadcomplete", this._uploadEventHandler, this); |
|
|
724 |
this.queue.on("alluploadscomplete", this._uploadEventHandler, this); |
|
|
725 |
this.queue.on("alluploadscancelled", function () {this.queue = null;}, this); |
|
|
726 |
this.queue.on("uploaderror", this._uploadEventHandler, this); |
|
|
727 |
this.queue.startUpload(); |
|
|
728 |
|
|
|
729 |
this.fire("uploadstart"); |
|
|
730 |
} |
|
|
731 |
} |
|
|
732 |
}, |
|
|
733 |
|
|
|
734 |
{ |
|
|
735 |
/** |
|
|
736 |
* The template for the Flash player container. Since the Flash player container needs |
|
|
737 |
* to completely overlay the &lquot;Select Files&rqot; control, it's positioned absolutely, |
|
|
738 |
* with width and height set to 100% of the parent. |
|
|
739 |
* |
|
|
740 |
* @property FLASH_CONTAINER |
|
|
741 |
* @type {HTML} |
|
|
742 |
* @static |
|
|
743 |
* @default '<div id="{swfContainerId}" style="position:absolute; top:0px; left: 0px; margin: 0; padding: 0; |
|
|
744 |
* border: 0; width:100%; height:100%"></div>' |
|
|
745 |
*/ |
|
|
746 |
FLASH_CONTAINER: '<div id="{swfContainerId}" style="position:absolute; top:0px; left: 0px; margin: 0; ' + |
|
|
747 |
'padding: 0; border: 0; width:100%; height:100%"></div>', |
|
|
748 |
|
|
|
749 |
/** |
|
|
750 |
* The template for the "Select Files" button. |
|
|
751 |
* |
|
|
752 |
* @property SELECT_FILES_BUTTON |
|
|
753 |
* @type {HTML} |
|
|
754 |
* @static |
|
|
755 |
* @default "<button type='button' class='yui3-button' tabindex='-1'>{selectButtonLabel}</button>" |
|
|
756 |
*/ |
|
|
757 |
SELECT_FILES_BUTTON: "<button type='button' class='yui3-button' tabindex='-1'>{selectButtonLabel}</button>", |
|
|
758 |
|
|
|
759 |
/** |
|
|
760 |
* The static property reflecting the type of uploader that `Y.Uploader` |
|
|
761 |
* aliases. The UploaderFlash value is `"flash"`. |
|
|
762 |
* |
|
|
763 |
* @property TYPE |
|
|
764 |
* @type {String} |
|
|
765 |
* @static |
|
|
766 |
*/ |
|
|
767 |
TYPE: "flash", |
|
|
768 |
|
|
|
769 |
/** |
|
|
770 |
* The identity of the widget. |
|
|
771 |
* |
|
|
772 |
* @property NAME |
|
|
773 |
* @type String |
|
|
774 |
* @default 'uploader' |
|
|
775 |
* @readOnly |
|
|
776 |
* @protected |
|
|
777 |
* @static |
|
|
778 |
*/ |
|
|
779 |
NAME: "uploader", |
|
|
780 |
|
|
|
781 |
/** |
|
|
782 |
* Static property used to define the default attribute configuration of |
|
|
783 |
* the Widget. |
|
|
784 |
* |
|
|
785 |
* @property ATTRS |
|
|
786 |
* @type {Object} |
|
|
787 |
* @protected |
|
|
788 |
* @static |
|
|
789 |
*/ |
|
|
790 |
ATTRS: { |
|
|
791 |
|
|
|
792 |
/** |
|
|
793 |
* A Boolean indicating whether newly selected files should be appended |
|
|
794 |
* to the existing file list, or whether they should replace it. |
|
|
795 |
* |
|
|
796 |
* @attribute appendNewFiles |
|
|
797 |
* @type {Boolean} |
|
|
798 |
* @default true |
|
|
799 |
*/ |
|
|
800 |
appendNewFiles : { |
|
|
801 |
value: true |
|
|
802 |
}, |
|
|
803 |
|
|
|
804 |
/** |
|
|
805 |
* The names of CSS classes that correspond to different button states |
|
|
806 |
* of the "Select Files" control. These classes are assigned to the |
|
|
807 |
* "Select Files" control based on the mouse states reported by the |
|
|
808 |
* Flash player. The keys for the class names are: |
|
|
809 |
* <ul> |
|
|
810 |
* <li> <strong>`hover`</strong>: the class corresponding to mouse hovering over |
|
|
811 |
* the "Select Files" button.</li> |
|
|
812 |
* <li> <strong>`active`</strong>: the class corresponding to mouse down state of |
|
|
813 |
* the "Select Files" button.</li> |
|
|
814 |
* <li> <strong>`disabled`</strong>: the class corresponding to the disabled state |
|
|
815 |
* of the "Select Files" button.</li> |
|
|
816 |
* <li> <strong>`focus`</strong>: the class corresponding to the focused state of |
|
|
817 |
* the "Select Files" button.</li> |
|
|
818 |
* </ul> |
|
|
819 |
* @attribute buttonClassNames |
|
|
820 |
* @type {Object} |
|
|
821 |
* @default { hover: "yui3-button-hover", |
|
|
822 |
* active: "yui3-button-active", |
|
|
823 |
* disabled: "yui3-button-disabled", |
|
|
824 |
* focus: "yui3-button-selected" |
|
|
825 |
* } |
|
|
826 |
*/ |
|
|
827 |
buttonClassNames: { |
|
|
828 |
value: { |
|
|
829 |
"hover": "yui3-button-hover", |
|
|
830 |
"active": "yui3-button-active", |
|
|
831 |
"disabled": "yui3-button-disabled", |
|
|
832 |
"focus": "yui3-button-selected" |
|
|
833 |
} |
|
|
834 |
}, |
|
|
835 |
|
|
|
836 |
/** |
|
|
837 |
* A Boolean indicating whether the uploader is enabled or disabled for user input. |
|
|
838 |
* |
|
|
839 |
* @attribute enabled |
|
|
840 |
* @type {Boolean} |
|
|
841 |
* @default true |
|
|
842 |
*/ |
|
|
843 |
enabled : { |
|
|
844 |
value: true |
|
|
845 |
}, |
|
|
846 |
|
|
|
847 |
/** |
|
|
848 |
* The action performed when an upload error occurs for a specific file being uploaded. |
|
|
849 |
* The possible values are: |
|
|
850 |
* <ul> |
|
|
851 |
* <li> <strong>`UploaderQueue.CONTINUE`</strong>: the error is ignored and the upload process is continued.</li> |
|
|
852 |
* <li> <strong>`UploaderQueue.STOP`</strong>: the upload process is stopped as soon as any other parallel file |
|
|
853 |
* uploads are finished.</li> |
|
|
854 |
* <li> <strong>`UploaderQueue.RESTART_ASAP`</strong>: the file is added back to the front of the queue.</li> |
|
|
855 |
* <li> <strong>`UploaderQueue.RESTART_AFTER`</strong>: the file is added to the back of the queue.</li> |
|
|
856 |
* </ul> |
|
|
857 |
* @attribute errorAction |
|
|
858 |
* @type {String} |
|
|
859 |
* @default UploaderQueue.CONTINUE |
|
|
860 |
*/ |
|
|
861 |
errorAction: { |
|
|
862 |
value: "continue", |
|
|
863 |
validator: function (val) { |
|
|
864 |
return ( |
|
|
865 |
val === UploaderQueue.CONTINUE || |
|
|
866 |
val === UploaderQueue.STOP || |
|
|
867 |
val === UploaderQueue.RESTART_ASAP || |
|
|
868 |
val === UploaderQueue.RESTART_AFTER |
|
|
869 |
); |
|
|
870 |
} |
|
|
871 |
}, |
|
|
872 |
|
|
|
873 |
/** |
|
|
874 |
* An array indicating what fileFilters should be applied to the file |
|
|
875 |
* selection dialog. Each element in the array should be an object with |
|
|
876 |
* the following key-value pairs: |
|
|
877 |
* { |
|
|
878 |
* description : String |
|
|
879 |
extensions: String of the form &lquot;*.ext1;*.ext2;*.ext3;...&rquot; |
|
|
880 |
* } |
|
|
881 |
* @attribute fileFilters |
|
|
882 |
* @type {Array} |
|
|
883 |
* @default [] |
|
|
884 |
*/ |
|
|
885 |
fileFilters: { |
|
|
886 |
value: [] |
|
|
887 |
}, |
|
|
888 |
|
|
|
889 |
/** |
|
|
890 |
* A filtering function that is applied to every file selected by the user. |
|
|
891 |
* The function receives the `Y.File` object and must return a Boolean value. |
|
|
892 |
* If a `false` value is returned, the file in question is not added to the |
|
|
893 |
* list of files to be uploaded. |
|
|
894 |
* Use this function to put limits on file sizes or check the file names for |
|
|
895 |
* correct extension, but make sure that a server-side check is also performed, |
|
|
896 |
* since any client-side restrictions are only advisory and can be circumvented. |
|
|
897 |
* |
|
|
898 |
* @attribute fileFilterFunction |
|
|
899 |
* @type {Function} |
|
|
900 |
* @default null |
|
|
901 |
*/ |
|
|
902 |
fileFilterFunction: { |
|
|
903 |
value: null |
|
|
904 |
}, |
|
|
905 |
|
|
|
906 |
/** |
|
|
907 |
* A String specifying what should be the POST field name for the file |
|
|
908 |
* content in the upload request. |
|
|
909 |
* |
|
|
910 |
* @attribute fileFieldName |
|
|
911 |
* @type {String} |
|
|
912 |
* @default Filedata |
|
|
913 |
*/ |
|
|
914 |
fileFieldName: { |
|
|
915 |
value: "Filedata" |
|
|
916 |
}, |
|
|
917 |
|
|
|
918 |
/** |
|
|
919 |
* The array of files to be uploaded. All elements in the array |
|
|
920 |
* must be instances of `Y.FileFlash` and be instantiated with a `fileId` |
|
|
921 |
* retrieved from an instance of the uploader. |
|
|
922 |
* |
|
|
923 |
* @attribute fileList |
|
|
924 |
* @type {Array} |
|
|
925 |
* @default [] |
|
|
926 |
*/ |
|
|
927 |
fileList: { |
|
|
928 |
value: [], |
|
|
929 |
getter: "_getFileList", |
|
|
930 |
setter: "_setFileList" |
|
|
931 |
}, |
|
|
932 |
|
|
|
933 |
/** |
|
|
934 |
* A Boolean indicating whether multiple file selection is enabled. |
|
|
935 |
* |
|
|
936 |
* @attribute multipleFiles |
|
|
937 |
* @type {Boolean} |
|
|
938 |
* @default false |
|
|
939 |
*/ |
|
|
940 |
multipleFiles: { |
|
|
941 |
value: false |
|
|
942 |
}, |
|
|
943 |
|
|
|
944 |
/** |
|
|
945 |
* An object, keyed by `fileId`, containing sets of key-value pairs |
|
|
946 |
* that should be passed as POST variables along with each corresponding |
|
|
947 |
* file. This attribute is only used if no POST variables are specifed |
|
|
948 |
* in the upload method call. |
|
|
949 |
* |
|
|
950 |
* @attribute postVarsPerFile |
|
|
951 |
* @type {Object} |
|
|
952 |
* @default {} |
|
|
953 |
*/ |
|
|
954 |
postVarsPerFile: { |
|
|
955 |
value: {} |
|
|
956 |
}, |
|
|
957 |
|
|
|
958 |
/** |
|
|
959 |
* The label for the "Select Files" widget. This is the value that replaces the |
|
|
960 |
* `{selectButtonLabel}` token in the `SELECT_FILES_BUTTON` template. |
|
|
961 |
* |
|
|
962 |
* @attribute selectButtonLabel |
|
|
963 |
* @type {String} |
|
|
964 |
* @default "Select Files" |
|
|
965 |
*/ |
|
|
966 |
selectButtonLabel: { |
|
|
967 |
value: "Select Files" |
|
|
968 |
}, |
|
|
969 |
|
|
|
970 |
/** |
|
|
971 |
* The widget that serves as the "Select Files" control for the file uploader |
|
|
972 |
* |
|
|
973 |
* |
|
|
974 |
* @attribute selectFilesButton |
|
|
975 |
* @type {Node | Widget} |
|
|
976 |
* @default A standard HTML button with YUI CSS Button skin. |
|
|
977 |
*/ |
|
|
978 |
selectFilesButton : { |
|
|
979 |
valueFn: function () { |
|
|
980 |
return Y.Node.create(substitute(Y.UploaderFlash.SELECT_FILES_BUTTON, {selectButtonLabel: this.get("selectButtonLabel")})); |
|
|
981 |
} |
|
|
982 |
}, |
|
|
983 |
|
|
|
984 |
/** |
|
|
985 |
* The number of files that can be uploaded |
|
|
986 |
* simultaneously if the automatic queue management |
|
|
987 |
* is used. This value can be in the range between 2 |
|
|
988 |
* and 5. |
|
|
989 |
* |
|
|
990 |
* @attribute simLimit |
|
|
991 |
* @type {Number} |
|
|
992 |
* @default 2 |
|
|
993 |
*/ |
|
|
994 |
simLimit: { |
|
|
995 |
value: 2, |
|
|
996 |
validator: function (val) { |
|
|
997 |
return (val >= 2 && val <= 5); |
|
|
998 |
} |
|
|
999 |
}, |
|
|
1000 |
|
|
|
1001 |
/** |
|
|
1002 |
* The URL to the SWF file of the flash uploader. A copy local to |
|
|
1003 |
* the server that hosts the page on which the uploader appears is |
|
|
1004 |
* recommended. |
|
|
1005 |
* |
|
|
1006 |
* @attribute swfURL |
|
|
1007 |
* @type {String} |
|
|
1008 |
* @default "CDN Prefix + uploader/assets/flashuploader.swf" with a |
|
|
1009 |
* random GET parameter for IE (to prevent buggy behavior when the SWF |
|
|
1010 |
* is cached). |
|
|
1011 |
*/ |
|
|
1012 |
swfURL: { |
|
|
1013 |
valueFn: function () { |
|
|
1014 |
var prefix = Y.Env.cdn + "uploader/assets/flashuploader.swf"; |
|
|
1015 |
|
|
|
1016 |
if (Y.UA.ie > 0) { |
|
|
1017 |
return (prefix + "?t=" + Y.guid("uploader")); |
|
|
1018 |
} |
|
|
1019 |
|
|
|
1020 |
return prefix; |
|
|
1021 |
} |
|
|
1022 |
}, |
|
|
1023 |
|
|
|
1024 |
/** |
|
|
1025 |
* The id's or `Node` references of the DOM elements that precede |
|
|
1026 |
* and follow the `Select Files` button in the tab order. Specifying |
|
|
1027 |
* these allows keyboard navigation to and from the Flash player |
|
|
1028 |
* layer of the uploader. |
|
|
1029 |
* The two keys corresponding to the DOM elements are: |
|
|
1030 |
<ul> |
|
|
1031 |
* <li> `from`: the id or the `Node` reference corresponding to the |
|
|
1032 |
* DOM element that precedes the `Select Files` button in the tab order.</li> |
|
|
1033 |
* <li> `to`: the id or the `Node` reference corresponding to the |
|
|
1034 |
* DOM element that follows the `Select Files` button in the tab order.</li> |
|
|
1035 |
* </ul> |
|
|
1036 |
* @attribute tabElements |
|
|
1037 |
* @type {Object} |
|
|
1038 |
* @default null |
|
|
1039 |
*/ |
|
|
1040 |
tabElements: { |
|
|
1041 |
value: null |
|
|
1042 |
}, |
|
|
1043 |
|
|
|
1044 |
/** |
|
|
1045 |
* The URL to which file upload requested are POSTed. Only used if a different url is not passed to the upload method call. |
|
|
1046 |
* |
|
|
1047 |
* @attribute uploadURL |
|
|
1048 |
* @type {String} |
|
|
1049 |
* @default "" |
|
|
1050 |
*/ |
|
|
1051 |
uploadURL: { |
|
|
1052 |
value: "" |
|
|
1053 |
}, |
|
|
1054 |
|
|
|
1055 |
/** |
|
|
1056 |
* The number of times to try re-uploading a file that failed to upload before |
|
|
1057 |
* cancelling its upload. |
|
|
1058 |
* |
|
|
1059 |
* @attribute retryCount |
|
|
1060 |
* @type {Number} |
|
|
1061 |
* @default 3 |
|
|
1062 |
*/ |
|
|
1063 |
retryCount: { |
|
|
1064 |
value: 3 |
|
|
1065 |
} |
|
|
1066 |
} |
|
|
1067 |
}); |
|
|
1068 |
|
|
|
1069 |
Y.UploaderFlash.Queue = UploaderQueue; |
|
|
1070 |
|
|
|
1071 |
|
|
|
1072 |
}, '3.10.3', {"requires": ["swf", "widget", "base", "cssbutton", "node", "event-custom", "file-flash", "uploader-queue"]}); |