Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('dataschema-base', function (Y, NAME) {
2
 
3
/**
4
 * The DataSchema utility provides a common configurable interface for widgets to
5
 * apply a given schema to a variety of data.
6
 *
7
 * @module dataschema
8
 * @main dataschema
9
 */
10
 
11
/**
12
 * Provides the base DataSchema implementation, which can be extended to
13
 * create DataSchemas for specific data formats, such XML, JSON, text and
14
 * arrays.
15
 *
16
 * @module dataschema
17
 * @submodule dataschema-base
18
 */
19
 
20
var LANG = Y.Lang,
21
/**
22
 * Base class for the YUI DataSchema Utility.
23
 * @class DataSchema.Base
24
 * @static
25
 */
26
    SchemaBase = {
27
    /**
28
     * Overridable method returns data as-is.
29
     *
30
     * @method apply
31
     * @param schema {Object} Schema to apply.
32
     * @param data {Object} Data.
33
     * @return {Object} Schema-parsed data.
34
     * @static
35
     */
36
    apply: function(schema, data) {
37
        return data;
38
    },
39
 
40
    /**
41
     * Applies field parser, if defined
42
     *
43
     * @method parse
44
     * @param value {Object} Original value.
45
     * @param field {Object} Field.
46
     * @return {Object} Type-converted value.
47
     */
48
    parse: function(value, field) {
49
        if(field.parser) {
50
            var parser = (LANG.isFunction(field.parser)) ?
51
            field.parser : Y.Parsers[field.parser+''];
52
            if(parser) {
53
                value = parser.call(this, value);
54
            }
55
            else {
56
            }
57
        }
58
        return value;
59
    }
60
};
61
 
62
Y.namespace("DataSchema").Base = SchemaBase;
63
Y.namespace("Parsers");
64
 
65
 
66
}, '3.18.1', {"requires": ["base"]});