io-xdr.js revision db6bcdca3c01def23cea443aa1bb08552d696ba6
/**
* Extends the IO base class to provide an alternate, Flash transport, for making
* cross-domain requests.
* @module io
* @submodule io-xdr
*/
/**
* @event io:xdrReady
* @description This event is fired by YUI.io when the specified transport is
* ready for use.
* @type Event Custom
*/
var E_XDR_READY = 'io:xdrReady';
/**
* @description Method that creates the Flash transport swf.
*
* @method _swf
* @private
* @static
* @param {string} uri - location of io.swf.
* @param {string} yid - YUI instance id.
* @return void
*/
var o = '<object id="yuiIoSwf" type="application/x-shockwave-flash" data="' +
uri + '" width="0" height="0">' +
'<param name="allowScriptAccess" value="always">' +
'</object>',
c.innerHTML = o;
}
function _ie(o, c) {
//o.c.onprogress
if (c.timeout) {
}
}
};
return r;
}
function _abort(o, c) {
}
function _isInProgress(o, t) {
return o.c.isInProgress(o.id);
}
/**
* @description Map of io transports.
*
* @property _transport
* @private
* @static
* @type object
*/
_transport: {},
/**
* @description Object that stores callback handlers for cross-domain requests
* when using Flash as the transport.
*
* @property _fn
* @private
* @static
* @type object
*/
_fn: {},
/**
* @description Method for accessing the transport's interface for making a
* cross-domain transaction.
*
* @method _xdr
* @private
* @static
* @param {string} uri - qualified path to transaction resource.
* @param {object} o - Transaction object generated by _create() in io-base.
* @param {object} c - configuration object for the transaction.
*/
if (c.on && t === 'flash') {
}
else if (window.XDomainRequest) {
_ie(o, c);
}
return {
isInProgress: function() { _isInProgress(o, t); }
}
},
/**
* @description Response controller for cross-domain requests when using the
* Flash transport or IE8's XDomainRequest object.
*
* @method xdrResponse
* @private
* @static
* @param {object} o - Transaction object generated by _create() in io-base.
* @param {object} c - configuration object for the transaction.
* @param {string} e - Event name
* @return object
*/
xdrResponse: function(o, c, e) {
var m, fn,
if (isFlash) {
if (fn) {
}
}
if (e === ('abort' || 'timeout')) {
o.status = e;
}
switch (e) {
case 'start':
break;
case 'success':
if (isFlash) {
delete m[o.id];
}
break;
case 'timeout':
case 'abort':
case 'failure':
if (isFlash) {
delete m[o.id];
}
break;
}
},
/**
* @description Fires event "io:xdrReady"
*
* @method xdrReady
* @private
* @static
* @param {number} id - transaction id
* @param {object} c - configuration object for the transaction.
*
* @return void
*/
},
/**
* @description Method to initialize the desired transport.
*
* @method transport
* @public
* @static
* @param {object} o - object of transport configurations.
* @return void
*/
transport: function(o) {
}
});