|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
6 |
<title>Accessible Menu Button</title> |
|
|
7 |
|
|
|
8 |
<style type="text/css"> |
|
|
9 |
/*margin and padding on body element |
|
|
10 |
can introduce errors in determining |
|
|
11 |
element position and are not recommended; |
|
|
12 |
we turn them off as a foundation for YUI |
|
|
13 |
CSS treatments. */ |
|
|
14 |
body { |
|
|
15 |
margin:0; |
|
|
16 |
padding:0; |
|
|
17 |
} |
|
|
18 |
</style> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<!--begin custom header content for this example--> |
|
|
25 |
<style type="text/css"> |
|
|
26 |
|
|
|
27 |
/* The following two styles are necessary to override style rules in the |
|
|
28 |
YUI CSS file. */ |
|
|
29 |
|
|
|
30 |
#example ul { |
|
|
31 |
margin: 0; |
|
|
32 |
} |
|
|
33 |
|
|
|
34 |
#example a:hover { |
|
|
35 |
text-decoration: none; |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
/* Hide the list while it is being transformed into a menu. */ |
|
|
40 |
|
|
|
41 |
.yui-loading #menu-1, |
|
|
42 |
.yui-loading #button-1 { |
|
|
43 |
display: none; |
|
|
44 |
} |
|
|
45 |
|
|
|
46 |
</style> |
|
|
47 |
|
|
|
48 |
<script type="text/javascript"> |
|
|
49 |
|
|
|
50 |
// Add a class to the documentElement to prevent the user from seeing |
|
|
51 |
// the unstyled menu while the necessary CSS and JavaScript |
|
|
52 |
// dependancies are being fetched. |
|
|
53 |
|
|
|
54 |
document.documentElement.className = "yui-loading"; |
|
|
55 |
|
|
|
56 |
</script> |
|
|
57 |
<!--end custom header content for this example--> |
|
|
58 |
|
|
|
59 |
</head> |
|
|
60 |
|
|
|
61 |
<body class=" yui-skin-sam"> |
|
|
62 |
|
|
|
63 |
<h1>Accessible Menu Button</h1> |
|
|
64 |
|
|
|
65 |
<div class="exampleIntro"> |
|
|
66 |
<p> |
|
|
67 |
This example illustrates how to use the Focus Manager Node Plugin, |
|
|
68 |
Event's <a href="../../api/YUI.html#event_delegate">delegation support</a> and |
|
|
69 |
<a href="../../api/YUI.html#event_mouseenter">mouseenter</a> event, along with |
|
|
70 |
the <a href="../../overlay/">Overlay widget</a> and Node's support for the |
|
|
71 |
<a href="http://www.w3.org/TR/wai-aria/">WAI-ARIA Roles and States</a> to |
|
|
72 |
create an accessible menu button. |
|
|
73 |
</p> |
|
|
74 |
</div> |
|
|
75 |
|
|
|
76 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
77 |
|
|
|
78 |
<a id="button-1" href="#menu-1"><span><span>Move To</span></span></a> |
|
|
79 |
<div id="menu-1"> |
|
|
80 |
<ul> |
|
|
81 |
<li><input type="button" name="button-1" value="Inbox"></li> |
|
|
82 |
<li><input type="button" name="button-2" value="Archive"></li> |
|
|
83 |
<li><input type="button" name="button-3" value="Trash"></li> |
|
|
84 |
</ul> |
|
|
85 |
</div> |
|
|
86 |
|
|
|
87 |
<script type="text/javascript"> |
|
|
88 |
|
|
|
89 |
YUI({ |
|
|
90 |
base:"../../build/", |
|
|
91 |
timeout: 10000, |
|
|
92 |
modules: { |
|
|
93 |
"menubuttoncss": { |
|
|
94 |
type: "css", |
|
|
95 |
fullpath: "assets/menubutton.css" |
|
|
96 |
}, |
|
|
97 |
"menubuttonjs": { |
|
|
98 |
type: "js", |
|
|
99 |
fullpath: "assets/menubutton.js", |
|
|
100 |
requires: ["menubuttoncss", "node-focusmanager", "node-event-simulate", "overlay"] |
|
|
101 |
} |
|
|
102 |
} |
|
|
103 |
|
|
|
104 |
}).use("menubuttonjs", function(Y, result) { |
|
|
105 |
|
|
|
106 |
// The callback supplied to use() will be executed regardless of |
|
|
107 |
// whether the operation was successful or not. The second parameter |
|
|
108 |
// is a result object that has the status of the operation. We can |
|
|
109 |
// use this to try to recover from failures or timeouts. |
|
|
110 |
|
|
|
111 |
if (!result.success) { |
|
|
112 |
|
|
|
113 |
Y.log("Load failure: " + result.msg, "warn", "Example"); |
|
|
114 |
|
|
|
115 |
// Show the menu button HTML if loading the JavaScript resources |
|
|
116 |
// failed, that way the original unskinned menu button |
|
|
117 |
// will be visible so that the user can interact with the menu |
|
|
118 |
// either way. |
|
|
119 |
|
|
|
120 |
document.documentElement.className = ""; |
|
|
121 |
|
|
|
122 |
} |
|
|
123 |
|
|
|
124 |
}); |
|
|
125 |
|
|
|
126 |
</script> |
|
|
127 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
128 |
|
|
|
129 |
</body> |
|
|
130 |
</html> |