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