-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
342 lines (322 loc) · 9.01 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!DOCTYPE html>
<html>
<head>
<!-- Original test page written by Dominic Mazzoni -->
<title>Focus Overlay Demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="dist/focusOverlay.css" />
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
div,
input,
textarea,
h1,
h2 {
font-family: arial, sans-serif;
}
div:not(.focus-overlay) {
margin: 1em 0;
}
div[contenteditable] {
width: 10em;
min-height: 2em;
padding: 0.2em;
border: 1px solid #000;
}
label {
display: block;
margin: 1em 0;
}
select {
width: 10em;
}
.foTest {
display: none;
margin: 0 10px;
}
a.transition-test {
display: block;
background: rgba(255, 255, 255, 0.8);
max-width: 260px;
padding: 10px;
text-transform: uppercase;
color: #06427c;
font-weight: bold;
font-size: 15px;
font-size: 0.9375rem;
border: 1px solid #f28d1d;
text-align: center;
transition: all 0.5s linear;
}
a.transition-test:hover,
a.transition-test:focus {
background: #06427c;
color: #fff;
text-decoration: none;
max-width: 300px;
}
a.transition-test.perm.trans {
background: #06427c;
color: #fff;
text-decoration: none;
max-width: 300px;
}
a.transition-test.inner span {
display: inline-block;
width: 30px;
height: 30px;
background: blue;
margin: 5px;
transition: all 1.5s linear;
}
a.transition-test.inner:hover span,
a.transition-test.inner:focus span {
background: orange;
}
.section-one {
border: 1px solid blue;
}
.section-two {
border: 1px solid green;
}
.section-two .focus-overlay {
box-shadow: 0 0 3px 2px green;
}
.section-two .focus-overlay:after {
box-shadow: 0 0 2px 1px green, 0 0 2px green inset;
}
small {
font-size: 0.6em;
}
</style>
</head>
<body>
<h1>
FocusOverlay -
<small
><a href="https://github.com/mmahandev/FocusOverlay">Repo</a></small
>
</h1>
<ul>
<li>
This page contains various html controls and demonstrates when the
keyboard is being used to show FocusOverlay.
</li>
<li>Navigate through the interactive elements with your tab key.</li>
<li>Outlined sections have their own scoped instance.</li>
</ul>
<h2>Buttons</h2>
<div class="section-one">
<b>Default Settings</b>
<div>
<label> <input type="checkbox" />Checkbox</label>
</div>
<div>
<label> <input name="a" type="radio" />Radio 1</label>
<label> <input name="b" type="radio" />Radio 2</label>
</div>
<div>
<button>Button</button>
</div>
<div>
<input type="submit" value="Submit button" />
</div>
<div>
<a href="#">Regular Link</a>
</div>
<h2 tabindex="0">Editable text</h2>
<div>
<input placeholder="Single line" />
</div>
<div>
<textarea placeholder="Multi line"></textarea>
</div>
<h2>Transitions</h2>
<div>
<a href="#" class="transition-test">Link with focus transition</a>
</div>
<div>
<a href="#" class="transition-test perm"
>Link with permanent focus transition</a
>
</div>
<div tabindex="0">
<a href="#" class="transition-test inner"
>Link with focus transition and outer element that's focusable</a
>
</div>
<div>
<a href="#" class="transition-test inner"
>Link with focus transition and inner element with focus transition
<span> </span>
</a>
</div>
<h2>Iframe</h2>
<iframe
width="320"
height="200"
src="https://www.youtube.com/embed/fEErySYqItI"
frameBorder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title="Inline Frame Example"
></iframe>
<div>
<div>
<a href="#" class="transition-test"
>Transitioned link after iframe focus</a
>
</div>
</div>
<div><a href="#">Regular link before iframe</a></div>
<iframe
width="320"
height="200"
src="https://www.youtube.com/embed/fEErySYqItI"
frameBorder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title="Inline Frame Example"
></iframe>
<div><input type="text" placeholder="Regular input after iframe" /></div>
<video controls width="250">
<source
src="//interactive-examples.mdn.mozilla.net/media/examples/flower.webm"
type="video/webm"
/>
<source
src="//interactive-examples.mdn.mozilla.net/media/examples/flower.mp4"
type="video/mp4"
/>
Sorry, your browser doesn't support embedded videos.
</video>
<div>
<input type="text" placeholder="Input after video" />
</div>
</div>
<div class="section-two">
<b><i>alwaysActive</i> set to true</b>
<div>
<div contenteditable="true">Contenteditable explicitly set to true</div>
</div>
<div>
<div contenteditable>Contenteditable</div>
</div>
<div>
<div role="textbox" contenteditable="true">
Contenteditable with textbox role
</div>
</div>
<h2>Focusable <code><div></code>s</h2>
<div tabindex="0">
<code>tabindex="0"</code>
</div>
<div tabindex="-1">
<code>tabindex="-1"</code>
</div>
<div tabindex="0">
<code>tabindex="0"</code>
</div>
<h2>Selects</h2>
<label
>Select one from drop-down:
<br />
<select>
<option>Apple</option>
<option>Orange</option>
<option>Banana</option>
</select>
</label>
<label
>Select one from list:
<br />
<select size="5">
<option>Apple</option>
<option>Orange</option>
<option>Banana</option>
</select>
</label>
<label
>Select multiple:
<br />
<select multiple="">
<option>Apple</option>
<option>Orange</option>
<option>Banana</option>
</select>
</label>
<h2>Other</h2>
<label
>data-focus-label with no <i>for</i> attribute:
<br />
<input data-focus-label type="range" min="-20" max="20" value="0" />
</label>
<label
>Bowling score from 0 to 300:
<br />
<input type="range" min="0" max="300" value="0" />
</label>
<div>
<input type="date" value="2008-09-01" />
</div>
<div>
<input type="time" value="00:00:00" />
</div>
<div>
<input type="number" placeholder="Number" />
</div>
<div>
<input type="color" title="Color" value="#00ff00" />
</div>
<div>
<input type="file" title="File" />
</div>
</div>
<h2>FocusOverlay is not called on the elements below</h2>
<div>
<label> <input type="checkbox" />Checkbox</label>
</div>
<div>
<label> <input name="a" type="radio" />Radio 1</label>
<label> <input name="b" type="radio" />Radio 2</label>
</div>
<div>
<button>Button</button>
</div>
<script src="dist/focusOverlay.js"></script>
<script>
// Tests
const focusable = document.querySelectorAll(
'input, a, iframe, object, embed, [tabindex], [contenteditable], button, textarea, select, area'
);
for (let i = 0; i < focusable.length; i++) {
focusable[i].setAttribute('id', 'control-' + i);
}
document.querySelector('.perm').addEventListener('focusin', function(e) {
e.target.classList.add('trans');
});
// Initialization
const sectionOne = document.querySelector('.section-one');
const sectionTwo = document.querySelector('.section-two');
const foOne = new FocusOverlay('.section-one', {
onInit: function(focusOverlay) {
console.log('ran', focusOverlay);
},
onBeforeMove: function(currentTarget, nextTarget, focusOverlay) {
console.log(currentTarget, nextTarget, focusOverlay);
},
// onAfterMove: function (previousTarget, currentTarget, focusOverlay) {
// console.log(previousTarget, currentTarget, focusOverlay);
// },
onDestroy: function(focusOverlay) {
console.log('de_stroyed');
}
});
const foTwo = new FocusOverlay(sectionTwo, {
alwaysActive: true
});
</script>
</body>
</html>