2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('datasource-arrayschema', function (Y, NAME) {
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
79
* @param tId {Number} Unique transaction ID.
80
* @param request {Object} The request.
81
* @param callback {Object} The callback object with the following properties:
83
* <dt>success (Function)</dt> <dd>Success handler.</dd>
84
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
86
* @param data {Object} Raw data.
89
_beforeDefDataFn: function(e) {
90
var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
91
response = Y.DataSchema.Array.apply.call(this, this.get("schema"), data),
92
payload = e.details[0];
102
payload.response = response;
104
this.get("host").fire("response", payload);
106
return new Y.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");
110
Y.namespace('Plugin').DataSourceArraySchema = DataSourceArraySchema;
113
}, '3.10.3', {"requires": ["datasource-local", "plugin", "dataschema-array"]});