datasource-debug.js revision 9593cd5be06a4d8436ea33c4ac3620c4c0243c91
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshYUI.add('datasource-base', function(Y) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * The DataSource utility provides a common configurable interface for widgets to
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * access a variety of data, from JavaScript arrays to online database servers.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @module datasource
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @requires base
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @title DataSource Utility
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadibvar LANG = Y.Lang,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Base class for the YUI DataSource utility.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @class DataSource
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @extends Base
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @constructor
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshDSLocal = function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh DSLocal.superclass.constructor.apply(this, arguments);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh};
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // DataSource static properties
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.mix(DSLocal, {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Class name.
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould *
16a8c7d5e433b176636a4a1260c42ea43932110bKrzysztof Kosiński * @property DataSource.NAME
54e660c4de9d37185e3953165d053526632ef4f0johanengelen * @type String
54e660c4de9d37185e3953165d053526632ef4f0johanengelen * @static
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @final
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @value "DataSource.Local"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh NAME: "DataSource.Local",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // DataSource Attributes
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ATTRS: {
dd69425007680aafc47fdd994e1985625571d252bryce /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @attribute source
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @description Pointer to live data.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type MIXED
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @default null
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh source: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh value: null
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Global transaction counter.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @property DataSource._tId
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @type Number
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @static
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @private
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @default 0
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh _tId: 0,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Executes a given callback. The third param determines whether to execute
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method DataSource.issueCallback
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param callback {Object} The callback object.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param params {Array} params to be passed to the callback method
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param error {Boolean} whether an error occurred
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @static
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh issueCallback: function (response) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if(response.callback) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var scope = response.callback.scope || window,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh callbackFunc = (response.error && response.callback.failure) || response.callback.success;
d444ed610362dab3c3e727d1b110312318b84cb8miklosh if (callbackFunc) {
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould callbackFunc.apply(scope, [response]);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.extend(DSLocal, Y.Base, {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @property _queue
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @description Object literal to manage asynchronous request/response
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * cycles enabled if queue needs to be managed (asyncMode/xhrConnMode):
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dt>interval {Number}</dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dd>Interval ID of in-progress queue.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dt>conn</dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dd>In-progress connection identifier (if applicable).</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dt>requests {Object[]}</dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <dd>Array of queued request objects: {request:oRequest, callback:_xhrCallback}.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type Object
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @default {interval:null, conn:null, requests:[]}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @private
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen _queue: null,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method initializer
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @description Internal init() handler.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @private
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh initializer: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._queue = {interval:null, conn:null, requests:[]};
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._initEvents();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method destructor
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @description Internal destroy() handler.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @private
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh destructor: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method _createEvents
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @description This method creates all the events for this module
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Target and publishes them so we get Event Bubbling.
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen * @private
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh _initEvents: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Fired when a data request is received.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @event request
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dl>
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>request (Object)</dt> <dd>The request.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>callback (Object)</dt> <dd>The callback object.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @preventable _defRequestFn
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //this.publish("request", {defaultFn: this._defRequestFn});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.publish("request", {defaultFn:function(e, o){
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._defRequestFn(e, o);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Fired when raw data is received.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @event data
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dl>
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>request (Object)</dt> <dd>The request.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>callback (Object)</dt> <dd>The callback object.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>data (Object)</dt> <dd>The raw data.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * </dl>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @preventable _defDataFn
05a66d0771cb563225b8690de04e9490b35453f2johanengelen */
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //this.publish("data", {defaultFn: this._defDataFn});
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.publish("data", {defaultFn:function(e, o){
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this._defDataFn(e, o);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen }});
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen /**
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * Fired when response is returned.
05a66d0771cb563225b8690de04e9490b35453f2johanengelen *
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @event response
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @param e {Event.Facade} Event Facade.
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @param o {Object} Object with the following properties:
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dl>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>request (Object)</dt> <dd>The request.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>callback (Object)</dt> <dd>The callback object.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>data (Object)</dt> <dd>The raw data.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>results (Object)</dt> <dd>Parsed results.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>meta (Object)</dt> <dd>Parsed meta results data.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @preventable _defResponseFn
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //this.publish("response", {defaultFn: this._defResponseFn});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.publish("response", {defaultFn:function(e, o){
d5ad05ac17abfd7d2eae333a8c1233971e1c1a8fAbhishek Sharma Public this._defResponseFn(e, o);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
7cc06cc17ffc875601993118f9533dfe36bd2dd5johanengelen * Fired when an error is encountered.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
7cc06cc17ffc875601993118f9533dfe36bd2dd5johanengelen * @event error
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @param o {Object} Object with the following properties:
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dl>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>request (Object)</dt> <dd>The request.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>callback (Object)</dt> <dd>The callback object.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>data (Object)</dt> <dd>The raw data (if available).</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>results (Object)</dt> <dd>Parsed results (if available).</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>meta (Object)</dt> <dd>Parsed meta results data (if available).</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * </dl>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac */
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac },
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac /**
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * Manages request/response transaction. Must fire <code>response</code>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * event when response is received. This method should be implemented by
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * subclasses to achieve more complex behavior such as accessing remote data.
68b9e386db1a231abaddbfed4d05f7539bdac786scislac *
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @method _defRequestFn
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @param e {Event.Facade} Event Facade.
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @param o {Object} Object with the following properties:
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * <dl>
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>request (Object)</dt> <dd>The request.</dd>
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * <dt>callback (Object)</dt> <dd>The callback object.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * </dl>
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @protected
05a66d0771cb563225b8690de04e9490b35453f2johanengelen */
05a66d0771cb563225b8690de04e9490b35453f2johanengelen _defRequestFn: function(e, o) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var data = this.get("source");
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
05a66d0771cb563225b8690de04e9490b35453f2johanengelen // Problematic data
05a66d0771cb563225b8690de04e9490b35453f2johanengelen if(LANG.isUndefined(data)) {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen o.error = true;
05a66d0771cb563225b8690de04e9490b35453f2johanengelen }
05a66d0771cb563225b8690de04e9490b35453f2johanengelen if(o.error) {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.fire("error", null, o);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen Y.log("Error in response", "error", this.toString());
05a66d0771cb563225b8690de04e9490b35453f2johanengelen }
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.fire("data", null, Y.mix(o, {data:data}));
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould Y.log("Transaction " + e.tId + " complete. Request: " +
05a66d0771cb563225b8690de04e9490b35453f2johanengelen Y.dump(o.request) + " . Response: " + Y.dump(o.response), "info", this.toString());
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
05a66d0771cb563225b8690de04e9490b35453f2johanengelen /**
54e660c4de9d37185e3953165d053526632ef4f0johanengelen * Normalizes raw data into a response that includes results and meta properties.
05a66d0771cb563225b8690de04e9490b35453f2johanengelen *
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @method _defDataFn
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dl>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>request (Object)</dt> <dd>The request.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>callback (Object)</dt> <dd>The callback object.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * <dt>data (Object)</dt> <dd>The raw response data.</dd>
05a66d0771cb563225b8690de04e9490b35453f2johanengelen * </dl>
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould * @protected
05a66d0771cb563225b8690de04e9490b35453f2johanengelen */
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould _defDataFn: function(e, o) {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen // Pass through data as-is
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould o.results = o.data;
54e660c4de9d37185e3953165d053526632ef4f0johanengelen
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Normalize
68b9e386db1a231abaddbfed4d05f7539bdac786scislac if(!o.results) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac o.results = [];
68b9e386db1a231abaddbfed4d05f7539bdac786scislac }
68b9e386db1a231abaddbfed4d05f7539bdac786scislac if(!o.meta) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac o.meta = {};
68b9e386db1a231abaddbfed4d05f7539bdac786scislac }
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.fire("response", null, o);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac },
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac /**
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * Sends data as a normalized response to callback.
68b9e386db1a231abaddbfed4d05f7539bdac786scislac *
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @method _defResponseFn
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @param e {Event.Facade} Event Facade.
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * @param o {Object} Object with the following properties:
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dl>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>request (Object)</dt> <dd>The request.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>callback (Object)</dt> <dd>The callback object.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>data (Object)</dt> <dd>Raw data.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>results (Object)</dt> <dd>Parsed results.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
68b9e386db1a231abaddbfed4d05f7539bdac786scislac * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @protected
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh _defResponseFn: function(e, o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Send the response back to the callback
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh DSLocal.issueCallback(o);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould /**
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * Generates a unique transaction ID and fires <code>request</code> event.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method sendRequest
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param request {Object} Request.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param callback {Object} An object literal with the following properties:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dl>
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * <dt><code>success</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>The function to call when the data is ready.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>failure</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>The function to call upon a response failure condition.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>scope</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>The object to serve as the scope for the success and failure handlers.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>argument</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>Arbitrary data payload that will be passed back to the success and failure handlers.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @return {Number} Transaction ID.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh sendRequest: function(request, callback) {
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen var tId = DSLocal._tId++;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.fire("request", null, {tId:tId, request:request,callback:callback});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log("Transaction " + tId + " sent request: " + Y.dump(request), "info", this.toString());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return tId;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.namespace("DataSource");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.DataSource.Local = DSLocal;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh}, '@VERSION@' ,{requires:['base']});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshYUI.add('datasource-xhr', function(Y) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * The DataSource utility provides a common configurable interface for widgets to
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * access a variety of data, from JavaScript arrays to online database servers.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @module datasource-xhr
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @requires datasource-base
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @title DataSource XHR Submodule
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * XHR subclass for the YUI DataSource utility.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @class DataSource.XHR
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @extends DataSource
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @constructor
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshvar DSXHR = function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh DSXHR.superclass.constructor.apply(this, arguments);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh};
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // DataSource.XHR static properties
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.mix(DSXHR, {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Class name.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @property DataSource.XHR.NAME
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type String
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @static
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @final
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @value "DataSource.XHR"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib NAME: "DataSource.XHR",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen // DataSource.XHR Attributes
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen //
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ATTRS: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Pointer to IO Utility.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @attribute io
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type Y.io
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @default Y.io
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib io: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh value: Y.io
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.extend(DSXHR, Y.DataSource.Local, {
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Passes query string to IO. Fires <code>response</code> event when
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * response is received asynchronously.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method _defRequestFn
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * <dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>request (Object)</dt> <dd>The request.</dd>
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * <dt>callback (Object)</dt> <dd>The callback object.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @protected
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh _defRequestFn: function(e, o) {
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen var uri = this.get("source"),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh cfg = {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh on: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh success: function (id, response, o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.fire("data", null, Y.mix(o, {data:response}));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log("Received XHR data response for \"" + o.request + "\"", "info", this.toString());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //{tId:args.tId, request:args.request, callback:args.callback, response:response}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //this.handleResponse(args.tId, args.request, args.callback, response);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh failure: function (id, response, o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh o.error = true;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.fire("error", null, Y.mix(o, {data:response}));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.fire("data", null, Y.mix(o, {data:response}));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log("Received XHR data response for \"" + o.request + "\"", "info", this.toString());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //{tId:args.tId, request:args.request, callback:args.callback, response:response}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //this.handleResponse(args.tId, args.request, args.callback, response);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh context: this,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh arguments: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh tId: o.tId,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh request: o.request,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh callback: o.callback
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen }
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen };
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.get("io")(uri, cfg);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return o.tId;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib});
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed GouldY.DataSource.XHR = DSXHR;
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould}, '@VERSION@' ,{requires:['datasource-base']});
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadibYUI.add('datasource-cache', function(Y) {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould/**
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * Extends DataSource with caching functionality.
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib *
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib * @module datasource-cache
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib * @requires plugin, datasource-base, cache
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib * @title DataSource Cache Plugin
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong */
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould/**
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould * Adds cacheability to the YUI DataSource utility.
d5ad05ac17abfd7d2eae333a8c1233971e1c1a8fAbhishek Sharma Public * @class DataSourceCache
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould */
3bd80e038b72ad220f218d7053a9089685fab17cTed Gouldvar DataSourceCache = function() {
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould DataSourceCache.superclass.constructor.apply(this, arguments);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib};
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
3bd80e038b72ad220f218d7053a9089685fab17cTed GouldY.mix(DataSourceCache, {
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould /**
479ed85bac2b7467a6678bae572404e33465a5d9acspike * The namespace for the plugin. This will be the property on the host which
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * references the plugin instance.
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould *
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould * @property NS
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @type String
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @static
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould * @final
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould * @value "cache"
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould */
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould NS: "cache",
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib /**
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * Class name.
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould *
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @property DataParser.Base.NAME
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib * @type String
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @static
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @final
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @value "DataSourceCache"
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould */
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould NAME: "DataSourceCache",
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould /////////////////////////////////////////////////////////////////////////////
d5ad05ac17abfd7d2eae333a8c1233971e1c1a8fAbhishek Sharma Public //
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould // DataSourceCache Attributes
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib //
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib /////////////////////////////////////////////////////////////////////////////
09ba3247163582bf2e30e17c4c154aa259ce038acilix
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould ATTRS: {
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould }
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib});
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould
3bd80e038b72ad220f218d7053a9089685fab17cTed GouldY.extend(DataSourceCache, Y.Cache, {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib /**
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @method initializer
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @description Internal init() handler.
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * @private
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib */
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib initializer: function(config) {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib this.doBefore("_defRequestFn", this._beforeDefRequestFn);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould this.doBefore("_defResponseFn", this._beforeDefResponseFn);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib },
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib /**
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * First look for cached response, then send request to live data.
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib *
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * @method _beforeDefRequestFn
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak * <dl>
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak * <dt>request (Object)</dt> <dd>The request.</dd>
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak * <dt>callback (Object)</dt> <dd>The callback object.</dd>
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak * </dl>
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib * @protected
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib */
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib _beforeDefRequestFn: function(e, o) {
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib // Is response already in the Cache?
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib var entry = (this.retrieve(o.request)) || null;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if(entry && entry.response) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._owner.fire("response", null, Y.mix(o, entry.response));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return new Y.Do.Halt("DataSourceCache plugin halted _defRequestFn");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //BASE.issueCallback(entry.response);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //return new Y.Do.Halt("msg", "newRetVal");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Adds data to cache before returning data.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method _beforeResponse
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param e {Event.Facade} Event Facade.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param o {Object} Object with the following properties:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>request (Object)</dt> <dd>The request.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>callback (Object)</dt> <dd>The callback object.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>data (Object)</dt> <dd>Raw data.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>results (Object)</dt> <dd>Parsed results.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @protected
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh _beforeDefResponseFn: function(e, o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Add to Cache before returning
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.add(o.request, o, (o.callback && o.callback.argument));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.namespace('plugin');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.plugin.DataSourceCache = DataSourceCache;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh}, '@VERSION@' ,{requires:['plugin', 'datasource-base', 'cache']});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyakYUI.add('datasource-jsonparser', function(Y) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Extends DataSource with schema-based JSON parsing functionality.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @module datasource-jsonparser
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @requires plugin, datasource-base, dataparser-json
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @title DataSource JSONParser Plugin
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Adds parsability to the YUI DataSource utility.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @class DataSourceJSONParser
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshvar DataSourceJSONParser = function() {
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen DataSourceJSONParser.superclass.constructor.apply(this, arguments);
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen};
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen
e66a49aa774c6770e99591a19873105bfeb5ce74Johan EngelenY.mix(DataSourceJSONParser, {
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * The namespace for the plugin. This will be the property on the host which
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * references the plugin instance.
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @property NS
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type String
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @static
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong * @final
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @value "cache"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh NS: "parser",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen /**
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen * Class name.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @property DataParser.Base.NAME
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @type String
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @static
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @final
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @value "DataSourceCache"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh NAME: "DataSourceJSONParser",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
09ba3247163582bf2e30e17c4c154aa259ce038acilix /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //
6825a6097da27fdfdf22859c0f81c208e7e22bb4Johan Engelen // DataSourceCache Attributes
6825a6097da27fdfdf22859c0f81c208e7e22bb4Johan Engelen //
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /////////////////////////////////////////////////////////////////////////////
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould ATTRS: {
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould parser: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh readOnly: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh value: Y.DataParser.JSON,
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould useRef: true
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
09ff61b38270862163a561a7f45acb203db68625Johan Engelen schema: {
09ff61b38270862163a561a7f45acb203db68625Johan Engelen //value: {}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
d5ad05ac17abfd7d2eae333a8c1233971e1c1a8fAbhishek Sharma Public }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh});
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
e9b6af083e34e2397a8ddbe9781920733d09d151Ted GouldY.extend(DataSourceJSONParser, Y.Plugin, {
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould /**
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @method initializer
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @description Internal init() handler.
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @private
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould */
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould initializer: function(config) {
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould this.doBefore("_defDataFn", this._beforeDefDataFn);
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould },
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould /**
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong * Parses raw data into a normalized response.
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib *
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @method _defDataFn
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak * @param e {Event.Facade} Event Facade.
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * @param o {Object} Object with the following properties:
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak * <dl>
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński * <dt>request (Object)</dt> <dd>The request.</dd>
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński * <dt>callback (Object)</dt> <dd>The callback object.</dd>
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński * <dt>data (Object)</dt> <dd>The raw response.</dd>
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak * </dl>
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński * @protected
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak */
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak _beforeDefDataFn: function(e, o) {
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak var response = (this.get("parser").parse(this.get("schema"), o.data));
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak if(!response) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh response = {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh meta: {},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh results: o.data
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh };
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._owner.fire("response", null, Y.mix(o, response));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return new Y.Do.Halt("DataSourceJSONParser plugin halted _defDataFn");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh});
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.namespace('plugin');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.plugin.DataSourceJSONParser = DataSourceJSONParser;
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh}, '@VERSION@' ,{requires:['plugin', 'datasource-base', 'dataparser-json']});
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshYUI.add('datasource-polling', function(Y) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/**
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen * Extends DataSource with polling functionality.
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg *
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg * @module datasource-polling
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg * @requires datasource-base
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @title DataSource Polling Extension
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var LANG = Y.Lang,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Adds polling to the YUI DataSource utility.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @class Pollable
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Pollable = function() {};
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyakPollable.prototype = {
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak /**
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak * @property _intervals
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak * @description Array of polling interval IDs that have been enabled,
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak * stored here to be able to clear all intervals.
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak * @private
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak */
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak _intervals: null,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Sets up a polling mechanism to send requests at set intervals and forward
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * responses to given callback.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method setInterval
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param msec {Number} Length of interval in milliseconds.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param request {Object} Request object.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param callback {Object} An object literal with the following properties:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>success</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>The function to call when the data is ready.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>failure</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>The function to call upon a response failure condition.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>scope</code></dt>
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould * <dd>The object to serve as the scope for the success and failure handlers.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dt><code>argument</code></dt>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * <dd>Arbitrary data that will be passed back to the success and failure handlers.</dd>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * </dl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @return {Number} Interval ID.
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh setInterval: function(msec, request, callback) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if(LANG.isNumber(msec) && (msec >= 0)) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log("Enabling polling to live data for \"" + Y.dump(request) + "\" at interval " + msec, "info", this.toString());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var self = this,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh id = setInterval(function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh self.sendRequest(request, callback);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //self._makeConnection(request, callback);
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen }, msec);
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg if(!this._intervals) {
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg this._intervals = [];
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this._intervals.push(id);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return id;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
533909ea7bb06d8f0658b7d448fa4283afd3f52ftavmjong else {
533909ea7bb06d8f0658b7d448fa4283afd3f52ftavmjong Y.log("Could not enable polling to live data for \"" + Y.dump(request) + "\" at interval " + msec, "info", this.toString());
533909ea7bb06d8f0658b7d448fa4283afd3f52ftavmjong }
533909ea7bb06d8f0658b7d448fa4283afd3f52ftavmjong },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /**
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Disables polling mechanism associated with the given interval ID.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh *
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @method clearInterval
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * @param id {Number} Interval ID.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh clearInterval: function(id) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Remove from tracker if there
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var tracker = this._intervals || [],
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh i = tracker.length-1;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh for(; i>-1; i--) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if(tracker[i] === id) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh tracker.splice(i,1);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh clearInterval(id);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh};
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshY.Base.build(Y.DataSource.Local.NAME, Y.DataSource.Local, [Pollable], {dynamic:false});
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh}, '@VERSION@' ,{requires:['datasource-base']});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshYUI.add('datasource', function(Y){}, '@VERSION@' ,{use:['datasource-base','datasource-xhr','datasource-cache','datasource-jsonparser','datasource-polling']});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh