eventprovider.html revision ba9518d6366a8c1c3a1d027fdc652d92759e101b
<html>
<head>
<title>Chaining Animations Using <code>onComplete</code></title>
<script type="text/javascript">
if (typeof loadFirebugConsole == 'function') {
loadFirebugConsole();
}
</script>
<!--begin custom header content for this example-->
<script type="text/javascript">
YUI({
chain: true
}).use('*', function(Y) {
/*
Y.example.EventReceiver = function() { };
Y.example.EventReceiver.prototype.on = function(type, f) {
var ev = this.publish(type);
ev.on(f);
return ev;
};
function onTest(arg) {
alert("test 1 " + arg);
}
function onTest2(arg) {
alert("test 2 " + arg);
}
var er = new Y.example.EventReceiver();
er.on("test", onTest);
er.on("test", onTest2);
//er.on("test");
er.fire("test", "firing test");
*/
var Animal = function() {
this.publish('myEvent');
this.after('myEvent', this.handler, this, 'AFTER').on('foo, myEvent', this.handler, this, 5, 6).on('foo, myEvent2', this.handler2, this, 7, 8);
};
Animal.prototype.handler = function(arg) {
Y.log('Animal');
Y.log(this);
Y.log(arguments);
};
Animal.prototype.handler2 = function(arg) {
Y.log('Animal handler2');
Y.log(this);
Y.log(arguments);
};
Y.augment(Animal, Y.EventTarget);
var Dog = function() {
Animal.prototype.constructor.apply(this, arguments);
};
Y.extend(Dog, Animal, {
handler: function(arg) {
Y.log('Dog');
Y.log(this);
Y.log(arguments);
}
});
var Cat = function() {
Animal.prototype.constructor.apply(this, arguments);
};
Y.extend(Cat, Animal, {
handler: function(arg) {
Y.log('Cat');
Y.log(this);
Y.log(arguments);
}
});
var d = new Dog(), c = new Cat();
d.fire('myEvent', 1, 2);
c.fire('myEvent', 3, 4);
c.detach('foo, myEvent');
c.fire('myEvent', 'should not see unless this is AFTER');
c.fire('myEvent2', 'Should see Animal\' imp');
// Y.log("detacher, menu:click".split(/([,:])\s*/))
// Y.log("detacher menu click".split(/([,:])\s*/))
});
</script>
</head>
<body class=" yui-skin-sam">
</body>
</html>