widget-htmlparser.js revision 76ca635d61eb3f9fb7c9d788a44fa8b1690aa138
/**
* Adds HTML Parser support to the base Widget class
*
* @module widget
* @submodule widget-htmlparser
* @for Widget
*/
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 Widget.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
*/
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
*/
value: null,
getter: "_getSrcNode",
writeOnce: true
};
/**
* @method _getSrcNode
* @protected
* @return {Node} The Node to apply HTML_PARSER to
*/
_getSrcNode : function(val) {
},
/**
* @method _applyParsedConfig
* @protected
* @return {Object} The merged configuration literal
*/
},
/**
* 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,
val;
val = null;
if (Lang.isFunction(v)) {
} else {
val = null;
}
} else {
}
}
parsedConfig = parsedConfig || {};
parsedConfig[k] = val;
}
});
}
},
/**
* 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;
p = classes[i].HTML_PARSER;
if (p) {
}
}
return parser;
}
});