datasource-base.js revision 1bc27dc58fd882eb8902cdefa2dde4a8ee2a5bbd
9ad572a3ac0fd3845a9abecfbf41e8db9b3a5cf0vboxsyncYUI.add('datasource-base', function(Y) {
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
adf2bcd2e5d07d5a11553b88e147c1f4b2249bffvboxsync/**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * The DataSource utility provides a common configurable interface for widgets to
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * access a variety of data, from JavaScript arrays to online database servers.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * @module datasource
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @requires base
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @title DataSource Utility
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync Y.namespace("DataSource");
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync var DS = Y.DataSource,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync LANG = Y.Lang,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync /**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Base class for the YUI DataSource utility.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @class DataSource.Base
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @extends Base
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @constructor
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync DSBase = function() {
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync DSBase.superclass.constructor.apply(this, arguments);
70bb61ea2f96e80150e807529ce5df435607706bvboxsync };
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
23179f1443b03947d85eccc81cbc6b5153a4abf3vboxsync /////////////////////////////////////////////////////////////////////////////
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync //
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync // DataSource static properties
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync //
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync /////////////////////////////////////////////////////////////////////////////
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsyncY.mix(DS, {
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync /**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Global transaction counter.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @property DataSource._tId
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @type Number
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @static
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @private
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @default 0
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync _tId: 0,
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync /**
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * Indicates null data response.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @property DataSource.ERROR_DATANULL
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @type Number
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @static
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @final
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @default 0
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync ERROR_DATANULL: 0,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /**
b304856b23107864c9c594a80cebca6006623f31vboxsync * Indicates invalid data response.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @property DataSource.ERROR_DATAINVALID
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @type Number
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @static
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @final
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @default 1
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync ERROR_DATAINVALID: 1
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync});
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /////////////////////////////////////////////////////////////////////////////
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync //
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync // DataSource.Base static properties
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync //
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync /////////////////////////////////////////////////////////////////////////////
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsyncY.mix(DSBase, {
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync /**
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * Class name.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @property NAME
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * @type String
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @static
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * @final
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @value "DataSource.Base"
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync NAME: "DataSource.Base",
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /////////////////////////////////////////////////////////////////////////////
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync //
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync // DataSource.Base Attributes
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync //
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync /////////////////////////////////////////////////////////////////////////////
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync ATTRS: {
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync /**
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * @attribute source
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * @description Pointer to live data.
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * @type MIXED
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync * @default null
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync */
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync source: {
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync value: null
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync },
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync
2a5e5a032e6f23f8937718e4ee4d6979188bdd19vboxsync /**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @attribute ERROR_DATAINVALID
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @description Error message for invalid data responses.
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * @type String
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @default "Invalid data"
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
f62342e2cc901a67e27fa69c0e712ee35e9c4c68vboxsync ERROR_DATAINVALID: {
b604fbf16eda38d14b4999c245f032bfaa5aa85avboxsync value: "Invalid data"
13d1fd6f43e9a245a4f2b4fc6845bdaa5d0f4134vboxsync },
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /**
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @attribute ERROR_DATANULL
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @description Error message for null data responses.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @type String
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * @default "Null data"
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync */
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync ERROR_DATANULL: {
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync value: "Null data"
62a515eec8de1b7804ec6997c0f2013fef5c5a6bvboxsync }
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync },
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync /**
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * Executes a given callback. The third param determines whether to execute
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync *
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * @method issueCallback
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param callback {Object} The callback object.
19cb1f8699e352d590c4946caee33863a5157241vboxsync * @param params {Array} params to be passed to the callback method
19cb1f8699e352d590c4946caee33863a5157241vboxsync * @param error {Boolean} whether an error occurred
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @static
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync issueCallback: function (response) {
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync if(response.callback) {
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync var scope = response.callback.scope || window,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync callbackFunc = (response.error && response.callback.failure) || response.callback.success;
3933885bc0c2c93436d858a14564c6179ec72872vboxsync if (callbackFunc) {
3933885bc0c2c93436d858a14564c6179ec72872vboxsync callbackFunc.apply(scope, [response]);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync }
3933885bc0c2c93436d858a14564c6179ec72872vboxsync }
3933885bc0c2c93436d858a14564c6179ec72872vboxsync }
3933885bc0c2c93436d858a14564c6179ec72872vboxsync});
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsyncY.extend(DSBase, Y.Base, {
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync /**
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync * @property _queue
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync * @description Object literal to manage asynchronous request/response
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * cycles enabled if queue needs to be managed (asyncMode/xhrConnMode):
6e25221ce8ef8e656d1e15eb7ec5cf8ae758ceb2vboxsync <dl>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync <dt>interval {Number}</dt>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync <dd>Interval ID of in-progress queue.</dd>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync <dt>conn</dt>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync <dd>In-progress connection identifier (if applicable).</dd>
9ca017ceee656f9d33f2cb6652e401b5f17fcfb7vboxsync <dt>requests {Object[]}</dt>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync <dd>Array of queued request objects: {request:oRequest, callback:_xhrCallback}.</dd>
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync </dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @type Object
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @default {interval:null, conn:null, requests:[]}
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @private
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync _queue: null,
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
ad9e5a61fea617d40d07390ff1737277d6aef869vboxsync /**
dbabc9de5bf52ce5eb77cf82b038e9a6166c5a04vboxsync * @method initializer
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync * @description Internal init() handler.
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync * @private
40dce69ff1c2949a489337922f30f1021d62d864vboxsync */
40dce69ff1c2949a489337922f30f1021d62d864vboxsync initializer: function() {
40dce69ff1c2949a489337922f30f1021d62d864vboxsync this._queue = {interval:null, conn:null, requests:[]};
40dce69ff1c2949a489337922f30f1021d62d864vboxsync this._initEvents();
40dce69ff1c2949a489337922f30f1021d62d864vboxsync },
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync /**
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @method destructor
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @description Internal destroy() handler.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @private
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync */
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync destructor: function() {
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync },
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync /**
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @method _createEvents
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @description This method creates all the events for this module
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * Target and publishes them so we get Event Bubbling.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @private
b304856b23107864c9c594a80cebca6006623f31vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync _initEvents: function() {
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync /**
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * Fired when a data request is received.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync *
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @event request
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @param e {Event.Facade} Event Facade.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @param o {Object} Object with the following properties:
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dl>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync * </dl>
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync */
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync this.publish("request", {defaultFn: this._handleRequest});
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync /**
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync * Fired when raw data is received.
6e12ccc60ac657fb87e27b7a2b26e0a63bebe024vboxsync *
657b2c9f6d33f08001e5fa6f6e0572dcf0391013vboxsync * @event data
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync * @param e {Event.Facade} Event Facade.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param o {Object} Object with the following properties:
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dl>
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
9353e321b583ed6f2b42414257a5212885575b5cvboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dt>data (Object)</dt> <dd>The raw data.</dd>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * </dl>
fc5f879e9508f333e20b37c63db9189a33059308vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync this.publish("data", {defaultFn: this._handleData});
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
1c6ec9a3a329da6f61978a372e509cd233f0d9f9vboxsync /**
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * Fired when response is returned.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @event response
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param e {Event.Facade} Event Facade.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param o {Object} Object with the following properties:
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>data (Object)</dt> <dd>The raw data.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>results (Object)</dt> <dd>Parsed results.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>meta (Object)</dt> <dd>Parsed meta results data.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * </dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync */
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync this.publish("response", {defaultFn: this._handleResponse});
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync /**
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * Fired when an error is encountered.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @event error
f62342e2cc901a67e27fa69c0e712ee35e9c4c68vboxsync * @param e {Event.Facade} Event Facade.
b604fbf16eda38d14b4999c245f032bfaa5aa85avboxsync * @param o {Object} Object with the following properties:
13d1fd6f43e9a245a4f2b4fc6845bdaa5d0f4134vboxsync * <dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>data (Object)</dt> <dd>The raw data (if available).</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>results (Object)</dt> <dd>Parsed results (if available).</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>meta (Object)</dt> <dd>Parsed meta results data (if available).</dd>
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * <dt>error (Boolean)</dt> <dd>Error flag.</dd>
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * </dl>
95cb8e789c1eed6f2bb3195d0b996feee11d548evboxsync */
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
62a515eec8de1b7804ec6997c0f2013fef5c5a6bvboxsync },
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync /**
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * Overridable default <code>request</code> event handler manages request/response
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * transaction. Must fire <code>response</code> event when response is received. This
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * method should be implemented by subclasses to achieve more complex
cebc93936b5bb4d867e1c086dd1b206db33c31dcvboxsync * behavior such as accessing remote data.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync *
19cb1f8699e352d590c4946caee33863a5157241vboxsync * @method _handleRequest
19cb1f8699e352d590c4946caee33863a5157241vboxsync * @protected
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param e {Event.Facade} Event Facade.
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @param o {Object} Object with the following properties:
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * </dl>
3933885bc0c2c93436d858a14564c6179ec72872vboxsync */
3933885bc0c2c93436d858a14564c6179ec72872vboxsync _handleRequest: function(e, o) {
3933885bc0c2c93436d858a14564c6179ec72872vboxsync var data = this.get("source");
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync // Problematic data
060f7ec6ae5c99df18341ef2e1f3e91f4b0c89f1vboxsync if(LANG.isUndefined(data)) {
3933885bc0c2c93436d858a14564c6179ec72872vboxsync o.error = true;
cc74f15083bf80fbc96723a89faa06c15d0dead8vboxsync }
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync if(o.error) {
a72b5355eb89aafe6bfcc8912cf02645d7cccceavboxsync this.fire("error", null, o);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync }
6e25221ce8ef8e656d1e15eb7ec5cf8ae758ceb2vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync this.fire("data", null, Y.mix(o, {data:data}));
3933885bc0c2c93436d858a14564c6179ec72872vboxsync },
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
060f7ec6ae5c99df18341ef2e1f3e91f4b0c89f1vboxsync /**
9ca017ceee656f9d33f2cb6652e401b5f17fcfb7vboxsync * Overridable default <code>data</code> event handler normalizes raw data
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * into a response that includes results and meta properties.
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync *
261b44f7fa60a1d4bb4102142d3aa44188908484vboxsync * @method _handleData
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * @protected
f106b549ead77cab51ff1e2c116060aaabb90d5evboxsync * @param e {Event.Facade} Event Facade.
f106b549ead77cab51ff1e2c116060aaabb90d5evboxsync * @param o {Object} Object with the following properties:
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dl>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
9e4ea89b1085fdaa5861e45a729d9c978db1a8f1vboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
ad9e5a61fea617d40d07390ff1737277d6aef869vboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
dbabc9de5bf52ce5eb77cf82b038e9a6166c5a04vboxsync * <dt>data (Object)</dt> <dd>The raw response data.</dd>
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync * </dl>
4090390866c02d5d0ad061151cdb298b9a173e86vboxsync */
40dce69ff1c2949a489337922f30f1021d62d864vboxsync _handleData: function(e, o) {
40dce69ff1c2949a489337922f30f1021d62d864vboxsync // Pass through data as-is
40dce69ff1c2949a489337922f30f1021d62d864vboxsync o.results = o.data;
40dce69ff1c2949a489337922f30f1021d62d864vboxsync
40dce69ff1c2949a489337922f30f1021d62d864vboxsync // Normalize
7a29aa5ce149ccd344a2929d2815b8e212690b92vboxsync if(!o.results) {
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync o.results = [];
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync }
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync if(!o.meta) {
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync o.meta = {};
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync }
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync this.fire("response", null, o);
3933885bc0c2c93436d858a14564c6179ec72872vboxsync },
3933885bc0c2c93436d858a14564c6179ec72872vboxsync
3933885bc0c2c93436d858a14564c6179ec72872vboxsync /**
3933885bc0c2c93436d858a14564c6179ec72872vboxsync * Overridable default <code>response</code> event handler returns data as a
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * normalized response to callabck.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync *
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @method _handleResponse
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @protected
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @param e {Event.Facade} Event Facade.
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * @param o {Object} Object with the following properties:
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * <dl>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * <dt>request (Object)</dt> <dd>The request.</dd>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * <dt>callback (Object)</dt> <dd>The callback object.</dd>
aa0553becec2abc2e781f839ba1d399c31c2c07fvboxsync * <dt>data (Object)</dt> <dd>Raw data.</dd>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * <dt>results (Object)</dt> <dd>Parsed results.</dd>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * </dl>
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync */
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync _handleResponse: function(e, o) {
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync // Send the response back to the callback
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync DSBase.issueCallback(o);
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync },
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync /**
a1b4fb3917412d2632d358ff8989f1ec971f2d5bvboxsync * Generates a unique transaction ID and fires <code>request</code> event.
3933885bc0c2c93436d858a14564c6179ec72872vboxsync *
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @method sendRequest
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @param request {Object} Request.
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * @param callback {Object} An object literal with the following properties:
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * <dl>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * <dt><code>success</code></dt>
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync * <dd>The function to call when the data is ready.</dd>
2823fbb1428e982169f04923472d7c94e7ed8385vboxsync * <dt><code>failure</code></dt>
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * <dd>The function to call upon a response failure condition.</dd>
147e101bcd061b5e085e4a2c0cc9fc35546ff1aavboxsync * <dt><code>scope</code></dt>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * <dd>The object to serve as the scope for the success and failure handlers.</dd>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * <dt><code>argument</code></dt>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * <dd>Arbitrary data payload that will be passed back to the success and failure handlers.</dd>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * </dl>
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync * @return {Number} Transaction ID.
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync */
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync sendRequest: function(request, callback) {
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync var tId = DS._tId++;
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync this.fire("request", null, {tId:tId, request:request,callback:callback});
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync return tId;
1dc37bff2fb26897f5892d8330fe2bc0c9859aecvboxsync }
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync});
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync DS.Base = DSBase;
508452243fd3328f7b9e0405d39fb9dc004e31b8vboxsync
508452243fd3328f7b9e0405d39fb9dc004e31b8vboxsync
71c8a528203c289a8585ce10ac6bafc4274058c6vboxsync
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync}, '@VERSION@' ,{requires:['base']});
89aedeb1d8af54aba6ae46dbbd256281315c1be6vboxsync