|
1 /* |
|
2 Copyright (c) 2009, Yahoo! Inc. All rights reserved. |
|
3 Code licensed under the BSD License: |
|
4 http://developer.yahoo.net/yui/license.txt |
|
5 version: 3.0.0b1 |
|
6 build: 1163 |
|
7 */ |
|
8 YUI.add('io-base', function(Y) { |
|
9 |
|
10 /** |
|
11 * Base IO functionality. Provides basic XHR transport support. |
|
12 * @module io |
|
13 * @submodule io-base |
|
14 */ |
|
15 |
|
16 /** |
|
17 * The io class is a utility that brokers HTTP requests through a simplified |
|
18 * interface. Specifically, it allows JavaScript to make HTTP requests to |
|
19 * a resource without a page reload. The underlying transport for making |
|
20 * same-domain requests is the XMLHttpRequest object. YUI.io can also use |
|
21 * Flash, if specified as a transport, for cross-domain requests. |
|
22 * |
|
23 * @class io |
|
24 */ |
|
25 |
|
26 /** |
|
27 * @event io:start |
|
28 * @description This event is fired by YUI.io when a transaction is initiated. |
|
29 * @type Event Custom |
|
30 */ |
|
31 var E_START = 'io:start', |
|
32 |
|
33 /** |
|
34 * @event io:complete |
|
35 * @description This event is fired by YUI.io when a transaction is complete. |
|
36 * Response status and data are accessible, if available. |
|
37 * @type Event Custom |
|
38 */ |
|
39 E_COMPLETE = 'io:complete', |
|
40 |
|
41 /** |
|
42 * @event io:success |
|
43 * @description This event is fired by YUI.io when a transaction is complete, and |
|
44 * the HTTP status resolves to HTTP2xx. |
|
45 * @type Event Custom |
|
46 */ |
|
47 E_SUCCESS = 'io:success', |
|
48 |
|
49 /** |
|
50 * @event io:failure |
|
51 * @description This event is fired by YUI.io when a transaction is complete, and |
|
52 * the HTTP status resolves to HTTP4xx, 5xx and above. |
|
53 * @type Event Custom |
|
54 */ |
|
55 E_FAILURE = 'io:failure', |
|
56 |
|
57 /** |
|
58 * @event io:end |
|
59 * @description This event signifies the end of the transaction lifecycle. The |
|
60 * transaction transport is destroyed. |
|
61 * @type Event Custom |
|
62 */ |
|
63 E_END = 'io:end', |
|
64 |
|
65 //-------------------------------------- |
|
66 // Properties |
|
67 //-------------------------------------- |
|
68 /** |
|
69 * @description A transaction counter that increments for each transaction. |
|
70 * |
|
71 * @property transactionId |
|
72 * @private |
|
73 * @static |
|
74 * @type int |
|
75 */ |
|
76 transactionId = 0, |
|
77 |
|
78 /** |
|
79 * @description Object of default HTTP headers to be initialized and sent |
|
80 * for all transactions. |
|
81 * |
|
82 * @property _headers |
|
83 * @private |
|
84 * @static |
|
85 * @type object |
|
86 */ |
|
87 _headers = { |
|
88 'X-Requested-With' : 'XMLHttpRequest' |
|
89 }, |
|
90 |
|
91 /** |
|
92 * @description Object that stores timeout values for any transaction with |
|
93 * a defined "timeout" configuration property. |
|
94 * |
|
95 * @property _timeOut |
|
96 * @private |
|
97 * @static |
|
98 * @type object |
|
99 */ |
|
100 _timeout = {}, |
|
101 |
|
102 // Window reference |
|
103 w = Y.config.win; |
|
104 |
|
105 //-------------------------------------- |
|
106 // Methods |
|
107 //-------------------------------------- |
|
108 /** |
|
109 * @description Method for requesting a transaction. _io() is implemented as |
|
110 * yui.io(). Each transaction may include a configuration object. Its |
|
111 * properties are: |
|
112 * |
|
113 * method: HTTP method verb (e.g., GET or POST). If this property is not |
|
114 * not defined, the default value will be GET. |
|
115 * |
|
116 * data: This is the name-value string that will be sent as the transaction |
|
117 * data. If the request is HTTP GET, the data become part of |
|
118 * querystring. If HTTP POST, the data are sent in the message body. |
|
119 * |
|
120 * xdr: Defines the transport to be used for cross-domain requests. By |
|
121 * setting this property, the transaction will use the specified |
|
122 * transport instead of XMLHttpRequest. Currently, the only alternate |
|
123 * transport supported is Flash (e.g., { xdr: 'flash' }). |
|
124 * |
|
125 * form: This is a defined object used to process HTML form as data. The |
|
126 * properties are: |
|
127 * { |
|
128 * id: object, //HTML form object or id of HTML form |
|
129 * useDisabled: boolean, //Allow disabled HTML form field values |
|
130 * to be sent as part of the data. |
|
131 * } |
|
132 * |
|
133 * on: This is a defined object used to create and handle specific |
|
134 * events during a transaction lifecycle. These events will fire in |
|
135 * addition to the global io events. The events are: |
|
136 * start - This event is fired when a request is sent to a resource. |
|
137 * complete - This event fires when the transaction is complete. |
|
138 * success - This event fires when the response status resolves to |
|
139 * HTTP 2xx. |
|
140 * failure - This event fires when the response status resolves to |
|
141 * HTTP 4xx, 5xx; and, for all transaction exceptions, |
|
142 * including aborted transactions and transaction timeouts. |
|
143 * end - This even is fired at the conclusion of the transaction |
|
144 * lifecycle, after a success or failure resolution. |
|
145 * |
|
146 * The properties are: |
|
147 * { |
|
148 * start: function(id, args){}, |
|
149 * complete: function(id, responseobject, args){}, |
|
150 * success: function(id, responseobject, args){}, |
|
151 * failure: function(id, responseobject, args){}, |
|
152 * end: function(id, args){} |
|
153 * } |
|
154 * Each property can reference a function or be written as an |
|
155 * inline function. |
|
156 * |
|
157 * context: Object reference for an event handler when it is implemented |
|
158 * as a method of a base object. Defining "context" will preserve |
|
159 * the proper reference of "this" used in the event handler. |
|
160 * headers: This is a defined object of client headers, as many as. |
|
161 * desired for the transaction. These headers are sentThe object |
|
162 * pattern is: |
|
163 * { |
|
164 * header: value |
|
165 * } |
|
166 * |
|
167 * timeout: This value, defined as milliseconds, is a time threshold for the |
|
168 * transaction. When this threshold is reached, and the transaction's |
|
169 * Complete event has not yet fired, the transaction will be aborted. |
|
170 * arguments: Object, array, string, or number passed to all registered |
|
171 * event handlers. This value is available as the second |
|
172 * argument in the "start" and "abort" event handlers; and, it is |
|
173 * the third argument in the "complete", "success", and "failure" |
|
174 * event handlers. |
|
175 * |
|
176 * @method _io |
|
177 * @private |
|
178 * @static |
|
179 * @param {string} uri - qualified path to transaction resource. |
|
180 * @param {object} c - configuration object for the transaction. |
|
181 * @return object |
|
182 */ |
|
183 function _io(uri, c) { |
|
184 var u, f, |
|
185 // Set default value of argument c to Object if |
|
186 // configuration object "c" does not exist. |
|
187 c = c || {}, |
|
188 o = _create((arguments.length === 3) ? arguments[2] : null, c), |
|
189 m = (c.method) ? c.method.toUpperCase() : 'GET', |
|
190 d = (c.data) ? c.data : null; |
|
191 |
|
192 o.abort = function () { |
|
193 c.xdr ? o.c.abort(o.id, c) : _ioCancel(o, 'abort'); |
|
194 }; |
|
195 o.isInProgress = function() { |
|
196 var s = (c.xdr) ? _isInProgress(o) : (o.c.readyState !== 4 && o.c.readyState !== 0); |
|
197 return s; |
|
198 }; |
|
199 |
|
200 /* Determine configuration properties */ |
|
201 // If config.form is defined, perform data operations. |
|
202 if (c.form) { |
|
203 |
|
204 if (c.form.upload) { |
|
205 u = Y.io._upload(o, uri, c); |
|
206 return u; |
|
207 } |
|
208 |
|
209 // Serialize the HTML form into a string of name-value pairs. |
|
210 f = Y.io._serialize(c.form); |
|
211 // If config.data is defined, concatenate the data to the form string. |
|
212 if (d) { |
|
213 f += "&" + d; |
|
214 Y.log('Configuration object.data added to serialized HTML form data. The string is: ' + f, 'info', 'io'); |
|
215 } |
|
216 |
|
217 if (m === 'POST') { |
|
218 d = f; |
|
219 _setHeader('Content-Type', 'application/x-www-form-urlencoded'); |
|
220 } |
|
221 else if (m === 'GET') { |
|
222 uri = _concat(uri, f); |
|
223 Y.log('Configuration object.data added to serialized HTML form data. The querystring is: ' + uri, 'info', 'io'); |
|
224 } |
|
225 } |
|
226 else if (d && m === 'POST') { |
|
227 _setHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
|
228 } |
|
229 |
|
230 if (c.xdr) { |
|
231 Y.io._xdr(uri, o, c); |
|
232 return o; |
|
233 } |
|
234 |
|
235 // If config.timeout is defined, and the request is standard XHR, |
|
236 // initialize timeout polling. |
|
237 if (c.timeout) { |
|
238 _startTimeout(o, c.timeout); |
|
239 } |
|
240 /* End Configuration Properties */ |
|
241 |
|
242 o.c.onreadystatechange = function() { _readyState(o, c); }; |
|
243 try { _open(o.c, m, uri); } catch (e0) {} |
|
244 _setHeaders(o.c, (c.headers || {})); |
|
245 |
|
246 // Do not pass null, in the absence of data, as this |
|
247 // will result in a POST request with no Content-Length |
|
248 // defined. |
|
249 _async(o, (d || ''), c); |
|
250 |
|
251 return o; |
|
252 } |
|
253 |
|
254 /** |
|
255 * @description Method for creating and subscribing transaction events. |
|
256 * |
|
257 * @method _tPubSub |
|
258 * @private |
|
259 * @static |
|
260 * @param {string} e - event to be published |
|
261 * @param {object} c - configuration data subset for event subscription. |
|
262 * |
|
263 * @return void |
|
264 */ |
|
265 function _tPubSub(e, c){ |
|
266 var event = new Y.EventTarget().publish('transaction:' + e); |
|
267 event.subscribe(c.on[e], (c.context || this), c.arguments); |
|
268 |
|
269 return event; |
|
270 } |
|
271 |
|
272 /** |
|
273 * @description Fires event "io:start" and creates, fires a |
|
274 * transaction-specific start event, if config.on.start is |
|
275 * defined. |
|
276 * |
|
277 * @method _ioStart |
|
278 * @private |
|
279 * @static |
|
280 * @param {number} id - transaction id |
|
281 * @param {object} c - configuration object for the transaction. |
|
282 * |
|
283 * @return void |
|
284 */ |
|
285 function _ioStart(id, c) { |
|
286 var m = Y.io._fn || {}, |
|
287 fn = (m && m[id]) ? m[id] : null, |
|
288 event; |
|
289 // Set default value of argument c, property "on" to Object if |
|
290 // the property is null or undefined. |
|
291 c.on = c.on || {}; |
|
292 |
|
293 if (fn) { |
|
294 c.on.start = fn.start; |
|
295 } |
|
296 |
|
297 Y.fire(E_START, id); |
|
298 |
|
299 if (c.on.start) { |
|
300 event = _tPubSub('start', c); |
|
301 event.fire(id); |
|
302 } |
|
303 Y.log('Transaction ' + id + ' started.', 'info', 'io'); |
|
304 } |
|
305 |
|
306 |
|
307 /** |
|
308 * @description Fires event "io:complete" and creates, fires a |
|
309 * transaction-specific "complete" event, if config.on.complete is |
|
310 * defined. |
|
311 * |
|
312 * @method _ioComplete |
|
313 * @private |
|
314 * @static |
|
315 * @param {object} o - transaction object. |
|
316 * @param {object} c - configuration object for the transaction. |
|
317 * |
|
318 * @return void |
|
319 */ |
|
320 function _ioComplete(o, c) { |
|
321 var r, event; |
|
322 // Set default value of argument c, property "on" to Object if |
|
323 // the property is null or undefined. |
|
324 c.on = c.on || {}; |
|
325 |
|
326 r = (o.status) ? _response(o.status) : o.c; |
|
327 Y.fire(E_COMPLETE, o.id, r); |
|
328 |
|
329 if (c.on.complete) { |
|
330 event = _tPubSub('complete', c); |
|
331 event.fire(o.id, r); |
|
332 } |
|
333 Y.log('Transaction ' + o.id + ' completed.', 'info', 'io'); |
|
334 } |
|
335 |
|
336 /** |
|
337 * @description Fires event "io:success" and creates, fires a |
|
338 * transaction-specific "success" event, if config.on.success is |
|
339 * defined. |
|
340 * |
|
341 * @method _ioSuccess |
|
342 * @private |
|
343 * @static |
|
344 * @param {object} o - transaction object. |
|
345 * @param {object} c - configuration object for the transaction. |
|
346 * |
|
347 * @return void |
|
348 */ |
|
349 function _ioSuccess(o, c) { |
|
350 var m = Y.io._fn || {}, |
|
351 fn = (m && m[o.id]) ? m[o.id] : null, |
|
352 event; |
|
353 // Set default value of argument c, property "on" to Object if |
|
354 // the property is null or undefined. |
|
355 c.on = c.on || {}; |
|
356 |
|
357 if (fn) { |
|
358 c.on.success = fn.success; |
|
359 //Decode the response from IO.swf |
|
360 o.c.responseText = decodeURI(o.c.responseText); |
|
361 } |
|
362 |
|
363 Y.fire(E_SUCCESS, o.id, o.c); |
|
364 |
|
365 if (c.on.success) { |
|
366 event = _tPubSub('success', c); |
|
367 event.fire(o.id, o.c); |
|
368 } |
|
369 |
|
370 Y.log('HTTP Status evaluates to Success. The transaction is: ' + o.id, 'info', 'io'); |
|
371 _ioEnd(o, c); |
|
372 } |
|
373 |
|
374 /** |
|
375 * @description Fires event "io:failure" and creates, fires a |
|
376 * transaction-specific "failure" event, if config.on.failure is |
|
377 * defined. |
|
378 * |
|
379 * @method _ioFailure |
|
380 * @private |
|
381 * @static |
|
382 * @param {object} o - transaction object. |
|
383 * @param {object} c - configuration object for the transaction. |
|
384 * |
|
385 * @return void |
|
386 */ |
|
387 function _ioFailure(o, c) { |
|
388 var m = Y.io._fn || {}, |
|
389 fn = (m && m[o.id]) ? m[o.id] : null, |
|
390 r, event; |
|
391 // Set default value of argument c, property "on" to Object if |
|
392 // the property is null or undefined. |
|
393 c.on = c.on || {}; |
|
394 |
|
395 if (fn) { |
|
396 c.on.failure = fn.failure; |
|
397 //Decode the response from IO.swf |
|
398 o.c.responseText = decodeURI(o.c.responseText); |
|
399 } |
|
400 |
|
401 r = (o.status) ? _response(o.status) : o.c; |
|
402 Y.fire(E_FAILURE, o.id, r); |
|
403 |
|
404 if (c.on.failure) { |
|
405 event = _tPubSub('failure', c); |
|
406 event.fire(o.id, r); |
|
407 } |
|
408 |
|
409 Y.log('HTTP Status evaluates to Failure. The transaction is: ' + o.id, 'info', 'io'); |
|
410 _ioEnd(o, c); |
|
411 } |
|
412 |
|
413 /** |
|
414 * @description Fires event "io:end" and creates, fires a |
|
415 * transaction-specific "end" event, if config.on.end is |
|
416 * defined. |
|
417 * |
|
418 * @method _ioEnd |
|
419 * @private |
|
420 * @static |
|
421 * @param {object} o - transaction object. |
|
422 * @param {object} c - configuration object for the transaction. |
|
423 * |
|
424 * @return void |
|
425 */ |
|
426 function _ioEnd(o, c) { |
|
427 var m = Y.io._fn || {}, |
|
428 fn = (m && m[o.id]) ? m[o.id] : null, |
|
429 event; |
|
430 // Set default value of argument c, property "on" to Object if |
|
431 // the property is null or undefined. |
|
432 c.on = c.on || {}; |
|
433 |
|
434 if (fn) { |
|
435 c.on.end = fn.end; |
|
436 delete m[o.id]; |
|
437 } |
|
438 |
|
439 Y.fire(E_END, o.id); |
|
440 |
|
441 if (c.on.end) { |
|
442 event = _tPubSub('end', c); |
|
443 event.fire(o.id); |
|
444 } |
|
445 |
|
446 _destroy(o, (c.xdr) ? true : false ); |
|
447 Y.log('Transaction ' + o.id + ' ended.', 'info', 'io'); |
|
448 } |
|
449 |
|
450 /** |
|
451 * @description Terminates a transaction due to an explicit abort or |
|
452 * timeout. |
|
453 * |
|
454 * @method _ioCancel |
|
455 * @private |
|
456 * @static |
|
457 * @param {object} o - Transaction object generated by _create(). |
|
458 * @param {object} c - Configuration object passed to YUI.io(). |
|
459 * @param {string} s - Identifies timed out or aborted transaction. |
|
460 * |
|
461 * @return void |
|
462 */ |
|
463 function _ioCancel(o, s) { |
|
464 if (o && o.c) { |
|
465 o.status = s; |
|
466 o.c.abort(); |
|
467 } |
|
468 Y.log('Transaction cancelled due to time out or explicitly aborted. The transaction is: ' + o.id, 'info', 'io'); |
|
469 } |
|
470 |
|
471 /** |
|
472 * @description Determines if a cross-domain transaction is still |
|
473 * in progress. |
|
474 * |
|
475 * @method _isInProgress |
|
476 * @private |
|
477 * @static |
|
478 * @param {object} o - Transaction object generated by _create(). |
|
479 * |
|
480 * @return boolean |
|
481 */ |
|
482 function _isInProgress(o) { |
|
483 return o.c.isInProgress(o.id); |
|
484 } |
|
485 |
|
486 function _response(s) { |
|
487 return { status:0, statusText:s }; |
|
488 } |
|
489 |
|
490 /** |
|
491 * @description Method that increments _transactionId for each transaction. |
|
492 * |
|
493 * @method _id |
|
494 * @private |
|
495 * @static |
|
496 * @return int |
|
497 */ |
|
498 function _id() { |
|
499 var id = transactionId; |
|
500 transactionId++; |
|
501 |
|
502 Y.log('Transaction id generated. The id is: ' + id, 'info', 'io'); |
|
503 return id; |
|
504 } |
|
505 |
|
506 /** |
|
507 * @description Method that creates a unique transaction object for each |
|
508 * request. |
|
509 * |
|
510 * @method _create |
|
511 * @private |
|
512 * @static |
|
513 * @param {number} s - URI or root data. |
|
514 * @param {number} c - configuration object |
|
515 * @return object |
|
516 */ |
|
517 function _create(i, c) { |
|
518 var o = {}; |
|
519 o.id = Y.Lang.isNumber(i) ? i : _id(); |
|
520 |
|
521 if (c.xdr) { |
|
522 o.c = Y.io._transport[c.xdr.use]; |
|
523 } |
|
524 else if (c.form && c.form.upload) { |
|
525 o.c = {}; |
|
526 } |
|
527 else { |
|
528 o.c = _xhr(); |
|
529 } |
|
530 |
|
531 return o; |
|
532 }; |
|
533 |
|
534 /** |
|
535 * @description Method that creates the XMLHttpRequest transport |
|
536 * |
|
537 * @method _xhr |
|
538 * @private |
|
539 * @static |
|
540 * @return object |
|
541 */ |
|
542 function _xhr() { |
|
543 return (w.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); |
|
544 } |
|
545 |
|
546 /** |
|
547 * @description Method that concatenates string data for HTTP GET transactions. |
|
548 * |
|
549 * @method _concat |
|
550 * @private |
|
551 * @static |
|
552 * @param {string} s - URI or root data. |
|
553 * @param {string} d - data to be concatenated onto URI. |
|
554 * @return int |
|
555 */ |
|
556 function _concat(s, d) { |
|
557 s += ((s.indexOf('?') == -1) ? '?' : '&') + d; |
|
558 return s; |
|
559 } |
|
560 |
|
561 /** |
|
562 * @description Method that stores default client headers for all transactions. |
|
563 * If a label is passed with no value argument, the header will be deleted. |
|
564 * |
|
565 * @method _setHeader |
|
566 * @private |
|
567 * @static |
|
568 * @param {string} l - HTTP header |
|
569 * @param {string} v - HTTP header value |
|
570 * @return int |
|
571 */ |
|
572 function _setHeader(l, v) { |
|
573 if (v) { |
|
574 _headers[l] = v; |
|
575 } |
|
576 else { |
|
577 delete _headers[l]; |
|
578 } |
|
579 } |
|
580 |
|
581 /** |
|
582 * @description Method that sets all HTTP headers to be sent in a transaction. |
|
583 * |
|
584 * @method _setHeaders |
|
585 * @private |
|
586 * @static |
|
587 * @param {object} o - XHR instance for the specific transaction. |
|
588 * @param {object} h - HTTP headers for the specific transaction, as defined |
|
589 * in the configuration object passed to YUI.io(). |
|
590 * @return void |
|
591 */ |
|
592 function _setHeaders(o, h) { |
|
593 var p; |
|
594 |
|
595 for (p in _headers) { |
|
596 if (_headers.hasOwnProperty(p)) { |
|
597 if (h[p]) { |
|
598 // Configuration headers will supersede IO preset headers, |
|
599 // if headers match. |
|
600 Y.log('Matching configuration HTTP header: ' + p + ' found with value of ' + _headers[p], 'info', 'io'); |
|
601 break; |
|
602 } |
|
603 else { |
|
604 h[p] = _headers[p]; |
|
605 Y.log('HTTP header ' + p + ' found with value of ' + _headers[p], 'info', 'io'); |
|
606 } |
|
607 } |
|
608 } |
|
609 |
|
610 for (p in h) { |
|
611 if (h.hasOwnProperty(p)) { |
|
612 o.setRequestHeader(p, h[p]); |
|
613 Y.log('HTTP Header ' + p + ' set with value of ' + h[p], 'info', 'io'); |
|
614 } |
|
615 } |
|
616 } |
|
617 |
|
618 function _open(o, m, uri) { |
|
619 o.open(m, uri, true); |
|
620 } |
|
621 |
|
622 /** |
|
623 * @description Method that sends the transaction request. |
|
624 * |
|
625 * @method _async |
|
626 * @private |
|
627 * @static |
|
628 * @param {object} o - Transaction object generated by _create(). |
|
629 * @param {string} d - Transaction data. |
|
630 * @param {object} c - Configuration object passed to YUI.io(). |
|
631 * @return void |
|
632 */ |
|
633 function _async(o, d, c) { |
|
634 o.c.send(d); |
|
635 _ioStart(o.id, c); |
|
636 } |
|
637 |
|
638 /** |
|
639 * @description Starts timeout count if the configuration object |
|
640 * has a defined timeout property. |
|
641 * |
|
642 * @method _startTimeout |
|
643 * @private |
|
644 * @static |
|
645 * @param {object} o - Transaction object generated by _create(). |
|
646 * @param {object} c - Configuration object passed to YUI.io(). |
|
647 * @return void |
|
648 */ |
|
649 function _startTimeout(o, timeout) { |
|
650 _timeout[o.id] = w.setTimeout(function() { _ioCancel(o, 'timeout'); }, timeout); |
|
651 } |
|
652 |
|
653 /** |
|
654 * @description Clears the timeout interval started by _startTimeout(). |
|
655 * |
|
656 * @method _clearTimeout |
|
657 * @private |
|
658 * @static |
|
659 * @param {number} id - Transaction id. |
|
660 * @return void |
|
661 */ |
|
662 function _clearTimeout(id) { |
|
663 w.clearTimeout(_timeout[id]); |
|
664 delete _timeout[id]; |
|
665 } |
|
666 |
|
667 /** |
|
668 * @description Event handler bound to onreadystatechange. |
|
669 * |
|
670 * @method _readyState |
|
671 * @private |
|
672 * @static |
|
673 * @param {object} o - Transaction object generated by _create(). |
|
674 * @param {object} c - Configuration object passed to YUI.io(). |
|
675 * @return void |
|
676 */ |
|
677 function _readyState(o, c) { |
|
678 if (o.c.readyState === 4) { |
|
679 if (c.timeout) { |
|
680 _clearTimeout(o.id); |
|
681 } |
|
682 |
|
683 w.setTimeout( |
|
684 function() { |
|
685 _ioComplete(o, c); |
|
686 _handleResponse(o, c); |
|
687 }, 0); |
|
688 } |
|
689 } |
|
690 |
|
691 /** |
|
692 * @description Method that determines if a transaction response qualifies |
|
693 * as success or failure, based on the response HTTP status code, and |
|
694 * fires the appropriate success or failure events. |
|
695 * |
|
696 * @method _handleResponse |
|
697 * @private |
|
698 * @static |
|
699 * @param {object} o - Transaction object generated by _create(). |
|
700 * @param {object} c - Configuration object passed to io(). |
|
701 * @return void |
|
702 */ |
|
703 function _handleResponse(o, c) { |
|
704 var status; |
|
705 try{ |
|
706 if (o.c.status && o.c.status !== 0) { |
|
707 status = o.c.status; |
|
708 } |
|
709 else { |
|
710 status = 0; |
|
711 } |
|
712 } |
|
713 catch(e1) { |
|
714 status = 0; |
|
715 Y.log('HTTP status unreadable. The transaction is: ' + o.id, 'warn', 'io'); |
|
716 } |
|
717 |
|
718 // IE reports HTTP 204 as HTTP 1223. |
|
719 // But, the response data are still available. |
|
720 if (status >= 200 && status < 300 || status === 1223) { |
|
721 _ioSuccess(o, c); |
|
722 } |
|
723 else { |
|
724 _ioFailure(o, c); |
|
725 } |
|
726 } |
|
727 |
|
728 function _destroy(o, isTransport) { |
|
729 // IE, when using XMLHttpRequest as an ActiveX Object, will throw |
|
730 // a "Type Mismatch" error if the event handler is set to "null". |
|
731 if(w.XMLHttpRequest && !isTransport) { |
|
732 if (o.c) { |
|
733 o.c.onreadystatechange = null; |
|
734 } |
|
735 } |
|
736 |
|
737 o.c = null; |
|
738 o = null; |
|
739 } |
|
740 |
|
741 _io.start = _ioStart; |
|
742 _io.complete = _ioComplete; |
|
743 _io.success = _ioSuccess; |
|
744 _io.failure = _ioFailure; |
|
745 _io.isInProgress = _isInProgress; |
|
746 _io._id = _id; |
|
747 |
|
748 //-------------------------------------- |
|
749 // Begin public interface definition |
|
750 //-------------------------------------- |
|
751 /** |
|
752 * @description Method that stores default client headers for all transactions. |
|
753 * If a label is passed with no value argument, the header will be deleted. |
|
754 * This is the interface for _setHeader(). |
|
755 * |
|
756 * @method header |
|
757 * @public |
|
758 * @static |
|
759 * @param {string} l - HTTP header |
|
760 * @param {string} v - HTTP header value |
|
761 * @return int |
|
762 */ |
|
763 _io.header = _setHeader; |
|
764 |
|
765 /** |
|
766 * @description Method for requesting a transaction. This |
|
767 * is the interface for _io(). |
|
768 * |
|
769 * @method io |
|
770 * @public |
|
771 * @static |
|
772 * @param {string} uri - qualified path to transaction resource. |
|
773 * @param {object} c - configuration object for the transaction. |
|
774 * @return object |
|
775 */ |
|
776 Y.io = _io; |
|
777 Y.io.http = _io; |
|
778 |
|
779 |
|
780 |
|
781 }, '3.0.0b1' ); |
|
782 |
|
783 YUI.add('io-form', function(Y) { |
|
784 |
|
785 /** |
|
786 * Extends the IO base class to enable HTML form data serialization, when specified |
|
787 * in the transaction's configuration object. |
|
788 * @module io |
|
789 * @submodule io-form |
|
790 */ |
|
791 |
|
792 Y.mix(Y.io, { |
|
793 /** |
|
794 * @description Method to enumerate through an HTML form's elements collection |
|
795 * and return a string comprised of key-value pairs. |
|
796 * |
|
797 * @method _serialize |
|
798 * @private |
|
799 * @static |
|
800 * @param {object} o - YUI form node or HTML form id. |
|
801 * @return string |
|
802 */ |
|
803 _serialize: function(o) { |
|
804 var eUC = encodeURIComponent, |
|
805 data = [], |
|
806 useDf = o.useDisabled || false, |
|
807 item = 0, |
|
808 e, f, n, v, d, i, ilen, j, jlen, o, |
|
809 id = (typeof o.id === 'string') ? o.id : o.id.getAttribute('id'); |
|
810 |
|
811 if (!id) { |
|
812 id = Y.guid('io:'); |
|
813 o.id.setAttribute('id', id); |
|
814 } |
|
815 |
|
816 f = Y.config.doc.getElementById(id); |
|
817 |
|
818 // Iterate over the form elements collection to construct the |
|
819 // label-value pairs. |
|
820 for (i = 0, ilen = f.elements.length; i < ilen; ++i) { |
|
821 e = f.elements[i]; |
|
822 d = e.disabled; |
|
823 n = e.name; |
|
824 |
|
825 if ((useDf) ? n : (n && !d)) { |
|
826 n = encodeURIComponent(n) + '='; |
|
827 v = encodeURIComponent(e.value); |
|
828 |
|
829 switch (e.type) { |
|
830 // Safari, Opera, FF all default options.value from .text if |
|
831 // value attribute not specified in markup |
|
832 case 'select-one': |
|
833 if (e.selectedIndex > -1) { |
|
834 o = e.options[e.selectedIndex]; |
|
835 data[item++] = n + eUC((o.attributes.value && o.attributes.value.specified) ? o.value : o.text); |
|
836 } |
|
837 break; |
|
838 case 'select-multiple': |
|
839 if (e.selectedIndex > -1) { |
|
840 for (j = e.selectedIndex, jlen = e.options.length; j < jlen; ++j) { |
|
841 o = e.options[j]; |
|
842 if (o.selected) { |
|
843 data[item++] = n + eUC((o.attributes.value && o.attributes.value.specified) ? o.value : o.text); |
|
844 } |
|
845 } |
|
846 } |
|
847 break; |
|
848 case 'radio': |
|
849 case 'checkbox': |
|
850 if(e.checked){ |
|
851 data[item++] = n + v; |
|
852 } |
|
853 break; |
|
854 case 'file': |
|
855 // stub case as XMLHttpRequest will only send the file path as a string. |
|
856 case undefined: |
|
857 // stub case for fieldset element which returns undefined. |
|
858 case 'reset': |
|
859 // stub case for input type reset button. |
|
860 case 'button': |
|
861 // stub case for input type button elements. |
|
862 break; |
|
863 case 'submit': |
|
864 default: |
|
865 data[item++] = n + v; |
|
866 } |
|
867 } |
|
868 } |
|
869 Y.log('HTML form serialized. The value is: ' + data.join('&'), 'info', 'io'); |
|
870 return data.join('&'); |
|
871 } |
|
872 }, true); |
|
873 |
|
874 |
|
875 |
|
876 }, '3.0.0b1' ,{requires:['io-base']}); |
|
877 |
|
878 YUI.add('io-xdr', function(Y) { |
|
879 |
|
880 /** |
|
881 * Extends the IO base class to provide an alternate, Flash transport, for making |
|
882 * cross-domain requests. |
|
883 * @module io |
|
884 * @submodule io-xdr |
|
885 */ |
|
886 |
|
887 /** |
|
888 * @event io:xdrReady |
|
889 * @description This event is fired by YUI.io when the specified transport is |
|
890 * ready for use. |
|
891 * @type Event Custom |
|
892 */ |
|
893 var E_XDR_READY = 'io:xdrReady'; |
|
894 |
|
895 /** |
|
896 * @description Method that creates the Flash transport swf. |
|
897 * |
|
898 * @method _swf |
|
899 * @private |
|
900 * @static |
|
901 * @param {string} uri - location of IO.swf. |
|
902 * @param {string} yid - YUI instance id. |
|
903 * @return void |
|
904 */ |
|
905 function _swf(uri, yid) { |
|
906 var XDR_SWF = '<object id="yuiIoSwf" type="application/x-shockwave-flash" data="' + |
|
907 uri + '" width="0" height="0">' + |
|
908 '<param name="movie" value="' + uri + '">' + |
|
909 '<param name="FlashVars" value="yid=' + yid + '">' + |
|
910 '<param name="allowScriptAccess" value="sameDomain">' + |
|
911 '</object>'; |
|
912 Y.get('body').appendChild(Y.Node.create(XDR_SWF)); |
|
913 } |
|
914 |
|
915 Y.mix(Y.io, { |
|
916 |
|
917 /** |
|
918 * @description Map of IO transports. |
|
919 * |
|
920 * @property _transport |
|
921 * @private |
|
922 * @static |
|
923 * @type object |
|
924 */ |
|
925 _transport: {}, |
|
926 |
|
927 /** |
|
928 * @description Object that stores callback handlers for cross-domain requests |
|
929 * when using Flash as the transport. |
|
930 * |
|
931 * @property _fn |
|
932 * @private |
|
933 * @static |
|
934 * @type object |
|
935 */ |
|
936 _fn: {}, |
|
937 |
|
938 /** |
|
939 * @description Method for accessing the transport's interface for making a |
|
940 * cross-domain transaction. |
|
941 * |
|
942 * @method _xdr |
|
943 * @private |
|
944 * @static |
|
945 * @param {string} uri - qualified path to transaction resource. |
|
946 * @param {object} o - Transaction object generated by _create() in io-base. |
|
947 * @param {object} c - configuration object for the transaction. |
|
948 * @return object |
|
949 */ |
|
950 _xdr: function(uri, o, c) { |
|
951 if (c.on) { |
|
952 this._fn[o.id] = c.on; |
|
953 } |
|
954 o.c.send(uri, c, o.id); |
|
955 |
|
956 return o; |
|
957 }, |
|
958 |
|
959 |
|
960 /** |
|
961 * @description Fires event "io:xdrReady" |
|
962 * |
|
963 * @method xdrReady |
|
964 * @private |
|
965 * @static |
|
966 * @param {number} id - transaction id |
|
967 * @param {object} c - configuration object for the transaction. |
|
968 * |
|
969 * @return void |
|
970 */ |
|
971 xdrReady: function(id) { |
|
972 Y.fire(E_XDR_READY, id); |
|
973 }, |
|
974 |
|
975 /** |
|
976 * @description Method to initialize the desired transport. |
|
977 * |
|
978 * @method transport |
|
979 * @public |
|
980 * @static |
|
981 * @param {object} o - object of transport configurations. |
|
982 * @return void |
|
983 */ |
|
984 transport: function(o) { |
|
985 switch (o.id) { |
|
986 case 'flash': |
|
987 _swf(o.src, o.yid); |
|
988 this._transport.flash = Y.config.doc.getElementById('yuiIoSwf'); |
|
989 break; |
|
990 } |
|
991 } |
|
992 }); |
|
993 |
|
994 |
|
995 |
|
996 }, '3.0.0b1' ,{requires:['io-base']}); |
|
997 |
|
998 YUI.add('io-upload-iframe', function(Y) { |
|
999 |
|
1000 /** |
|
1001 * Extends the IO base class to enable file uploads, with HTML forms, |
|
1002 * using an iframe as the transport medium. |
|
1003 * @module io |
|
1004 * @submodule io-upload-iframe |
|
1005 */ |
|
1006 |
|
1007 var w = Y.config.win; |
|
1008 /** |
|
1009 * @description Parses the POST data object and creates hidden form elements |
|
1010 * for each key-value, and appends them to the HTML form object. |
|
1011 * @method appendData |
|
1012 * @private |
|
1013 * @static |
|
1014 * @param {object} d The key-value hash map. |
|
1015 * @return {array} e Array of created fields. |
|
1016 */ |
|
1017 |
|
1018 function _addData(f, d) { |
|
1019 var e = [], |
|
1020 p, i; |
|
1021 |
|
1022 for (p in d) { |
|
1023 if (d.hasOwnProperty(d, p)) { |
|
1024 e[i] = document.createElement('input'); |
|
1025 e[i].type = 'hidden'; |
|
1026 e[i].name = p; |
|
1027 e[i].value = d[p]. |
|
1028 f.appendChild(e[i]); |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 return e; |
|
1033 } |
|
1034 |
|
1035 function _removeData(f, e) { |
|
1036 var i, l; |
|
1037 if (e && e.length > 0) { |
|
1038 for(i = 0, l = e.length; i < l; i++){ |
|
1039 f.removeChild(e[i]); |
|
1040 } |
|
1041 } |
|
1042 } |
|
1043 |
|
1044 function _create(o, c) { |
|
1045 var i = Y.Node.create('<iframe id="ioupload' + o.id + '" name="ioupload' + o.id + '" />'), |
|
1046 cfg = { |
|
1047 position: 'absolute', |
|
1048 top: '-1000px', |
|
1049 left: '-1000px' |
|
1050 }; |
|
1051 |
|
1052 i.setStyles(cfg); |
|
1053 Y.get('body').appendChild(i); |
|
1054 // Bind the onload handler to the iframe to detect the file upload response. |
|
1055 Y.on("load", function() { _handle(o, c) }, '#ioupload' + o.id); |
|
1056 } |
|
1057 |
|
1058 // Create the upload callback handler that fires when the iframe |
|
1059 // receives the load event. Subsequently, the event handler is detached |
|
1060 // and the iframe removed from the document. |
|
1061 function _handle(o, c) { |
|
1062 var p, |
|
1063 b = Y.get('#ioupload' + o.id).get('contentWindow.document.body'); |
|
1064 |
|
1065 if (c.timeout) { |
|
1066 _clearTimeout(o.id); |
|
1067 } |
|
1068 |
|
1069 // When a response Content-Type of "text/plain" is used, Firefox and Safari |
|
1070 // will wrap the response string with <pre></pre>. |
|
1071 p = b.query('pre:first-child'); |
|
1072 o.c.responseText = (p) ? p.get('innerHTML') : b.get('innerHTML'); |
|
1073 Y.io.complete(o, c); |
|
1074 // The transaction is complete, so call _destroy to remove |
|
1075 // the event listener bound to the iframe transport, and then |
|
1076 // destroy the iframe. |
|
1077 setTimeout( function() { _destroy(o.id); }, 0); |
|
1078 } |
|
1079 |
|
1080 /** |
|
1081 * @description Starts timeout count if the configuration object |
|
1082 * has a defined timeout property. |
|
1083 * |
|
1084 * @method _startTimeout |
|
1085 * @private |
|
1086 * @static |
|
1087 * @param {object} o Transaction object generated by _create(). |
|
1088 * @param {object} c Configuration object passed to YUI.io(). |
|
1089 * @return void |
|
1090 */ |
|
1091 function _startTimeout(o, c) { |
|
1092 Y.io._timeout[o.id] = w.setTimeout(function() { Y.io.abort(o, c); }, c.timeout); |
|
1093 } |
|
1094 |
|
1095 /** |
|
1096 * @description Clears the timeout interval started by _startTimeout(). |
|
1097 * |
|
1098 * @method _clearTimeout |
|
1099 * @private |
|
1100 * @static |
|
1101 * @param {number} id - Transaction id. |
|
1102 * @return void |
|
1103 */ |
|
1104 function _clearTimeout(id) { |
|
1105 w.clearTimeout(Y.io._timeout[id]); |
|
1106 delete Y.io._timeout[id]; |
|
1107 } |
|
1108 |
|
1109 function _destroy(id) { |
|
1110 Y.Event.purgeElement('#ioupload' + id, false); |
|
1111 Y.get('body').removeChild(Y.get('#ioupload' + id)); |
|
1112 Y.log('The iframe transport for transaction ' + id + 'has been destroyed.', 'info', 'io'); |
|
1113 } |
|
1114 |
|
1115 Y.mix(Y.io, { |
|
1116 |
|
1117 /** |
|
1118 * @description Uploads HTML form, inclusive of files/attachments, using the |
|
1119 * iframe created in createFrame to facilitate the transaction. |
|
1120 * @method _upload |
|
1121 * @private |
|
1122 * @static |
|
1123 * @param {o} o The transaction object |
|
1124 * @param {object} uri Qualified path to transaction resource. |
|
1125 * @param {object} c Configuration object for the transaction. |
|
1126 * @return {void} |
|
1127 */ |
|
1128 _upload: function(o, uri, c) { |
|
1129 var f = (typeof c.form.id === 'string') ? document.getElementById(c.form.id) : c.form.id, |
|
1130 e, fields, i, p, attr; |
|
1131 |
|
1132 _create(o, c); |
|
1133 // Track original HTML form attribute values. |
|
1134 attr = { |
|
1135 action: f.getAttribute('action'), |
|
1136 target: f.getAttribute('target') |
|
1137 }; |
|
1138 |
|
1139 // Initialize the HTML form properties in case they are |
|
1140 // not defined in the HTML form. |
|
1141 f.setAttribute('action', uri); |
|
1142 f.setAttribute('method', 'POST'); |
|
1143 f.setAttribute('target', 'ioupload' + o.id ); |
|
1144 f.setAttribute((Y.UA.ie && !document.documentMode) ? 'encoding' : 'enctype', 'multipart/form-data'); |
|
1145 |
|
1146 if (c.data) { |
|
1147 fields = _addData(f, c.data); |
|
1148 } |
|
1149 |
|
1150 // Start polling if a callback is present and the timeout |
|
1151 // property has been defined. |
|
1152 if (c.timeout) { |
|
1153 _startTimeout(o, c); |
|
1154 Y.log('Transaction timeout started for transaction ' + id + '.', 'info', 'io'); |
|
1155 } |
|
1156 |
|
1157 // Start file upload. |
|
1158 f.submit(); |
|
1159 Y.io.start(o.id, c); |
|
1160 |
|
1161 if (c.data) { |
|
1162 _removeData(f, fields); |
|
1163 } |
|
1164 |
|
1165 // Restore HTML form attributes to their original |
|
1166 // values prior to file upload. |
|
1167 for (p in attr) { |
|
1168 if (attr.hasOwnProperty(attr, p)) { |
|
1169 if (attr[p]) { |
|
1170 f.setAttribute(p, f[prop]); |
|
1171 } |
|
1172 else { |
|
1173 f.removeAttribute(p); |
|
1174 } |
|
1175 } |
|
1176 } |
|
1177 } |
|
1178 }); |
|
1179 |
|
1180 |
|
1181 |
|
1182 }, '3.0.0b1' ,{requires:['io-base']}); |
|
1183 |
|
1184 YUI.add('io-queue', function(Y) { |
|
1185 |
|
1186 /** |
|
1187 * Extends the IO base class to implement Queue for synchronous |
|
1188 * transaction processing. |
|
1189 * @module io |
|
1190 * @submodule io-queue |
|
1191 */ |
|
1192 |
|
1193 /** |
|
1194 * @description Array of transactions queued for processing |
|
1195 * |
|
1196 * @property _yQ |
|
1197 * @private |
|
1198 * @static |
|
1199 * @type Object |
|
1200 */ |
|
1201 var _q = new Y.Queue(), |
|
1202 |
|
1203 /** |
|
1204 * @description Reference to "io:complete" event handler. |
|
1205 * |
|
1206 * @property _e |
|
1207 * @private |
|
1208 * @static |
|
1209 * @type Object |
|
1210 */ |
|
1211 _e, |
|
1212 |
|
1213 _activeId, |
|
1214 /** |
|
1215 * @description Property to determine whether the queue is set to |
|
1216 * 1 (active) or 0 (inactive). When inactive, transactions |
|
1217 * will be stored in the queue until the queue is set to active. |
|
1218 * |
|
1219 * @property _qState |
|
1220 * @private |
|
1221 * @static |
|
1222 * @type int |
|
1223 */ |
|
1224 _qState = 1; |
|
1225 |
|
1226 /** |
|
1227 * @description Method for requesting a transaction, and queueing the |
|
1228 * request before it is sent to the resource. |
|
1229 * |
|
1230 * @method _queue |
|
1231 * @private |
|
1232 * @static |
|
1233 * @return Object |
|
1234 */ |
|
1235 function _queue(uri, c) { |
|
1236 var o = { uri: uri, id: Y.io._id(), cfg:c }; |
|
1237 |
|
1238 _q.add(o); |
|
1239 if (_qState === 1) { |
|
1240 _shift(); |
|
1241 } |
|
1242 |
|
1243 Y.log('Object queued. Transaction id is' + o.id, 'info', 'io'); |
|
1244 return o; |
|
1245 } |
|
1246 |
|
1247 /** |
|
1248 * @description Method Process the first transaction from the |
|
1249 * queue in FIFO order. |
|
1250 * |
|
1251 * @method _shift |
|
1252 * @private |
|
1253 * @static |
|
1254 * @return void |
|
1255 */ |
|
1256 function _shift() { |
|
1257 var o = _q.next(); |
|
1258 |
|
1259 _activeId = o.id; |
|
1260 _qState = 0; |
|
1261 Y.io(o.uri, o.cfg, o.id); |
|
1262 } |
|
1263 |
|
1264 /** |
|
1265 * @description Method for promoting a transaction to the top of the queue. |
|
1266 * |
|
1267 * @method _unshift |
|
1268 * @private |
|
1269 * @static |
|
1270 * @return void |
|
1271 */ |
|
1272 function _unshift(o) { |
|
1273 _q.promote(o); |
|
1274 } |
|
1275 |
|
1276 function _next(id) { |
|
1277 _qState = 1; |
|
1278 if (_activeId === id && _q.size() > 0) { |
|
1279 _shift(); |
|
1280 } |
|
1281 } |
|
1282 |
|
1283 /** |
|
1284 * @description Method for removing a specific, pending transaction from |
|
1285 * the queue. |
|
1286 * |
|
1287 * @method _remove |
|
1288 * @private |
|
1289 * @static |
|
1290 * @return void |
|
1291 */ |
|
1292 function _remove(o) { |
|
1293 _q.remove(o); |
|
1294 } |
|
1295 |
|
1296 function _start() { |
|
1297 _qState = 1; |
|
1298 |
|
1299 if (_q.size() > 0) { |
|
1300 _shift(); |
|
1301 } |
|
1302 Y.log('Queue started.', 'info', 'io'); |
|
1303 } |
|
1304 |
|
1305 /** |
|
1306 * @description Method for setting queue processing to inactive. |
|
1307 * Transaction requests to YUI.io.queue() will be stored in the queue, but |
|
1308 * not processed until the queue is reset to "active". |
|
1309 * |
|
1310 * @method _stop |
|
1311 * @private |
|
1312 * @static |
|
1313 * @return void |
|
1314 */ |
|
1315 function _stop() { |
|
1316 _qState = 0; |
|
1317 Y.log('Queue stopped.', 'info', 'io'); |
|
1318 }; |
|
1319 |
|
1320 /** |
|
1321 * @description Method to query the current size of the queue. |
|
1322 * |
|
1323 * @method _size |
|
1324 * @private |
|
1325 * @static |
|
1326 * @return int |
|
1327 */ |
|
1328 function _size() { |
|
1329 return _q.size(); |
|
1330 }; |
|
1331 |
|
1332 _e = Y.on('io:complete', function(id) { _next(id); }, Y.io); |
|
1333 |
|
1334 /** |
|
1335 * @description Method to query the current size of the queue, or to |
|
1336 * set a maximum queue size. This is the interface for _size(). |
|
1337 * |
|
1338 * @method size |
|
1339 * @public |
|
1340 * @static |
|
1341 * @param {number} i - Specified maximum size of queue. |
|
1342 * @return number |
|
1343 */ |
|
1344 _queue.size = _size; |
|
1345 |
|
1346 /** |
|
1347 * @description Method for setting the queue to active. If there are |
|
1348 * transactions pending in the queue, they will be processed from the |
|
1349 * queue in FIFO order. This is the interface for _start(). |
|
1350 * |
|
1351 * @method start |
|
1352 * @public |
|
1353 * @static |
|
1354 * @return void |
|
1355 */ |
|
1356 _queue.start = _start; |
|
1357 |
|
1358 /** |
|
1359 * @description Method for setting queue processing to inactive. |
|
1360 * Transaction requests to YUI.io.queue() will be stored in the queue, but |
|
1361 * not processed until the queue is restarted. This is the |
|
1362 * interface for _stop(). |
|
1363 * |
|
1364 * @method stop |
|
1365 * @public |
|
1366 * @static |
|
1367 * @return void |
|
1368 */ |
|
1369 _queue.stop = _stop; |
|
1370 |
|
1371 /** |
|
1372 * @description Method for promoting a transaction to the top of the queue. |
|
1373 * This is the interface for _unshift(). |
|
1374 * |
|
1375 * @method promote |
|
1376 * @public |
|
1377 * @static |
|
1378 * @param {Object} o - Reference to queued transaction. |
|
1379 * @return void |
|
1380 */ |
|
1381 _queue.promote = _unshift; |
|
1382 |
|
1383 /** |
|
1384 * @description Method for removing a specific, pending transaction from |
|
1385 * the queue. This is the interface for _purge(). |
|
1386 * |
|
1387 * @method purge |
|
1388 * @public |
|
1389 * @static |
|
1390 * @param {Object} o - Reference to queued transaction. |
|
1391 * @return void |
|
1392 */ |
|
1393 _queue.remove = _remove; |
|
1394 |
|
1395 Y.mix(Y.io, { |
|
1396 queue: _queue |
|
1397 }, true); |
|
1398 |
|
1399 |
|
1400 |
|
1401 }, '3.0.0b1' ,{requires:['io-base']}); |
|
1402 |
|
1403 |
|
1404 |
|
1405 YUI.add('io', function(Y){}, '3.0.0b1' ,{use:['io-base', 'io-form', 'io-xdr', 'io-upload-iframe', 'io-queue']}); |
|
1406 |