2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
8 YUI.add('datasource-arrayschema', function(Y) {
11 * Extends DataSource with schema-parsing on array data.
14 * @submodule datasource-arrayschema
18 * Adds schema-parsing to the DataSource Utility.
19 * @class DataSourceArraySchema
20 * @extends Plugin.Base
22 var DataSourceArraySchema = function() {
23 DataSourceArraySchema.superclass.constructor.apply(this, arguments);
26 Y.mix(DataSourceArraySchema, {
28 * The namespace for the plugin. This will be the property on the host which
29 * references the plugin instance.
46 * @value "dataSourceArraySchema"
48 NAME: "dataSourceArraySchema",
50 /////////////////////////////////////////////////////////////////////////////
52 // DataSourceArraySchema Attributes
54 /////////////////////////////////////////////////////////////////////////////
63 Y.extend(DataSourceArraySchema, Y.Plugin.Base, {
65 * Internal init() handler.
68 * @param config {Object} Config object.
71 initializer: function(config) {
72 this.doBefore("_defDataFn", this._beforeDefDataFn);
76 * Parses raw data into a normalized response.
78 * @method _beforeDefDataFn
80 * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
81 * <dt>request (Object)</dt> <dd>The request.</dd>
82 * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
84 * <dt>success (Function)</dt> <dd>Success handler.</dd>
85 * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
88 * <dt>data (Object)</dt> <dd>Raw data.</dd>
92 _beforeDefDataFn: function(e) {
93 var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
94 response = Y.DataSchema.Array.apply(this.get("schema"), data);
104 this.get("host").fire("response", Y.mix({response:response}, e));
105 return new Y.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");
109 Y.namespace('Plugin').DataSourceArraySchema = DataSourceArraySchema;
113 }, '3.0.0' ,{requires:['plugin', 'datasource-local', 'dataschema-array']});