4
<title>Test Page</title>
5
<style type="text/css">
11
<body class="yui-skin-sam">
14
<button type="button" class="go">Button 1</button>
15
<button type="button" class="go">Button 2</button>
16
<button type="button" class="go">Button 3</button>
20
<button type="button" id="attach">attach</button>
21
<button type="button" id="attach_handle">attach + handle</button>
22
<button type="button" id="attach_cat">attach + category</button>
23
<button type="button" id="detach">detach by signature</button>
24
<button type="button" id="detach_handle">detach by handle</button>
25
<button type="button" id="detach_cat">detach by category</button>
26
<button type="button" id="detach_nofn">detach without fn</button>
27
<button type="button" id="remove">remove buttons</button>
31
<script src="../../../../build/yui/yui.js"></script>
32
<!--script src="js/synthetic.js"></script-->
33
<!--script src="../../../build/event/event-synthetic.js"></script-->
36
useBrowserConsole: false,
37
lazyEventFacade: true,
39
}).use('event-synthetic', 'event-custom', 'node', function (Y) {
41
Y.on('yui:log', function (e) {
42
Y.one("#output").append("<li>" + e.msg + "</li>");
45
Y.Event.define('test', {
48
//publishConfig: { emitFacade: false },
50
on: function (node, sub, notifier) {
51
Y.log("on " + this.type + ": " + node.get('text'));
52
sub.testHandle = node.on('click', function (e) {
58
detach: function (node, sub, notifier) {
59
Y.log("detach " + this.type + ": " + node.get('text'));
60
sub.testHandle.detach();
63
delegate: function (container, sub, notifier, filter) {
64
Y.log("delegate " + this.type);
65
sub.delegateHandle = container.delegate('click', function (e) {
68
//notifier.fire({ currentTarget: e.currentTarget });
72
detachDelegate: function (container, sub, notifier, filter) {
73
Y.log("detachDelegate " + this.type);
74
sub.delegateHandle.detach();
78
var outer = Y.one('#outer'),
79
inner = Y.one('#inner'),
82
obj = { get: function () { return 'Context set OK'; } },
85
function notify(e, extra) {
86
var thisText = this.get('text'),
89
if (typeof e === 'object') {
90
ctText = e.currentTarget.get('text');
91
message = 'fired ' + e.type + ' from ' + ctText + ' (' + thisText + ')';
94
message += ' + ' + extra;
97
message = "fired from " + thisText + " with args (" +
98
Y.Array(arguments,0,true).join() + ")";
104
Y.one('#attach').on('click', function (e) {
106
case 1: Y.one('.go').on('test', notify); break;
107
//case 1: Y.one('.go').on('test', notify, obj, 1); break;
108
case 2: Y.all('.go').on('test', notify); break;
109
//case 2: Y.all('.go').on('test', notify, obj, 1); break;
110
case 3: Y.on('test', notify, '.go'); break;
111
//case 3: Y.on('test', notify, '.go', obj, 1); break;
112
case 4: Y.delegate('test', notify, '#outer', '.go'); break;
113
//case 4: Y.delegate('test', notify, '#outer', '.go', obj, 1); break;
117
Y.one('#attach_handle').on('click', function (e) {
119
case 1: handle = Y.one('.go').on('test', notify); break;
120
//case 1: handle = Y.one('.go').on('test', notify, obj, 1); break;
121
case 2: handle = Y.all('.go').on('test', notify); break;
122
//case 2: handle = Y.all('.go').on('test', notify, obj, 1); break;
123
case 3: handle = Y.on('test', notify, '.go'); break;
124
//case 3: handle = Y.on('test', notify, '.go', obj, 1); break;
125
case 4: handle = Y.delegate('test', notify, '#outer', '.go'); break;
126
//case 4: handle = Y.delegate('test', notify, '#outer', '.go', obj, 1); break;
130
Y.one('#attach_cat').on('click', function (e) {
132
case 1: Y.one('.go').on('foo|test', notify); break;
133
//case 1: Y.one('.go').on('foo|test', notify, obj, 1); break;
134
case 2: Y.all('.go').on('foo|test', notify); break;
135
//case 2: Y.all('.go').on('foo|test', notify, obj, 1); break;
136
case 3: Y.on('foo|test', notify, '.go'); break;
137
//case 3: Y.on('foo|test', notify, '.go', obj, 1); break;
138
case 4: Y.delegate('foo|test', notify, '#outer', '.go'); break;
139
//case 4: Y.delegate('foo|test', notify, '#outer', '.go', obj, 1); break;
143
Y.one('#detach').on('click', function (e) {
145
case 1: Y.one('.go').detach('test', notify); break;
146
case 2: Y.all('.go').detach('test', notify); break;
147
case 3: Y.detach('test', notify, '.go'); break;
148
case 4: Y.detach('test', notify, '#outer', '.go'); break;
152
Y.one('#detach_handle').on('click', function (e) {
156
Y.one('#detach_cat').on('click', function (e) {
158
case 1: Y.one('.go').detach('foo|test'); break;
159
case 2: Y.all('.go').detach('foo|test'); break;
160
case 3: Y.detach('foo|test'); break;
161
case 4: Y.one('#outer').detach('foo|test'); break;
165
Y.one('#detach_nofn').on('click', function (e) {
167
case 1: Y.one('.go').detach('test'); break;
168
case 2: Y.all('.go').detach('test'); break;
169
case 3: Y.detach('foo|*'); break;
170
case 4: Y.one('#outer').detach('test'); break;
174
Y.one('#remove').on('click', function (e) {