yui.html revision 1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749
<html>
<head>
<title>YUI 3.0</title>
<script type="text/javascript">
////////////////////////////////////////////////////////////////////////////
(function() {
var Mod = function(Y) {
Y.example.B = function() {
this.Super.apply(this, arguments);
this.b = "b";
Y.log("'B' constructor called: " + Array.prototype.splice.call(arguments, 0));
};
console.log('plugging B ' + Y.id);
test: function() {
Y.log("'B' test called: " + Array.prototype.splice.call(arguments, 0));
}
});
};
YUI.add("b", Mod, "3.0.0");
})();
////////////////////////////////////////////////////////////////////////////
(function() {
var Mod = function(Y) {
Y.example.A = function() {
// merge the prototype // wonder if this technique would speed inheritance since it // would eliminate lookups in the prototype chain.
//YUI.augment(this, A.prototype);
Y.log("'A' constructor called: " + Array.prototype.splice.call(arguments, 0));
};
d: function() { return "foo"; },
test: function() {
Y.log("'A' test called: " + Array.prototype.splice.call(arguments, 0));
}
};
console.log('plugging A ' + Y.id);
};
YUI.add("a", Mod, "3.0.0");
})();
////////////////////////////////////////////////////////////////////////////
(function() {
var Mod = function(Y) {
Y.example.C = function() {
this.Super.apply(this, arguments);
Y.log("'C' constructor called: " + Array.prototype.splice.call(arguments, 0));
};
console.log('plugging C ' + Y.id);
};
YUI.add("c", Mod, "3.0.0");
})();
////////////////////////////////////////////////////////////////////////////
(function() {
// YUI.use('b', 'a'); // order matters in stating deps unless add informs about deps
// YUI.use('a', 'b');
var y1 = YUI().use('a', 'c');
var b = new .example.B(1, 2);
b.test(1, '2');
// shouldn't work
// var c = new YUI.example.C();
// shouldn't work
// var b = new y1.example.B();
var a1 = new YUI.example.A();
a1.b = "a1 change";
var a2 = new y1.example.A();
a2.c = "a2 change";
// add a new version of A, change a prototype function
(function() {
var Mod = function(Y) {
Y.example.A = function() {
Y.log("'New A' constructor called");
// merge the prototype // wonder if this technique would speed inheritance since it // would eliminate lookups in the prototype chain.
//YUI.augment(this, A.prototype);
};
d: function() { return "bar"; },
};
console.log('plugging A ' + Y.id);
};
YUI.add("a", Mod, "3.0.0");
})();
var y2 = YUI().use('a');
var a3 = new y2.example.A();
y2.example.A.prototype.d = function() {
return "changed_d";
};
})();
</script>
<body>
<input id="addButton" type="button" value="Add link" />
</body>
</html>