~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/yuilib/3.13.0/dataschema-base/dataschema-base-debug.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.13.0 (build 508226d)
 
3
Copyright 2013 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
 
 
8
YUI.add('dataschema-base', function (Y, NAME) {
 
9
 
 
10
/**
 
11
 * The DataSchema utility provides a common configurable interface for widgets to
 
12
 * apply a given schema to a variety of data.
 
13
 *
 
14
 * @module dataschema
 
15
 * @main dataschema
 
16
 */
 
17
 
 
18
/**
 
19
 * Provides the base DataSchema implementation, which can be extended to
 
20
 * create DataSchemas for specific data formats, such XML, JSON, text and
 
21
 * arrays.
 
22
 *
 
23
 * @module dataschema
 
24
 * @submodule dataschema-base
 
25
 */
 
26
 
 
27
var LANG = Y.Lang,
 
28
/**
 
29
 * Base class for the YUI DataSchema Utility.
 
30
 * @class DataSchema.Base
 
31
 * @static
 
32
 */
 
33
    SchemaBase = {
 
34
    /**
 
35
     * Overridable method returns data as-is.
 
36
     *
 
37
     * @method apply
 
38
     * @param schema {Object} Schema to apply.
 
39
     * @param data {Object} Data.
 
40
     * @return {Object} Schema-parsed data.
 
41
     * @static
 
42
     */
 
43
    apply: function(schema, data) {
 
44
        return data;
 
45
    },
 
46
 
 
47
    /**
 
48
     * Applies field parser, if defined
 
49
     *
 
50
     * @method parse
 
51
     * @param value {Object} Original value.
 
52
     * @param field {Object} Field.
 
53
     * @return {Object} Type-converted value.
 
54
     */
 
55
    parse: function(value, field) {
 
56
        if(field.parser) {
 
57
            var parser = (LANG.isFunction(field.parser)) ?
 
58
            field.parser : Y.Parsers[field.parser+''];
 
59
            if(parser) {
 
60
                value = parser.call(this, value);
 
61
            }
 
62
            else {
 
63
                Y.log("Could not find parser for field " + Y.dump(field), "warn", "dataschema-json");
 
64
            }
 
65
        }
 
66
        return value;
 
67
    }
 
68
};
 
69
 
 
70
Y.namespace("DataSchema").Base = SchemaBase;
 
71
Y.namespace("Parsers");
 
72
 
 
73
 
 
74
}, '3.13.0', {"requires": ["base"]});