datasource-arrayschema.js revision 32b6fd78d1787b0afecb1970111f14a46a569aa7
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Extends DataSource with schema-parsing on array data.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @module datasource
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @submodule datasource-arrayschema
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Adds schema-parsing to the YUI DataSource utility.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @class DataSourceArraySchema
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @extends Plugin.Base
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNicovar DataSourceArraySchema = function() {
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico DataSourceArraySchema.superclass.constructor.apply(this, arguments);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * The namespace for the plugin. This will be the property on the host which
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * references the plugin instance.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @property NS
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @type String
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @value "schema"
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Class name.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @property NAME
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @type String
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @value "dataSourceArraySchema"
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico /////////////////////////////////////////////////////////////////////////////
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico // DataSourceArraySchema Attributes
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico /////////////////////////////////////////////////////////////////////////////
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Internal init() handler.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method initializer
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param config {Object} Config object.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico this.doBefore("_defDataFn", this._beforeDefDataFn);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Parses raw data into a normalized response.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method _beforeDefDataFn
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * <dt>request (Object)</dt> <dd>The request.</dd>
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * <dt>success (Function)</dt> <dd>Success handler.</dd>
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * <dt>data (Object)</dt> <dd>Raw data.</dd>
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico response = Y.DataSchema.Array.apply(this.get("schema"), data);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico this.get("host").fire("response", Y.mix({response:response}, e));
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico return new Y.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNicoY.namespace('Plugin').DataSourceArraySchema = DataSourceArraySchema;
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico}, '@VERSION@' ,{requires:['plugin', 'datasource-local', 'dataschema-array']});