multi.html revision d98d5e2bbc3fcf2015c549dd94c4c0371b3fdbe7
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html debug="true">
<head>
<title>YUI 3.0</title>
<script type="text/javascript" src="/build/yui/yui.js"></script>
<!--
<script type="text/javascript" src="/build/event/event-debug.js"></script>
<script type="text/javascript" src="/build/dump/dump.js"></script>
-->
<body>
<input id="button1" type="button" value="Button 1" class='button' />
<input id="button2" type="button" value="Button 2" class='button' />
<input id="text1" type="text" value="something" class='nothing' />
<script>
YUI({
base: '/build/',
filter: 'debug',
//filter: 'raw',
combine: false
}).use('dump', 'substitute', 'compat', function(Y) {
Y.on('yui:log', function(msg) {
var d=document, b=d.body, n=d.createElement("div");
if (b) {
n.appendChild(d.createTextNode(msg));
b.appendChild(n);
}
});
// o1.addTarget(o3);
var Base = function() {
Y.log('Base constructor executed');
arguments.callee.superclass.constructor.apply(this, arguments);
}
Y.extend(Base, Y.Event.Target, {
base: function() {
Y.log('all your base...');
}
});
var O = function(id) {
this.id = id;
Y.log('O constructor executed ' + id);
}
O.prototype = {
oOo: function(ok) {
Y.log('oOo');
}
}
Y.augment(O, Base, null, null, {
// Y.augment(O, Y.Event.Target, null, null, {
emitFacade: true
});
// augmented class
var o1 = new O('1');
// event target instance or subclass
// var o2 = new Y.Event.Target();
var o2 = new O('2');
// augmented object
var o3 = new Object();
Y.augment(o3, Y.Event.Target, null, null, {
emitFacade: true
});
o1.publish('o:1', {
defaultFn: function() {
Y.log('1 DEFAULT FN');
},
stoppedFn: function() {
Y.log('1 STOPPED');
},
preventedFn: function() {
Y.log('1 PREVENTED');
}
, emitFacade: true
});
o2.publish('o:1', {
defaultFn: function() {
Y.log('2 DEFAULT FN');
}
, emitFacade: true
});
o1.publish('chain', {
defaultFn: function() {
Y.log('DEFAULT FN CHAIN');
}
, emitFacade: true
});
o1.publish({
event1: null,
event2: null
}, {
defaultFn: function(e) {
Y.log('DEFAULT MULTI EVENT ' + e.type);
}
, emitFacade: true
});
o1.publish({
event3: {
defaultFn: function(e) {
Y.log('e3 ' + e.type);
}
},
event4: {
defaultFn: function(e) {
Y.log('e4 ' + e.type);
}
}
});
o1.subscribe({
event2: null,
event4: null
}, function(e) {
Y.log('event subscriber ' + e.type)
}, o1, 1, 2);
o1.subscribe({
event1: {
fn: function(e) { Y.log('event1 sub') }
},
event3: {
fn: function(e) { Y.log('event3 sub') }
}
});
o1.fire('event1');
o1.fire('event2');
o1.fire('event3');
o1.fire('event4');
});
</script>
</body>
</html>