~bjornt/lazr-js/prefetch-yui-3.5

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/io/io-xdr.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-01-14 23:32:29 UTC
  • mfrom: (197.1.7 yui-3.3.0)
  • Revision ID: launchpad@pqm.canonical.com-20110114233229-r6i4cazdiiw18o7p
Upgrade to YUI 3.3.0 [r=mars]

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.2.0
6
 
build: 2676
 
5
version: 3.3.0
 
6
build: 3167
7
7
*/
8
8
YUI.add('io-xdr', function(Y) {
9
9
 
44
44
    */
45
45
    _rS = {},
46
46
 
47
 
    ie = w && w.XDomainRequest,
48
 
 
49
47
    // Document reference
50
48
    d = Y.config.doc,
51
49
    // Window reference
52
 
    w = Y.config.win;
 
50
    w = Y.config.win,
 
51
        // IE8 cross-origin request detection
 
52
    ie = w && w.XDomainRequest;
53
53
 
54
54
   /**
55
55
    * @description Method that creates the Flash transport swf.
126
126
            return { id: o.id, c: { responseText: s, responseXML: x } };
127
127
        }
128
128
        else {
129
 
            return { id: o.id, status: o.e };
 
129
            return { id: o.id, e: o.e };
130
130
        }
131
131
 
132
132
    }
181
181
        * @param {object} c - configuration object for the transaction.
182
182
        */
183
183
        xdr: function(uri, o, c) {
184
 
            if (c.on && c.xdr.use === 'flash') {
185
 
                _cB[o.id] = {
186
 
                    on: c.on,
187
 
                    context: c.context,
188
 
                    arguments: c.arguments
189
 
                };
190
 
                // These properties cannot be serialized across Flash's
191
 
                // ExternalInterface.  Doing so will result in exceptions.
192
 
                c.context = null;
193
 
                c.form = null;
194
 
                o.c.send(uri, c, o.id);
195
 
            }
196
 
            else if (ie) {
197
 
                _evt(o, c);
198
 
                o.c.open(c.method || 'GET', uri);
199
 
                o.c.send(c.data);
200
 
            }
201
 
            else {
202
 
                o.c.send(uri, o, c);
203
 
            }
204
 
 
205
 
            return {
206
 
                id: o.id,
207
 
                abort: function() {
208
 
                    return o.c ? _abort(o, c) : false;
209
 
                },
210
 
                isInProgress: function() {
211
 
                    return o.c ? _isInProgress(o.id) : false;
212
 
                }
213
 
            };
 
184
                        if (c.xdr.use === 'flash') {
 
185
                                _cB[o.id] = {
 
186
                                        on: c.on,
 
187
                                        context: c.context,
 
188
                                        arguments: c.arguments
 
189
                                };
 
190
                                // These properties cannot be serialized across Flash's
 
191
                                // ExternalInterface.  Doing so will result in exceptions.
 
192
                                c.context = null;
 
193
                                c.form = null;
 
194
 
 
195
                                w.setTimeout(function() {
 
196
                                        if (o.c && o.c.send) {
 
197
                                                o.c.send(uri, c, o.id);
 
198
                                        }
 
199
                                        else {
 
200
                                                Y.io.xdrResponse(o, c, 'transport error');
 
201
                                        }
 
202
                                }, Y.io.xdr.delay);
 
203
                        }
 
204
                        else if (ie) {
 
205
                                _evt(o, c);
 
206
                                o.c.open(c.method || 'GET', uri);
 
207
                                o.c.send(c.data);
 
208
                        }
 
209
                        else {
 
210
                                o.c.send(uri, o, c);
 
211
                        }
 
212
 
 
213
                        return {
 
214
                                id: o.id,
 
215
                                abort: function() {
 
216
                                        return o.c ? _abort(o, c) : false;
 
217
                                },
 
218
                                isInProgress: function() {
 
219
                                        return o.c ? _isInProgress(o.id) : false;
 
220
                                }
 
221
                        };
214
222
        },
215
223
 
216
224
       /**
241
249
                }
242
250
            }
243
251
 
244
 
            switch (e.toLowerCase()) {
 
252
            switch (e) {
245
253
                case 'start':
246
254
                    Y.io.start(o.id, c);
247
255
                    break;
249
257
                    Y.io.complete(o, c);
250
258
                    break;
251
259
                case 'success':
252
 
                    Y.io.success(t || f ?  _data(o, f, t) : o, c);
 
260
                    Y.io.success(t || f ? _data(o, f, t) : o, c);
253
261
                    delete m[o.id];
254
262
                    break;
255
263
                case 'timeout':
256
264
                case 'abort':
 
265
                                case 'transport error':
 
266
                                        o.e = e;
257
267
                case 'failure':
258
 
                    if (e === ('abort' || 'timeout')) {
259
 
                        o.e = e;
260
 
                    }
261
 
 
262
268
                    Y.io.failure(t || f ? _data(o, f, t) : o, c);
263
269
                    delete m[o.id];
264
270
                    break;
277
283
        * @return void
278
284
        */
279
285
        xdrReady: function(id) {
 
286
                        Y.io.xdr.delay = 0;
280
287
            Y.fire(E_XDR_READY, id);
281
288
        },
282
289
 
290
297
        * @return void
291
298
        */
292
299
        transport: function(o) {
293
 
            var id = o.yid ? o.yid : Y.id;
294
 
                o.id = o.id || 'flash';
295
 
 
296
 
            if (o.id === 'native' || o.id === 'flash') {
297
 
                _swf(o.src, id);
 
300
            var yid = o.yid || Y.id,
 
301
                                oid = o.id || 'flash',
 
302
                                src = Y.UA.ie ? o.src + '?d=' + new Date().valueOf().toString() : o.src;
 
303
 
 
304
            if (oid === 'native' || oid === 'flash') {
 
305
 
 
306
                                _swf(src, yid);
298
307
                this._transport.flash = d.getElementById('yuiIoSwf');
299
308
            }
300
 
            else {
 
309
            else if (oid) {
301
310
                this._transport[o.id] = o.src;
302
311
            }
303
312
        }
304
313
    });
305
314
 
306
 
 
307
 
 
308
 
}, '3.2.0' ,{requires:['io-base','datatype-xml']});
 
315
   /**
 
316
        * @description Delay value to calling the Flash transport, in the
 
317
        * event io.swf has not finished loading.  Once the E_XDR_READY
 
318
    * event is fired, this value will be set to 0.
 
319
        *
 
320
        * @property delay
 
321
        * @public
 
322
        * @static
 
323
        * @type number
 
324
        */
 
325
        Y.io.xdr.delay = 50;
 
326
 
 
327
 
 
328
 
 
329
}, '3.3.0' ,{requires:['io-base','datatype-xml']});