datasource.js revision cfbefb0190a726e75555eb731e4b73a49573eff9
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * The DataSource utility provides a common configurable interface for widgets to
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * access a variety of data, from JavaScript arrays to online database servers.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @module datasource
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Base class for the YUI DataSource utility.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @class DataSource.Local
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @extends Base
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @constructor
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts DSLocal.superclass.constructor.apply(this, arguments);
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource static properties
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Class name.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @property NAME
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @type String
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @value "dataSourceLocal"
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource Attributes
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @attribute source
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @description Pointer to live data.
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @type MIXED
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @default null
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Global transaction counter.
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @property DataSource._tId
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @type Number
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * Executes a given callback. The third param determines whether to execute
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @method DataSource.issueCallback
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @param callback {Object} The callback object.
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @param params {Array} params to be passed to the callback method
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @param error {Boolean} whether an error occurred
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna issueCallback: function (e) {
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna var callbackFunc = (e.error && e.callback.failure) || e.callback.success;
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * Internal init() handler.
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @method initializer
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @param config {Object} Config object.
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * This method creates all the events for this module.
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * @method _initEvents
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * Fired when a data request is received.
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * @event request
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @param e {Event.Facade} Event Facade with the following properties:
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>request (Object)</dt> <dd>The request.</dd>
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * <dt>callback (Object)</dt> <dd>The callback object.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * @preventable _defRequestFn
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna this.publish("request", {defaultFn: Y.bind("_defRequestFn", this), queuable:true});
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * Fired when raw data is received.
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * @event data
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * @param e {Event.Facade} Event Facade with the following properties:
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>request (Object)</dt> <dd>The request.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>success (Function)</dt> <dd>Success handler.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>data (Object)</dt> <dd>Raw data.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @preventable _defDataFn
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest this.publish("data", {defaultFn: Y.bind("_defDataFn", this), queuable:true});
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * Fired when response is returned.
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * @event response
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * @param e {Event.Facade} Event Facade with the following properties:
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>request (Object)</dt> <dd>The request.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>success (Function)</dt> <dd>Success handler.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>data (Object)</dt> <dd>Raw data.</dd>
19624c21a7388e51e52731151ffb20ddf6597bf7James Phillpotts * <dt>response (Object)</dt> <dd>Normalized resopnse object with the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>results (Object)</dt> <dd>Parsed results.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
608e02664686ce4f4ca3743d81a889d14142a222Andrew Forrest * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @preventable _defResponseFn
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna this.publish("response", {defaultFn: Y.bind("_defResponseFn", this), queuable:true});
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * Fired when an error is encountered.
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @event error
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @param e {Event.Facade} Event Facade with the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>request (Object)</dt> <dd>The request.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>success (Function)</dt> <dd>Success handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * <dt>data (Object)</dt> <dd>Raw data.</dd>
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * <dt>response (Object)</dt> <dd>Normalized resopnse object with the following properties:
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * <dt>results (Object)</dt> <dd>Parsed results.</dd>
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * <dt>error (Object)</dt> <dd>Error object.</dd>
19624c21a7388e51e52731151ffb20ddf6597bf7James Phillpotts * Manages request/response transaction. Must fire <code>response</code>
d46a704b0f38f27472258f8a39b76f812155245fDavid Luna * event when response is received. This method should be implemented by
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * subclasses to achieve more complex behavior such as accessing remote data.
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * @method _defRequestFn
b4bc0f6f0effcc65edf83eec1e8747d5fce55752David Luna * @param e {Event.Facade} Event Facadewith the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>request (Object)</dt> <dd>The request.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>success (Function)</dt> <dd>Success handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @protected
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna // Problematic data
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * Normalizes raw data into a response that includes results and meta properties.
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @method _defDataFn
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @param e {Event.Facade} Event Facade with the following properties:
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>request (Object)</dt> <dd>The request.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * <dt>success (Function)</dt> <dd>Success handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * <dt>data (Object)</dt> <dd>Raw data.</dd>
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @protected
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna this.fire("response", Y.mix({response: response}, e));
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * Sends data as a normalized response to callback.
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @method _defResponseFn
4d07f71d21aed86fc86bb8f7a047e4138d39c4f4James Phillpotts * @param e {Event.Facade} Event Facade with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>request (Object)</dt> <dd>The request.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>success (Function)</dt> <dd>Success handler.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>data (Object)</dt> <dd>Raw data.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>response (Object)</dt> <dd>Normalized resopnse object with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>results (Object)</dt> <dd>Parsed results.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // Send the response back to the callback
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Generates a unique transaction ID and fires <code>request</code> event.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @method sendRequest
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @param request {Object} Request.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @param callback {Object} An object literal with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt><code>success</code></dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>The function to call when the data is ready.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt><code>failure</code></dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>The function to call upon a response failure condition.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt><code>argument</code></dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>Arbitrary data payload that will be passed back to the success and failure handlers.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @param cfg {Object} Configuration object
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @return {Number} Transaction ID.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts sendRequest: function(request, callback, cfg) {
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts this.fire("request", {tId:tId, request:request, callback:callback, cfg:cfg || {}});
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * The DataSource utility provides a common configurable interface for widgets to
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * access a variety of data, from JavaScript arrays to online database servers.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @module datasource
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * XHR subclass for the YUI DataSource utility.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @class DataSource.XHR
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @extends DataSource.Local
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @constructor
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpottsvar DSXHR = function() {
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts DSXHR.superclass.constructor.apply(this, arguments);
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource.XHR static properties
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Class name.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @property NAME
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @type String
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna * @value "dataSourceXHR"
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource.XHR Attributes
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Pointer to IO Utility.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @attribute io
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @default Y.io
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Internal init() handler.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @method initializer
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @param config {Object} Config object.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts this._queue = {interval:null, conn:null, requests:[]};
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @property _queue
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @description Object literal to manage asynchronous request/response
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * cycles enabled if queue needs to be managed (asyncMode/xhrConnMode):
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>interval {Number}</dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>Interval ID of in-progress queue.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>conn</dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>In-progress connection identifier (if applicable).</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>requests {Object[]}</dt>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dd>Array of queued request objects: {request:oRequest, callback:_xhrCallback}.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @type Object
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @default {interval:null, conn:null, requests:[]}
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Passes query string to IO. Fires <code>response</code> event when
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * response is received asynchronously.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @method _defRequestFn
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @param e {Event.Facade} Event Facade with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>request (Object)</dt> <dd>The request.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>success (Function)</dt> <dd>Success handler.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts this.fire("data", Y.mix({data:response}, e));
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts this.fire("error", Y.mix({data:response}, e));
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts this.fire("data", Y.mix({data:response}, e));
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts}, '@VERSION@' ,{requires:['datasource-local', 'io']});
63fcfdd800e1773bb54462cff066db6a312a99bbJames PhillpottsYUI.add('datasource-scriptnode', function(Y) {
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * The DataSource utility provides a common configurable interface for widgets to
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * access a variety of data, from JavaScript arrays to online database servers.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @module datasource
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Dynamic script node subclass for the YUI DataSource utility.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @class DataSource.ScriptNode
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @extends DataSource.Local
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @constructor
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpottsvar DSSN = function() {
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts DSSN.superclass.constructor.apply(this, arguments);
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource.ScriptNode static properties
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * Class name.
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @property NAME
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @type String
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts * @value "dataSourceScriptNode"
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts // DataSource.ScriptNode Attributes
63fcfdd800e1773bb54462cff066db6a312a99bbJames Phillpotts /////////////////////////////////////////////////////////////////////////////
get: {
cloneDefaultValue: false
* <dd>If a request is already in progress, wait until response is returned before sending the next request.</dd>
asyncMode: {
callbacks : [],
_defRequestFn: function(e) {
self = this;
}, this, id);
autopurge: true,
return e.tId;
DSFn = function() {
ATTRS: {
source: {
_defRequestFn: function(e) {
if(fn) {
return e.tId;
var DataSourceCache = function() {
ATTRS: {
_beforeDefRequestFn: function(e) {
_beforeDefResponseFn: function(e) {
var DataSourceJSONSchema = function() {
ATTRS: {
schema: {
_beforeDefDataFn: function(e) {
var data = (Y.DataSource.XHR && (this.get("host") instanceof Y.DataSource.XHR) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
if(!response) {
response = {
meta: {},
var DataSourceXMLSchema = function() {
ATTRS: {
schema: {
_beforeDefDataFn: function(e) {
var data = (Y.DataSource.XHR && (this.get("host") instanceof Y.DataSource.XHR) && e.data.responseXML && (e.data.responseXML.nodeType === 9)) ? e.data.responseXML : e.data,
if(!response) {
response = {
meta: {},
var DataSourceArraySchema = function() {
ATTRS: {
schema: {
_beforeDefDataFn: function(e) {
var data = ((this.get("host") instanceof Y.DataSource.XHR) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
if(!response) {
response = {
meta: {},
var DataSourceTextSchema = function() {
ATTRS: {
schema: {
_beforeDefDataFn: function(e) {
var data = (Y.DataSource.XHR && (this.get("host") instanceof Y.DataSource.XHR) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
if(!response) {
response = {
meta: {},
Pollable = function() {
this._intervals = {};
_intervals: null,
return x.id;
clearAllIntervals: function() {