dom.html revision 1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749
<!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="/build3x/yui/yui-debug.js"></script>
<script type="text/javascript" src="/build3x/dump/dump.js"></script>
<body>
<div id="body">asdf</div>
<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>
(function() {
``
//var Y = YUI().use('event', 'dom');
//var Y = YUI().use('node');
var Y = YUI().use('dump', 'substitute');
// debugger;
// alert('starting JS');
Y.log('asdf');
Y.on('event:ready', function() {
Y.log('on ready');
});
Y.on('click', function(e) {
Y.log('document click');
}, document);
// 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);
// }
// });
Y.Event.onDOMReady(function() {
Y.log("onDOMReady fired");
});
var el = Y.get('#button1');
Y.log("get got " + el);
var f = function(e) {
Y.log("SUB1, " + this.get('id') + " click event facade: " + e.target);
e.stopPropagation();
// e.stopImmediatePropagation();
}
var h =Y.on('click', f, el);
Y.on('click', function(e) {
Y.log("SUB2, " + this.get('id') + " click event facade: " + e.target);
h.detach();
// Y.detach('click', f, el);
// Y.Event.purgeElement(this);
}, el);
var ret = Y.on('click', function(e) {
Y.log(this.get('id') + " click event facade: " + e.target);
}, '#button2');
Y.log('ret: ' + Y.Lang.dump(ret, 1));
/*
var buts = Y.Node.queryAll('.button');
Y.log('queryAll buttons: ' + Y.Lang.dump(buts.get('length')));
buts.each(function(v, k) {
Y.log('blah: ' + v);
});
Y.each(buts, function(v, k) {
Y.log('blah2: ' + v);
});
*/
Y.on('mouseover', function(e) {
// alert('asdf');
Y.log(this.id || this.get('id') + " mouseover: " + e.target);
// }, Y.Node.queryAll('.button'));
//}, Y.Selector.query('.button'));
}, ['#button1', '#button2']);
/*
Y.on('TEST:EVENT', function() {
Y.log('test event subscriber success: ' + Y.Array(arguments));
});
Y.fire('TEST:EVENT', 1, 2);
Y.fire('asdf:asdf', 1);
Y.fire('asdf', 1);
*/
/*
var obj = new Y.Event.Target();
// test failure
obj.subscribe('foo', function() {
Y.info(notdefined);
});
obj.subscribe('foo', function() {
Y.info(notdefined);
});
obj.subscribe('foo', function() {
Y.info('foo fired anyway!');
});
try {
obj.fire('foo');
} catch(e) {
Y.warn('fire() error: ' + Y.Lang.dump(e.errors));
}
*/
//if (Object.prototype.hasOwnProperty) {
//alert('asdf');
//}
//window.blah ="ad"
//alert(window.hasOwnProperty('blah'));
//alert(window.hasOwnProperty('document'));
//alert(Y.object.owns(window, 'blah'));
var a = [
1,
2,
];
var handle;
function handleClick(){
alert(handle);
}
var body = Y.Node.get("body");
handle = body.on("click", handleClick);
//click to confirm it's attached
// body.detach("click", handleClick);
handle.detach();
//click again, will still show the alert
// for (var i in window) {
// Y.log(i);
// }
})();
</script>
</body>
</html>