Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
88 lines (75 sloc) 2.8 KB
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<link rel=dns-prefetch href="//airve.github.com">
<title>oi :: test suite</title>
<meta name=viewport content="width=device-width,initial-scale=1.0">
<meta name=author content="Ryan Van Etten">
<meta name=description content="JavaScript module tests: oi.js">
<style>
body {
font:normal 100% sans-serif;
width:94%; max-width:1280px;
margin: 0 auto; padding:20px 3%;
background:#eed; color:#133;
}
#test { background:#8d2; max-width:100%; padding:3em; margin:1em 0; }
[accesskey]:hover { cursor:pointer; }
</style>
<script src="http://airve.github.io/js/aok/aok.min.js"></script>
<script src="oi.js"></script>
<script>
(function(document, aok, oi) {
var log = aok.log
, remixedFive = oi.domReady.remix(0, 1, 2, 3, 4)
, relayedZero = oi.domReady.relay()
, relayedFunc = oi.domReady.relay(aok)
, referenced = oi.domReady
log(oi);
log(oi.bridge({ fn: {} }));
aok({
id: '.domReady === .fn.ready',
test: oi.domReady === oi.fn.ready
});
aok({
id:'returnVoid',
test: void 0 === referenced(function() {})
});
aok({
id:'returnThis',
test: oi === oi.domReady(function() {})
});
relayedZero(function() {
var bool = this === document && !arguments.length;
aok({ id: 'relayedZero', test: bool });
});
relayedFunc(function(f) {
var bool = this === document && typeof f == 'function' && 1 === arguments.length;
aok({ id: 'relayedFunc', test: bool });
});
remixedFive(function() {
var bool = this === document && 5 === arguments.length && 3 === arguments[3];
aok({ id: 'remixedFive', test: bool });
});
oi.domReady(function (u) {
var handler, i = 2, e = this.getElementById('test');
e.innerHTML = (e && e.nodeType
? "Oi! =) The DOM is ready. Now click this div. "
: "Bugger =( oi.domReady did not work properly." );
oi.addEvent(e, 'click', (handler = function() {
e.innerHTML += ' //// ' + e.tagName.toLowerCase() + " was clicked."
if (!i--) {
oi.removeEvent(e, 'click', handler);
e.innerHTML = 'Event removed. Next click should do nothing. Event tests passed!';
e.removeAttribute('accesskey');
}
}));
});
}(document, aok, oi));
</script>
</head>
<body>
<div id="test" accesskey="3"></div>
</body>
</html>