~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/widget-htmlparser/widget-htmlparser.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

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('widget-htmlparser', function(Y) {
8
 
 
9
 
/**
10
 
 * Adds HTML Parser support to the base Widget class
11
 
 *
12
 
 * @module widget
13
 
 * @submodule widget-htmlparser
14
 
 * @for Widget
15
 
 */
16
 
 
17
 
 
18
 
var Widget = Y.Widget,
19
 
    Node = Y.Node,
20
 
    Lang = Y.Lang,
21
 
 
22
 
    SRC_NODE = "srcNode",
23
 
    CONTENT_BOX = "contentBox";
24
 
 
25
 
/**
26
 
 * Object hash, defining how attribute values are to be parsed from
27
 
 * markup contained in the widget's content box. e.g.:
28
 
 * <pre>
29
 
 *   {
30
 
 *       // Set single Node references using selector syntax 
31
 
 *       // (selector is run through node.one)
32
 
 *       titleNode: "span.yui-title",
33
 
 *       // Set NodeList references using selector syntax 
34
 
 *       // (array indicates selector is to be run through node.all)
35
 
 *       listNodes: ["li.yui-item"],
36
 
 *       // Set other attribute types, using a parse function. 
37
 
 *       // Context is set to the widget instance.
38
 
 *       label: function(contentBox) {
39
 
 *           return contentBox.one("span.title").get("innerHTML");
40
 
 *       }
41
 
 *   }
42
 
 * </pre>
43
 
 * 
44
 
 * @property HTML_PARSER
45
 
 * @type Object
46
 
 * @static
47
 
 */
48
 
Widget.HTML_PARSER = {};
49
 
 
50
 
/**
51
 
 * The build configuration for the Widget class.
52
 
 * <p>
53
 
 * Defines the static fields which need to be aggregated,
54
 
 * when this class is used as the main class passed to 
55
 
 * the <a href="Base.html#method_build">Base.build</a> method.
56
 
 * </p>
57
 
 * @property _buildCfg
58
 
 * @type Object
59
 
 * @static
60
 
 * @final
61
 
 * @private
62
 
 */
63
 
Widget._buildCfg = {
64
 
    aggregates : ["HTML_PARSER"]
65
 
};
66
 
 
67
 
/**
68
 
 * The DOM node to parse for configuration values, passed to the Widget's HTML_PARSER definition
69
 
 *
70
 
 * @attribute srcNode
71
 
 * @type String | Node
72
 
 * @writeOnce
73
 
 */
74
 
Widget.ATTRS[SRC_NODE] = {
75
 
    value: null,
76
 
    setter: Node.one,
77
 
    getter: "_getSrcNode",
78
 
    writeOnce: true
79
 
};
80
 
 
81
 
Y.mix(Widget.prototype, {
82
 
 
83
 
    /**
84
 
     * @method _getSrcNode
85
 
     * @protected
86
 
     * @return {Node} The Node to apply HTML_PARSER to
87
 
     */
88
 
    _getSrcNode : function(val) {
89
 
        return val || this.get(CONTENT_BOX);
90
 
    },
91
 
 
92
 
    /**
93
 
     * @method _applyParsedConfig
94
 
     * @protected
95
 
     * @return {Object} The merged configuration literal
96
 
     */
97
 
    _applyParsedConfig : function(node, cfg, parsedCfg) {
98
 
        return (parsedCfg) ? Y.mix(cfg, parsedCfg, false) : cfg;
99
 
    },
100
 
 
101
 
    /**
102
 
     * Utilitity method used to apply the <code>HTML_PARSER</code> configuration for the 
103
 
     * instance, to retrieve config data values.
104
 
     *
105
 
     * @method _applyParser
106
 
     * @protected
107
 
     * @param config {Object} User configuration object (will be populated with values from Node) 
108
 
     */
109
 
    _applyParser : function(config) {
110
 
 
111
 
        var widget = this,
112
 
            srcNode = widget.get(SRC_NODE),
113
 
            schema = widget._getHtmlParser(),
114
 
            parsedConfig,
115
 
            val;
116
 
 
117
 
        if (schema && srcNode) {
118
 
            Y.Object.each(schema, function(v, k, o) {
119
 
                val = null;
120
 
 
121
 
                if (Lang.isFunction(v)) {
122
 
                    val = v.call(widget, srcNode);
123
 
                } else {
124
 
                    if (Lang.isArray(v)) {
125
 
                        val = srcNode.all(v[0]);
126
 
                        if (val.isEmpty()) {
127
 
                            val = null;
128
 
                        }
129
 
                    } else {
130
 
                        val = srcNode.one(v);
131
 
                    }
132
 
                }
133
 
 
134
 
                if (val !== null && val !== undefined) {
135
 
                    parsedConfig = parsedConfig || {};
136
 
                    parsedConfig[k] = val;
137
 
                }
138
 
            });
139
 
        }
140
 
        config = widget._applyParsedConfig(srcNode, config, parsedConfig);
141
 
    },
142
 
 
143
 
    /**
144
 
     * Gets the HTML_PARSER definition for this instance, by merging HTML_PARSER
145
 
     * definitions across the class hierarchy.
146
 
     *
147
 
     * @private
148
 
     * @method _getHtmlParser
149
 
     * @return {Object} HTML_PARSER definition for this instance
150
 
     */
151
 
    _getHtmlParser : function() {
152
 
        // Removed caching for kweight. This is a private method
153
 
        // and only called once so don't need to cache HTML_PARSER
154
 
        var classes = this._getClasses(),
155
 
            parser = {},
156
 
            i, p;
157
 
 
158
 
        for (i = classes.length - 1; i >= 0; i--) {
159
 
            p = classes[i].HTML_PARSER;
160
 
            if (p) {
161
 
                Y.mix(parser, p, true);
162
 
            }
163
 
        }
164
 
        return parser;
165
 
    }
166
 
});
167
 
 
168
 
 
169
 
}, '3.4.1' ,{requires:['widget-base']});