datasource-function.js revision 1e0aa6df8881a856ec262f103bfee1c0a05d19b9
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * The DataSource utility provides a common configurable interface for widgets to
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * access a variety of data, from JavaScript arrays to online database servers.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @module datasource
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * Function subclass for the YUI DataSource utility.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @class DataSource.Function
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @extends DataSource.Local
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @constructor
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly DSFn = function() {
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly DSFn.superclass.constructor.apply(this, arguments);
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly // DataSource.Function static properties
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @property NAME
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @type String
1e0aa6df8881a856ec262f103bfee1c0a05d19b9Jenny Han Donnelly * @value "dataSourceFunction"
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly // DataSource.Function Attributes
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @attribute source
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @description Pointer to live data.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @default null
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * Context in which to execute the function. By default, is the DataSource
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * instance itself. If set, the function will receive the DataSource instance
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * as an additional argument.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @property scope
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @type Object
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @default null
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * Internal init() handler.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @method initializer
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @param config {Object} Config object.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * Passes query string to IO. Fires <code>response</code> event when
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * response is received asynchronously.
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @method _defRequestFn
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * @param e {Event.Facade} Event Facade with the following properties:
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>request (Object)</dt> <dd>The request.</dd>
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>success (Function)</dt> <dd>Success handler.</dd>
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly * <dt>scope (Object)</dt> <dd>Execution context.</dd>
65b755664437543e907b9557027a4a608cc84c31Jenny Han Donnelly * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly response = fn.call(scope, e.request, this, e);
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly this.fire("data", Y.mix({data:response}, e));
4de851bb1d7d556b60e05085a888a1cf06f2b271Jenny Han Donnelly e.error = new Error(this.toString() + " Data failure");