eventprovider_compat.html revision 08e054017132cdd838955bc0af15889f1f2a7b42
<html>
<head>
<title>Chaining Animations Using <code>onComplete</code></title>
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/button/assets/skins/sam/button.css" />
<script type="text/javascript">
if (typeof loadFirebugConsole == 'function') {
loadFirebugConsole();
}
</script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/animation/animation.js"></script>
<!--begin custom header content for this example-->
#animator {
background-color:#003366;
color:#fff;
height:15em;
width: 15em;
position:relative;
margin:1em;
padding:1em;
}
</style>
<script type="text/javascript">
/*
YAHOO.example.EventReceiver = function() { };
YAHOO.example.EventReceiver.prototype.on = function(type, f) {
var ev = this.createEvent(type);
ev.on(f);
return ev;
};
function onTest(arg) {
alert("test 1 " + arg);
}
function onTest2(arg) {
alert("test 2 " + arg);
}
var er = new YAHOO.example.EventReceiver();
er.on("test", onTest);
er.on("test", onTest2);
//er.on("test");
er.fireEvent("test", "firing test");
*/
var Animal = function() {
this.createEvent('myEvent');
this.on('foo, myEvent', this.handler, this, 5, 6)
//.on('foo, myEvent2', this.handler2, this, 5, 6);
};
Animal.prototype.handler = function(arg) {
YAHOO.log('Animal');
YAHOO.log(this);
YAHOO.log(arguments);
};
Animal.prototype.handler2 = function(arg) {
YAHOO.log('Animal handler2');
YAHOO.log(this);
YAHOO.log(arguments);
};
YAHOO.augment(Animal, YAHOO.util.EventProvider);
var Dog = function() {
Animal.prototype.constructor.apply(this, arguments);
};
YAHOO.extend(Dog, Animal, {
handler: function(arg) {
YAHOO.log('Dog');
YAHOO.log(this);
YAHOO.log(arguments);
}
});
var Cat = function() {
Animal.prototype.constructor.apply(this, arguments);
};
YAHOO.extend(Cat, Animal, {
handler: function(arg) {
YAHOO.log('Cat');
YAHOO.log(this);
YAHOO.log(arguments);
}
});
var d = new Dog(), c = new Cat();
d.fireEvent('myEvent', 1, 2);
c.fireEvent('myEvent', 3, 4);
c.detach('foo, myEvent');
c.fireEvent('myEvent', 'should not see');
YAHOO.log("detacher, menu:click".split(/([,:])\s*/))
YAHOO.log("detacher menu click".split(/([,:])\s*/))
</script>
</head>
<body class=" yui-skin-sam">
</body>
</html>