baseBuild.html revision 13c4505d6df2d3db68248902959be8c92998d0fc
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Base.build</title>
<script type="text/javascript" src="/build/yui/yui.js"></script>
<script type="text/javascript" src="/build/plugin/plugin.js"></script>
<script type="text/javascript">
(function() {
YUI({base:"/build/", filter:"raw"}).use("base", "plugin", function(Y) {
// ----- Main Class -----
function MainPlugin() {}
MainPlugin.NS = "mainplugin";
MainPlugin.NAME = "mainplugin";
Y.extend(MainPlugin, Y.Plugin);
function Main(config) {
Main.superclass.constructor.apply(this, arguments);
}
Main.NAME = "main";
Main.ATTRS = {
mainA : {
value: "mainA"
},
mainB : {
value: "mainB"
}
};
Main.CLASSNAMES = {
main: "yui-main"
};
Main.PLUGINS = [
MainPlugin
];
Y.extend(Main, Y.Base, {
methodA : function() {
Y.log("methodA called - Attr value:" + this.get("mainA"));
},
methodB : function() {
Y.log("Main methodB called - Attr value:" + this.get("mainB"));
},
initializer : function() {
Y.log("Main initializer");
}
});
// ----- ExtOne --
function ExtOnePlugin() {}
ExtOnePlugin.NS = "extoneplugin";
ExtOnePlugin.NAME = "extoneplugin";
Y.extend(ExtOnePlugin, Y.Plugin);
function ExtOne() {
Y.log("ExtOne initializer");
}
ExtOne.NAME = "extone";
ExtOne.ATTRS = {
extOne : {
value: "extOne"
}
};
ExtOne.CLASSNAMES = {
extOne : "yui-extone"
};
ExtOne.PLUGINS = [
ExtOnePlugin
];
ExtOne.prototype = {
methodB : function() {
Y.log("ExtOne methodB called - Attr value:" + this.get("extOne"));
},
methodC : function() {
Y.log("methodC called - Attr value:" + this.get("extOne"));
},
methodD : function() {
Y.log("methodD called - Attr value:" + this.get("extOne"));
}
};
// ----- ExtTwo --
function ExtTwoPlugin() {}
ExtTwoPlugin.NS = "exttwoplugin";
ExtTwoPlugin.NAME = "exttwoplugin";
Y.extend(ExtTwoPlugin, Y.Plugin);
function ExtTwo() {
Y.log("ExtTwo initializer");
}
ExtTwo.NAME = "exttwo";
ExtTwo.ATTRS = {
extTwo : {
value: "extTwo"
}
};
ExtTwo.CLASSNAMES = {
extTwo : "yui-exttwo"
};
ExtTwo.PLUGINS = [
ExtTwoPlugin
];
ExtTwo.prototype = {
methodB : function() {
Y.log("ExtTwo methodB called - Attr value:" + this.get("extTwo"));
},
methodE : function() {
Y.log("methodE called - Attr value:" + this.get("extTwo"));
},
methodF : function() {
Y.log("methodF called - Attr value:" + this.get("extTwo"));
}
};
var CustMain = Y.Base.build(Main, [ExtOne, ExtTwo], {aggregates:["PLUGINS", "CLASSNAMES"]});
var c = new CustMain({mainA:"custMainA", extOne:"custExtOne"});
c.methodA();
c.methodB();
c.methodC();
c.methodD();
c.methodE();
c.methodF();
Y.log("CustMain === Main:" + (CustMain === Main));
Y.log("CustMain.superclass === Main:" + (CustMain.superclass.constructor === Main));
Y.log("Main.superclass === Y.Base:" + (Main.superclass.constructor === Y.Base));
Y.log("c instanceof Main:" + (c instanceof Main));
Y.log("c instanceof CustMain:" + (c instanceof CustMain));
Y.log("c instanceof Base:" + (c instanceof Y.Base));
Y.log("c.hasImpl(Main):" + (c.hasImpl(Main)));
Y.log("c.hasImpl(ExtOne):" + (c.hasImpl(ExtOne)));
Y.log("c.hasImpl(ExtTwo):" + (c.hasImpl(ExtTwo)));
var d = Y.Base.create(Main, [ExtOne, ExtTwo], {mainB: "custMainB", extTwo: "custExtTwo"});
d.methodA();
d.methodB();
d.methodC();
d.methodD();
d.methodE();
d.methodF();
Y.log("d instanceof Main:" + (d instanceof Main));
Y.log("d instanceof CustMain:" + (d instanceof CustMain));
Y.log("d instanceof Y.Base:" + (d instanceof Y.Base));
Y.log("d.hasImpl(Main):" + (d.hasImpl(Main)));
Y.log("d.hasImpl(Y.Base):" + (d.hasImpl(Y.Base)));
Y.log("d.hasImpl(ExtOne):" + (d.hasImpl(ExtOne)));
Y.log("d.hasImpl(ExtTwo):" + (d.hasImpl(ExtTwo)));
});
})();
</script>
</head>
<body>
</body>
</html>