default-on-child.html revision f5272da05b11f2b116e4bd62353472a187367714
970N/A<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
970N/A<html>
970N/A <body>
1479N/A <!--
970N/A <script src="http://yui.yahooapis.com/3.0.0/build/yui/yui.js" type="text/javascript"></script>
970N/A -->
970N/A <script src="/build/yui/yui.js" type="text/javascript"></script>
970N/A
970N/A <script type="text/javascript" charset="utf-8">
970N/A YUI({filter:"raw"}).use("node", "base", function(Y) {
970N/A
970N/Afunction SimpleNode(config) {
970N/A SimpleNode.superclass.constructor.apply(this, arguments);
970N/A}
970N/A
970N/ASimpleNode.NAME = "SimpleNode";
970N/A
970N/ASimpleNode.ATTRS = {
970N/A parent: {
970N/A value: null,
970N/A validator: function(value) { return !value || value instanceof SimpleNode; }
970N/A }
970N/A};
970N/A
970N/AY.extend(SimpleNode, Y.Base, {
970N/A _children: [],
970N/A
970N/A initializer: function(cfg) {
970N/A this._children = [];
970N/A
970N/A this.publish("simplenode:test", {
970N/A defaultFn: function() {
970N/A Y.log("test event defaultfn on " + this, "info", this.name);
970N/A },
970N/A preventedFn: function() { },
970N/A defaultTargetOnly: true,
970N/A stoppedFn: function() { }
970N/A });
970N/A },
970N/A addChild: function(node) {
970N/A node.addTarget(this);
970N/A this._children[this._children.length] = node;
970N/A node.set('parent',this);
970N/A }
970N/A});
970N/A
970N/A
970N/Avar a = new SimpleNode();
970N/Avar b = new SimpleNode();
970N/Avar c = new SimpleNode();
970N/A
970N/Aa.addChild(b);
970N/Ab.addChild(c);
970N/A
970N/AY.log(a + " parent is " + a.get('parent'), "info", "test");
970N/AY.log(b + " parent is " + b.get('parent'), "info", "test");
970N/AY.log(c + " parent is " + c.get('parent'), "info", "test");
970N/A
970N/Ac.fire("simplenode:test","tested");
970N/A
970N/A});
970N/A</script>
970N/A</body>
970N/A</html>
970N/A