|
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 Toolbar</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 |
.yui-toolbar { |
|
|
28 |
border: solid 1px #999; |
|
|
29 |
background-color: #ccc; |
|
|
30 |
margin: .25em; |
|
|
31 |
overflow: auto; |
|
|
32 |
} |
|
|
33 |
|
|
|
34 |
.yui-toolbar-button { |
|
|
35 |
display: inline-block; |
|
|
36 |
border-width: 1px 0; |
|
|
37 |
border-style: solid; |
|
|
38 |
border-color: #808080; |
|
|
39 |
background-color: #dfdfdf; |
|
|
40 |
margin: .25em; |
|
|
41 |
font-size: 85%; /* 11px */ |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
.first-child { |
|
|
45 |
margin-left: .5em; |
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
.yui-toolbar-button span { |
|
|
49 |
display: inline-block; |
|
|
50 |
border-width: 0 1px; |
|
|
51 |
border-style: solid; |
|
|
52 |
border-color: #808080; |
|
|
53 |
margin: 0 -1px; |
|
|
54 |
*position: relative; /* Necessary to get negative margins working in IE */ |
|
|
55 |
*left: -1px; |
|
|
56 |
} |
|
|
57 |
|
|
|
58 |
.yui-toolbar-button span span { |
|
|
59 |
display: inline-block; |
|
|
60 |
border: solid 1px #b6b6b6; |
|
|
61 |
margin: 0; |
|
|
62 |
*position: static; |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
.yui-toolbar-button input { |
|
|
66 |
border: none; |
|
|
67 |
margin: 0; |
|
|
68 |
padding: 4px 4px 4px 24px; |
|
|
69 |
*overflow: visible; /* Remove superfluous padding for IE */ |
|
|
70 |
background: transparent url(assets/icons.png) no-repeat; |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
#add-btn input { |
|
|
74 |
background-position: 4px -102px; |
|
|
75 |
*background-position: 4px -100px; |
|
|
76 |
} |
|
|
77 |
|
|
|
78 |
#edit-btn input { |
|
|
79 |
background-position: 4px -78px; |
|
|
80 |
*background-position: 4px -76px; |
|
|
81 |
} |
|
|
82 |
|
|
|
83 |
#print-btn input { |
|
|
84 |
background-position: 4px -54px; |
|
|
85 |
*background-position: 4px -52px; |
|
|
86 |
} |
|
|
87 |
|
|
|
88 |
#open-btn input { |
|
|
89 |
background-position: 4px -30px; |
|
|
90 |
*background-position: 4px -28px; |
|
|
91 |
} |
|
|
92 |
|
|
|
93 |
#delete-btn input { |
|
|
94 |
background-position: 4px -126px; |
|
|
95 |
*background-position: 4px -124px; |
|
|
96 |
} |
|
|
97 |
|
|
|
98 |
#save-btn input { |
|
|
99 |
background-position: 4px -6px; |
|
|
100 |
*background-position: 4px -4px; |
|
|
101 |
} |
|
|
102 |
|
|
|
103 |
|
|
|
104 |
/* Augment the browser's default styling of the focus state by changing the |
|
|
105 |
background color of the button when it is focused. */ |
|
|
106 |
|
|
|
107 |
.yui-toolbar-button input.focus { |
|
|
108 |
background-color: #B3D4FF; |
|
|
109 |
} |
|
|
110 |
|
|
|
111 |
</style> |
|
|
112 |
<!--end custom header content for this example--> |
|
|
113 |
|
|
|
114 |
</head> |
|
|
115 |
|
|
|
116 |
<body class=" yui-skin-sam"> |
|
|
117 |
|
|
|
118 |
<h1>Accessible Toolbar</h1> |
|
|
119 |
|
|
|
120 |
<div class="exampleIntro"> |
|
|
121 |
<p> |
|
|
122 |
This example illustrates how to create an accessible toolbar using the |
|
|
123 |
Focus Manager Node Plugin and Node's support for the |
|
|
124 |
<a href="http://www.w3.org/TR/wai-aria/">WAI-ARIA Roles and States</a>. |
|
|
125 |
</p> |
|
|
126 |
</div> |
|
|
127 |
|
|
|
128 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
129 |
|
|
|
130 |
<div id="toolbar-1" class="yui-toolbar"> |
|
|
131 |
<span id="add-btn" class="yui-toolbar-button first-child"><span><span><input type="button" name="btn-add" value="Add"></span></span></span> |
|
|
132 |
<span id="edit-btn" class="yui-toolbar-button"><span><span><input type="button" name="btn-edit" value="Edit"></span></span></span> |
|
|
133 |
<span id="print-btn" class="yui-toolbar-button"><span><span><input type="button" name="btn-print" value="Print"></span></span></span> |
|
|
134 |
<span id="delete-btn" class="yui-toolbar-button"><span><span><input type="button" name="btn-delete" value="Delete"></span></span></span> |
|
|
135 |
<span id="open-btn" class="yui-toolbar-button"><span><span><input type="button" name="btn-open" value="Open"></span></span></span> |
|
|
136 |
<span id="save-btn" class="yui-toolbar-button"><span><span><input type="button" name="btn-save" value="Save"></span></span></span> |
|
|
137 |
</div> |
|
|
138 |
|
|
|
139 |
<script type="text/javascript"> |
|
|
140 |
|
|
|
141 |
YUI({base:"../../build/", timeout: 10000}).use("node-focusmanager", function(Y) { |
|
|
142 |
|
|
|
143 |
// Retrieve the Node instance representing the toolbar |
|
|
144 |
// (<div id="toolbar">) and call the "plug" method |
|
|
145 |
// passing in a reference to the Focus Manager Node Plugin. |
|
|
146 |
|
|
|
147 |
var toolbar = Y.Node.get("#toolbar-1"); |
|
|
148 |
|
|
|
149 |
toolbar.plug(Y.Plugin.NodeFocusManager, { |
|
|
150 |
|
|
|
151 |
descendants: "input", |
|
|
152 |
keys: { next: "down:39", // Right arrow |
|
|
153 |
previous: "down:37" }, // Left arrow |
|
|
154 |
focusClass: "focus", |
|
|
155 |
circular: true |
|
|
156 |
|
|
|
157 |
}); |
|
|
158 |
|
|
|
159 |
|
|
|
160 |
// Set the ARIA "role" attribute of the Node instance representing the |
|
|
161 |
// toolbar to "toolbar" to improve the semantics of the markup for |
|
|
162 |
// users of screen readers. |
|
|
163 |
|
|
|
164 |
toolbar.set("role", "toolbar"); |
|
|
165 |
|
|
|
166 |
|
|
|
167 |
// Listen for the click event on each button via the use of the |
|
|
168 |
// "delegate" method |
|
|
169 |
|
|
|
170 |
toolbar.delegate("click", function (event) { |
|
|
171 |
|
|
|
172 |
alert("You clicked " + this.query("input").get("value")); |
|
|
173 |
|
|
|
174 |
}, ".yui-toolbar-button"); |
|
|
175 |
|
|
|
176 |
}); |
|
|
177 |
|
|
|
178 |
</script> |
|
|
179 |
|
|
|
180 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
181 |
|
|
|
182 |
</body> |
|
|
183 |
</html> |