~lutostag/ubuntu/utopic/maas/1.5.2

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/datasource-jsonschema/datasource-jsonschema.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-15 18:14:08 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120315181408-zgl94hzo0x4n99an
Tags: 0.1+bzr295+dfsg-0ubuntu2
* debian/patches:
  - 01-fix-database-settings.patch: Update to set PSERV_URL.
  - 02-pserv-config.patch: Set port to 8001.
* debian/maas.postinst: Run maas-import-isos on install.
* debian/control: Depends on rabbitmq-server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.4.1 (build 4118)
 
3
Copyright 2011 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('datasource-jsonschema', function(Y) {
 
8
 
 
9
/**
 
10
 * Extends DataSource with schema-parsing on JSON data.
 
11
 *
 
12
 * @module datasource
 
13
 * @submodule datasource-jsonschema
 
14
 */
 
15
 
 
16
/**
 
17
 * Adds schema-parsing to the DataSource Utility.
 
18
 * @class DataSourceJSONSchema
 
19
 * @extends Plugin.Base
 
20
 */    
 
21
var DataSourceJSONSchema = function() {
 
22
    DataSourceJSONSchema.superclass.constructor.apply(this, arguments);
 
23
};
 
24
 
 
25
Y.mix(DataSourceJSONSchema, {
 
26
    /**
 
27
     * The namespace for the plugin. This will be the property on the host which
 
28
     * references the plugin instance.
 
29
     *
 
30
     * @property NS
 
31
     * @type String
 
32
     * @static
 
33
     * @final
 
34
     * @value "schema"
 
35
     */
 
36
    NS: "schema",
 
37
 
 
38
    /**
 
39
     * Class name.
 
40
     *
 
41
     * @property NAME
 
42
     * @type String
 
43
     * @static
 
44
     * @final
 
45
     * @value "dataSourceJSONSchema"
 
46
     */
 
47
    NAME: "dataSourceJSONSchema",
 
48
 
 
49
    /////////////////////////////////////////////////////////////////////////////
 
50
    //
 
51
    // DataSourceJSONSchema Attributes
 
52
    //
 
53
    /////////////////////////////////////////////////////////////////////////////
 
54
 
 
55
    ATTRS: {
 
56
        schema: {
 
57
            //value: {}
 
58
        }
 
59
    }
 
60
});
 
61
 
 
62
Y.extend(DataSourceJSONSchema, Y.Plugin.Base, {
 
63
    /**
 
64
    * Internal init() handler.
 
65
    *
 
66
    * @method initializer
 
67
    * @param config {Object} Config object.
 
68
    * @private
 
69
    */
 
70
    initializer: function(config) {
 
71
        this.doBefore("_defDataFn", this._beforeDefDataFn);
 
72
    },
 
73
 
 
74
    /**
 
75
     * Parses raw data into a normalized response. To accommodate XHR responses,
 
76
     * will first look for data in data.responseText. Otherwise will just work
 
77
     * with data.
 
78
     *
 
79
     * @method _beforeDefDataFn
 
80
     * @param tId {Number} Unique transaction ID.
 
81
     * @param request {Object} The request.
 
82
     * @param callback {Object} The callback object with the following properties:
 
83
     *     <dl>
 
84
     *         <dt>success (Function)</dt> <dd>Success handler.</dd>
 
85
     *         <dt>failure (Function)</dt> <dd>Failure handler.</dd>
 
86
     *     </dl>
 
87
     * @param data {Object} Raw data.
 
88
     * @protected
 
89
     */
 
90
    _beforeDefDataFn: function(e) {
 
91
        var data = e.data && (e.data.responseText || e.data),
 
92
            schema = this.get('schema'),
 
93
            payload = e.details[0];
 
94
        
 
95
        payload.response = Y.DataSchema.JSON.apply.call(this, schema, data) || {
 
96
            meta: {},
 
97
            results: data
 
98
        };
 
99
 
 
100
        this.get("host").fire("response", payload);
 
101
 
 
102
        return new Y.Do.Halt("DataSourceJSONSchema plugin halted _defDataFn");
 
103
    }
 
104
});
 
105
    
 
106
Y.namespace('Plugin').DataSourceJSONSchema = DataSourceJSONSchema;
 
107
 
 
108
 
 
109
}, '3.4.1' ,{requires:['datasource-local', 'plugin', 'dataschema-json']});