1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
<title>MouseEnter and MouseLeave Event Tests</title>
9
<link rel="stylesheet" type="text/css" href="../../../../build/cssreset/reset-min.css">
10
<link rel="stylesheet" type="text/css" href="../../../../build/cssbase/base-min.css">
11
<style type="text/css">
14
background-color: #ccc;
23
background-color: #fc0;
30
background-color: #333;
36
background-color: #999;
42
.container ul li.hover {
43
background-color: #ff6;
50
background-color: #666;
54
.container ul li.outline {
59
background-color: blue;
64
<!--script src="/sand/delegate_leak_files/heapsize.js"></script-->
65
<script type="text/javascript" src="../../../../build/yui/yui.js"></script>
66
<!--script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui.js"></script-->
68
<script type="text/javascript">
70
//base: '../../../../build/',
72
}).use('event-custom', 'event', 'node-style', function (Y) {
76
Y.one = (function (original) {
79
return original.apply(Y, arguments);
84
//var memsnap = trackMemory(Y);
86
var onContainerMouseEnter = function (event) {
88
if (event.currentTarget == this) {
89
this.addClass("hover");
94
var onContainerMouseLeave = function (event) {
96
if (event.currentTarget == this) {
97
this.removeClass("hover");
102
var onLIMouseEnter = function (event) {
104
if (event.container.get("id") == "container-1") {
105
this.addClass("hover");
110
var onLIMouseLeave = function (event) {
112
if (event.container.get("id") == "container-1") {
113
this.removeClass("hover");
118
var addContainerOutline = function (event, className) {
120
event.currentTarget.addClass(className);
124
var removeContainerOutline = function (event) {
126
event.currentTarget.removeClass(this);
131
var addLIOutline = function (event, className) {
133
event.currentTarget.addClass(className);
137
var removeLIOutline = function (event) {
139
event.currentTarget.removeClass(this);
143
var setLIColor = function (event) {
145
this.setStyle("color", "#fff");
149
var removeLIColor = function (event) {
151
this.setStyle("color", "");
155
var handle1 = Y.on("mouseenter", onContainerMouseEnter, "#container-1");
156
var handle2 = Y.on("mouseleave", onContainerMouseLeave, "#container-1");
158
var handle3 = Y.on("mouseenter", addContainerOutline, "#container-1", Y, "outline");
159
var handle4 = Y.on("mouseleave", removeContainerOutline, "#container-1", "outline");
161
var handle5 = Y.on("mouseenter", setLIColor, "#container-1 li");
162
var handle6 = Y.on("mouseleave", removeLIColor, "#container-1 li");
164
var handle7 = Y.delegate("mouseenter", onLIMouseEnter, "#container-1", "li");
165
var handle8 = Y.delegate("mouseleave", onLIMouseLeave, "#container-1", "li");
167
var handle9 = Y.delegate("mouseenter", addLIOutline, "#container-1", "li", Y, "outline");
168
var handle10 = Y.delegate("mouseleave", removeLIOutline, "#container-1", "li", "outline");
171
Y.on("click", function () {
184
}, "#remove-listeners");
186
document.getElementById('memsize').onclick = function () {
188
//console.log(count);
189
console.log(Y.Object.keys(Y.Node._instances).length);
197
<h1>MouseEnter and MouseLeave Event Tests</h1>
200
<li>The background color of the <code>div</code> element should turn
201
orange and have a red outline when you move the mouse over it.</li>
202
<li>The background color of each <code>li</code> should change to yellow
203
when you mouse over it and have a red outline.</li>
206
<div id="container-1" class="container">
209
<p><span>This</span></p>
211
<p><strong>a</strong></p>
213
<blockquote><p>of</p></blockquote>
223
<em id="em1">Item Type One</em>
225
<li id="li2"><em id="em2">Item Type Two</em></li>
226
<li id="li3"><em id="em3">Item Type Three</em></li>
230
<button id="remove-listeners">Remove Listeners</button>
231
<button id="memsize">Check memory</button>