-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patha11y-slides-math-template.html
433 lines (387 loc) · 11.8 KB
/
a11y-slides-math-template.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<!--
#
# a11y-slides-math-template.html
# V0.7, 2025-02-12
#
-->
<html>
<head>
<meta charset="UTF-8"/>
<meta name="keywords" content="a11y, accessibility, slides, HTML"/>
<meta name="author" content="Your name here"/>
<title>Your title goes here</title>
</head>
<!--
#
# DOCUMENT body
#
-->
<body onload="initiateSlides()">
<div id="slideshow-container">
<div class="slide">
<h1>opening slide</h1>
<p>name</p>
<p>institution/organisation</p>
<p>date</p>
</div>
<div class="slide">
<h1>overview</h1>
<ol>
<li>one</li>
<li>two</li>
<li>three</li>
</ol>
</div>
<div class="slide">
<h1>some mathematical content</h1>
<p>A function \[f(x)=\frac{1}{x^2+3}\]</p>
<p>A more complicated example:
\[
\int_B\left(v\nabla ^2v+|\operatorname{grad} v|^2\right) dV=\oint_S v\frac{\partial v}{\partial n}\,dA
\]</p>
<div class="related-resource">
<p>Related resources: <a href="https://docs.mathjax.org/en/v2.7-latest/options/extensions/a11y-extensions.html?highlight=a11y#the-accessibility-extensions">MathJax Accessibility extensions</a>,
<a href="https://www.w3.org/WAI/WCAG21/quickref/#non-text-content">WCAG 1.1.1</a>,
<a href="https://www.w3.org/WAI/WCAG21/quickref/#info-and-relationships">WCAG 1.3.1</a>,
<a href="https://www.w3.org/WAI/WCAG21/quickref/#keyboard-accessible">WCAG 2.1.1</a></p>
</div>
</div>
</div>
<div id="nav-outer">
<div id="nav-inner">
<p><a id="prev-slide" onclick="prevSlide()" aria-label="previous">❮</a> <span id="slide-status">slide</span> <a id="next-slide" onclick="nextSlide()" aria-label="next">❯</a></p>
</div>
</div>
</body>
<!--
# ===========================================================
#
# a11y-slides-math JS and CSS settings
#
# edit/ignore as you see fit
#
# ===========================================================
#
-->
<!--
# ...............................................
# MathJax config
# https://docs.mathjax.org/en/latest/options/menu.html
# http://docs.mathjax.org/en/latest/web/start.html#using-mathjax-from-a-content-delivery-network-cdn
# ...............................................
#
-->
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
options: {
enableMenu: true, // set to false to disable the menu
menuOptions: {
settings: {
texHints: true, // put TeX-related attributes on MathML
semantics: false, // put original format in semantic tag in MathML
zoom: 'Click', // or 'Click' or 'DoubleClick' as zoom trigger
zscale: '200%', // zoom scaling factor
renderer: 'CHTML', // or 'SVG'
alt: false, // true if ALT required for zooming
cmd: false, // true if CMD required for zooming
ctrl: false, // true if CTRL required for zooming
shift: false, // true if SHIFT required for zooming
scale: 1, // scaling factor for all math
inTabOrder: true, // true if tabbing includes math
assistiveMml: true, // true if hidden assistive MathML should be generated for screen readers
collapsible: false, // true if complex math should be collapsible
explorer: true, // true if the expression explorer should be active
},
annotationTypes: {
TeX: ['TeX', 'LaTeX', 'application/x-tex'],
StarMath: ['StarMath 5.0'],
Maple: ['Maple'],
ContentMathML: ['MathML-Content', 'application/mathml-content+xml'],
OpenMath: ['OpenMath']
}
}
}
};
</script>
<script type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
<!--
#
# ...............................................
# Javascript section
# ...............................................
#
-->
<script type="text/javascript">
let slideIndex = 0;
const slides = document.getElementsByClassName("slide");
// initialise the slides visibility, based on sessionStorage
function initiateSlides() {
sessionStorage.setItem("all-slides-visible", 0);
// loop through the slides
let previousSessionActive = 0;
for (let i = 0; i < slides.length; i++) {
const currentslide = "slide" + i
slides[i].id = currentslide;
// check for session storage
if (sessionStorage.length > 0 && sessionStorage.getItem(currentslide) > 0) {
showSlides(i);
previousSessionActive = 1;
}
}
// possibly show the first slide
if (previousSessionActive == 0) {
showSlides(0);
}
// ARIA *vital* to announce H1 on change of slide, see
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions
document.getElementById("slideshow-container").ariaLive = "polite"
}
function showSlides(n) {
if (n < 0) { n = 0; }
slideIndex = n % slides.length;
// hide ALL slides
for (let i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
sessionStorage.setItem("slide" + i, 0);
}
// unhide CURRENT slide
slides[slideIndex].style.display = "block";
sessionStorage.setItem("slide" + slideIndex, 1);
// update < slide n of m >
document.getElementById("slide-status").textContent = "slide " + (slideIndex + 1) + " of " + slides.length
// gray out the prev/next button if at begin/end
if (n == (slides.length - 1)) {
document.getElementById("prev-slide").style.color = "black"
document.getElementById("next-slide").style.color = "#bbb"
} else if (n == 0) {
document.getElementById("prev-slide").style.color = "#bbb"
document.getElementById("next-slide").style.color = "black"
} else {
document.getElementById("prev-slide").style.color = "black"
document.getElementById("next-slide").style.color = "black"
}
// WARNING: *avoid* the following, see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/heading_role
// document.getElementById("slideshow-container").ariaLabel = "slide "+(slideIndex+1)
}
function moveSlide(n) {
showSlides(slideIndex += n);
}
function prevSlide() {
moveSlide(-1);
}
function nextSlide() {
// check we're not on last slide
if (sessionStorage.getItem("slide" + (slides.length - 1)) < 1) {
moveSlide(1);
}
}
// arrow key event listeners, https://stackoverflow.com/a/9310900/1091649
document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
if (e.keyCode == 38) {
// up arrow
// prevSlide();
} else if (e.keyCode == 40) {
// down arrow
// nextSlide();
} else if (e.keyCode == 37) {
// left arrow
// check for 'all-slides-visible' mode, and adjust as necessary
if (sessionStorage.getItem("all-slides-visible") > 0) {
toggleAllSlides();
}
prevSlide();
} else if (e.keyCode == 39) {
// right arrow
// check for 'all-slides-visible' mode, and adjust as necessary
if (sessionStorage.getItem("all-slides-visible") > 0) {
toggleAllSlides();
}
nextSlide();
} else if (e.shiftKey && e.keyCode == 80) {
// SHIFT+p
toggleAllSlides();
}
}
// toggle all slides for printing (or other reasons)
function toggleAllSlides() {
let slidePosition;
let slideBorder;
let slideDisplay;
// toggle back to individual slide
if (sessionStorage.getItem("all-slides-visible") > 0) {
sessionStorage.setItem("all-slides-visible", 0);
slidePosition = "absolute";
slideBorder = "none";
slideDisplay = "none";
// toggle nav
document.getElementById("nav-outer").style.display = "block";
document.getElementById("slideshow-container").ariaLabel = null;
} else {
// toggle to all slides
sessionStorage.setItem("all-slides-visible", 1);
slidePosition = "static";
slideBorder = "solid";
slideDisplay = "block";
// toggle nav
document.getElementById("nav-outer").style.display = "none";
document.getElementById("slideshow-container").ariaLabel = "All slides shown, useful for printing. Press SHIFT+P or LEFT or RIGHT to go individual slide";
}
// loop through slides, toggle CSS for printing/not printing
for (let i = 0; i < slides.length; i++) {
slides[i].style.position = slidePosition;
slides[i].style.borderStyle = slideBorder;
slides[i].style.display = slideDisplay;
}
// finally, possibly toggle active slide back on
if (sessionStorage.getItem("all-slides-visible") < 1) {
for (let i = 0; i < slides.length; i++) {
const currentslide = "slide" + i;
// toggle individual slide visibility back
if (sessionStorage.length > 0 && sessionStorage.getItem(currentslide) > 0) {
showSlides(i);
}
}
}
}
// swipe slides, https://stackoverflow.com/a/56663695/1091649
let touchstartX = 0;
let touchendX = 0;
function checkDirection() {
if (touchendX < touchstartX && Math.abs(touchstartX - touchendX) > 50) {
nextSlide();
}
if (touchendX > touchstartX && Math.abs(touchstartX - touchendX) > 50) {
prevSlide();
}
}
document.addEventListener('touchstart', e => {
touchstartX = e.changedTouches[0].screenX;
})
document.addEventListener('touchend', e => {
touchendX = e.changedTouches[0].screenX;
checkDirection();
})
</script>
<!--
#
# ...............................................
# CSS section; note, this is attempted to be 'mobile first' oriented
# ...............................................
#
-->
<style type="text/css">
html, body {
height: 100%; /*https://stackoverflow.com/a/30694851/1091649*/
}
body, h1, h2, h3, h4, h5, h6 {
font-family: Arial, sans-serif;
}
/* https://stackoverflow.com/questions/9174669/best-practice-font-size-for-mobile */
h1 { font-size: 2.5rem; }
h2 { font-size: 2.25rem; }
h3 { font-size: 2rem; }
h4 { font-size: 1.75rem; }
h5 { font-size: 1.5rem; }
h6 { font-size: 1.25rem; }
p, li {
font-size: 2rem;
margin-bottom: 2rem; /*https://www.w3.org/WAI/WCAG21/Understanding/text-spacing.html*/
}
#slideshow-container {
position: relative;
width: 100%;
height: 85%;
}
.slide {
position: absolute;
width: 100%;
height: 100%;
display: none;
margin: 0px;
break-after: page; /* for printing to pdf */
overflow: auto; /* allow vertical scroll bar when needed */
}
#nav-outer {
display: block;
width: 100%;
height: 3%;
padding: 0px;
}
#nav-inner {
float: right;
}
#prev-slide, #next-slide {
padding: 16px;
font-weight: bold;
font-size: 30px;
cursor: pointer;
}
.related-resource {
border-top: 1px solid #bbb;
}
/* reference: https://webaim.org/techniques/hypertext/link_text */
a:link {
text-decoration: underline;
}
a:hover, a:focus {
text-decoration: underline;
background-color: #ffffcc;
color: #BF1722;
border-top: 1px solid #bbb;
border-bottom: 1px solid #bbb;
border-radius: 4px;
}
/**
#
# CSS Screen size adjustments
#
# https://stackoverflow.com/a/70727606/1091649
#
**/
@media only screen and (min-width: 1000px) {
#slideshow-container {
position: relative;
width: 80%;
height: 85%;
}
.slide {
margin: 20px;
}
#nav-outer {
width: 80%;
}
}
@media (max-width: 480px) {
html {
font-size: 12px;
}
}
@media (min-width: 480px) {
html {
font-size: 13px;
}
}
@media (min-width: 768px) {
html {
font-size: 14px;
}
}
@media (min-width: 992px) {
html {
font-size: 15px;
}
}
@media (min-width: 1200px) {
html {
font-size: 16px;
}
}
</style>
</html>