forked from adobe-accessibility/Accessible-Mega-Menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
786 lines (692 loc) · 38.8 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
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<!DOCTYPE html>
<html lang="en">
<head>
<!--
Copyright © 2013 Adobe Systems Incorporated.
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Accessible Mega Menu</title>
<script src="//use.edgefonts.net/source-sans-pro.js"></script>
<script src="//google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
<script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/megamenu.css">
<script src="js/jquery-accessibleMegaMenu.js"></script>
<script src="js/main.js"></script>
</head>
<body class="init">
<div class="LayoutGrid LayoutCenter PanelDiffuseShadow PanelFillExtraLight">
<nav class="megamenu">
<ol>
<li>
<h2><a href="http://www.w3.org/TR/WCAG/#perceivable">Perceivable</a></h2>
<div class="cols-4">
<p>Information and user interface components must be presentable to users in ways they can perceive.</p>
<ol>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG/#text-equiv">1.1 Text Alternatives</a></h3>
<p>Provide text alternatives for any non-text content so that it can be changed into other forms people need, such as large print, braille, speech, symbols or simpler language.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#text-equiv-all">1.1.1 Non-text Content</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG/#media-equiv">1.2 Time-based Media</a></h3>
<p>Provide alternatives for time-based media.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-av-only-alt">1.2.1 Audio-only and Video-only (Prerecorded)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-captions">1.2.2 Captions (Prerecorded)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-audio-desc">1.2.3 Audio Description or Media Alternative (Prerecorded)</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-captions">1.2.4 Captions (Live)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-audio-desc-only">1.2.5 Audio Description (Prerecorded)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-sign">1.2.6 Sign Language (Prerecorded)</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-extended-ad">1.2.7 Extended Audio Description (Prerecorded)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-text-doc">1.2.8 Media Alternative (Prerecorded)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#media-equiv-live-audio-only">1.2.9 Audio-only (Live)</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#content-structure-separation">1.3 Adaptable</a></h3>
<p>Create content that can be presented in different ways (for example simpler layout) without losing information or structure.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#content-structure-separation-programmatic">1.3.1 Info and Relationships</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#content-structure-separation-sequence">1.3.2 Meaningful Sequence</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#content-structure-separation-understanding">1.3.3 Sensory Characteristics</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast">1.4 Distinguishable</a></h3>
<p>Make it easier for users to see and hear content including separating foreground from background.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-without-color">1.4.1 Use of Color</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-dis-audio">1.4.2 Audio Control</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast">1.4.3 Contrast (Minimum)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-scale">1.4.4 Resize Text</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-text-presentation">1.4.5 Images of Text</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast7">1.4.6 Contrast (Enhanced)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-noaudio">1.4.7 Low or No Background Audio</a></li>
<li><a href="http://www.w3.org/WAI/WCAG20/quickref/#qr-visual-audio-contrast-visual-presentation">1.4.8 Visual Presentation</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#visual-audio-contrast-text-images">1.4.9 Images of Text (No Exception)</a></li>
</ol>
</li>
</ol>
</div>
</li>
<li>
<h2><a href="http://www.w3.org/TR/WCAG/#operable">Operable</a></h2>
<div class="cols-4b">
<p>User interface components and navigation must be operable.</p>
<ol>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#keyboard-operation">2.1 Keyboard Accessible</a></h3>
<p>Make all functionality available from a keyboard.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#keyboard-operation-keyboard-operable">2.1.1 Keyboard</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#keyboard-operation-trapping">2.1.2 No Keyboard Trap</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#keyboard-operation-all-funcs">2.1.3 Keyboard (No Exception)</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#time-limits">2.2 Enough Time</a></h3>
<p>Provide users enough time to read and use content.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#time-limits-required-behaviors">2.2.1 Timing Adjustable</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#time-limits-pause">2.2.2 Pause, Stop, Hide</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#time-limits-no-exceptions">2.2.3 Interruptions</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#time-limits-postponed">2.2.4 Interruptions</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#time-limits-server-timeout">2.2.5 Re-authenticating</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#seizure">2.3 Seizures</a></h3>
<p>Do not design content in a way that is known to cause seizures.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#seizure-does-not-violate">2.3.1 Three Flashes or Below Threshold</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#seizure-three-times">2.3.2 Three Flashes</a> </li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms">2.4 Navigable</a></h3>
<p>Provide ways to help users navigate, find content, and determine where they are.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-skip">2.4.1 Bypass Blocks</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-title">2.4.2 Page Titled</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-focus-order">2.4.3 Focus Order</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-refs">2.4.4 Link Purpose (In Context)</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-mult-loc">2.4.5 Multiple Ways</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-descriptive">2.4.6 Headings and Labels</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-focus-visible">2.4.7 Focus Visible</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-location">2.4.8 Location</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-link">2.4.9 Link Purpose (Link Only)</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#navigation-mechanisms-headings">2.4.10 Section Headings</a></li>
</ol>
</li>
</ol>
</div>
</li>
<li>
<h2><a href="http://www.w3.org/TR/WCAG/#understandable">Understandable</a></h2>
<div class="cols-3">
<p>Information and the operation of user interface must be understandable.</p>
<ol>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#meaning">3.1 Readable</a></h3>
<p>Make text content readable and understandable.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-doc-lang-id">3.1.1 Language of Page</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-other-lang-id">3.1.2 Language of Parts</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-idioms">3.1.3 Unusual Words</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-located">3.1.4 Abbreviations</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-supplements">3.1.5 Reading Level</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#meaning-pronunciation">3.1.6 Pronunciation</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior">3.2 Predictable</a></h3>
<p>Make Web pages appear and operate in predictable ways.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior-receive-focus">3.2.1 On Focus</a> </li>
<li><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior-unpredictable-change">3.2.2 On Input</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior-consistent-locations">3.2.3 Consistent Navigation</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior-consistent-functionality">3.2.4 Consistent Identification</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#consistent-behavior-no-extreme-changes-context">3.2.5 Change on Request</a></li>
</ol>
</li>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#minimize-error">3.3 Input Assistance</a></h3>
<p>Help users avoid and correct mistakes.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-identified">3.3.1 Error Identification</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-cues">3.3.2 Labels or Instructions</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-suggestions">3.3.3 Error Suggestion</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-reversible">3.3.4 Error Prevention (Legal, Financial, Data)</a>
<hr/>
</li>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-context-help">3.3.5 Help</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#minimize-error-reversible-all">3.3.6 Error Prevention (All)</a></li>
</ol>
</li>
</ol>
</div>
</li>
<li>
<h2><a href="http://www.w3.org/TR/WCAG/#robust">Robust</a></h2>
<div class="cols-1">
<p>Content must be robust enough that it can be interpreted reliably by a wide variety of user agents, including assistive technologies.</p>
<ol>
<li class="accessible-megamenu-panel-group">
<h3><a href="http://www.w3.org/TR/WCAG20/#ensure-compat">4.1 Compatible</a></h3>
<p>Maximize compatibility with current and future user agents, including assistive technologies.</p>
<ol>
<li><a href="http://www.w3.org/TR/WCAG20/#ensure-compat-parses">4.1.1 Parsing</a></li>
<li><a href="http://www.w3.org/TR/WCAG20/#ensure-compat-rsv">4.1.2 Name, Role, Value</a></li>
</ol>
</li>
</ol>
</div>
</li>
</ol>
</nav>
<main role="main">
<h1>An Accessible Mega Menu</h1>
<p>The navigation at the top of this page demonstrates how one can implement an accessible mega menu as a jQuery plugin. It is modeled after the mega menu on <a href="http://adobe.com/">adobe.com</a> but has been simplified for use by others. An brief explanation of our interaction design choices can be found in a blog post at <a href="http://blogs.adobe.com/accessibility/2013/05/adobe-com.html">Mega menu accessibility on adobe.com</a>.</p>
<p>Content for the links and text within the mega menu comes from the <a href="http://www.w3.org/TR/WCAG/">Web Content Accessibility Guidelines (WCAG) 2.0</a>.</p>
<h2>Keyboard Accessibility</h2>
<p>The accessible mega menu supports keyboard interaction modeled after the behavior described in the <a href="http://www.w3.org/TR/wai-aria-practices/#menu">WAI-ARIA Menu or Menu bar (widget) design pattern</a>, however we also try to respect users' general expectations for the behavior of links in a global navigation. To this end, the accessible mega menu implementation permits tab focus on each of the six top-level menu items. When one of the menu items has focus, pressing the Enter key, Spacebar or Down arrow will open the submenu panel, and pressing the Left or Right arrow key will shift focus to the adjacent menu item. Links within the submenu panels are included in the tab order when the panel is open. They can also be navigated with the arrow keys or by typing the first character in the link name, which speeds up keyboard navigation considerably. Pressing the Escape key closes the submenu and restores focus to the parent menu item.</p>
<h2>Screen Reader Accessibility</h2>
<p>The accessible mega menu models its use of WAI-ARIA Roles, States, and Properties after those described in the <a href="http://www.w3.org/TR/wai-aria-practices/#menu">WAI-ARIA Menu or Menu bar (widget) design pattern</a> with some notable exceptions, so that it behaves better with screen reader user expectations for global navigation. We don't use <code class="prettyprint">role="menu"</code> for the menu container and <code class="prettyprint">role="menuitem"</code> for each of the links therein, because if we do, assistive technology will no longer interpret the links as links, but instead, as menu items, and the links in our global navigation will no longer show up when a screen reader user executes a shortcut command to bring up a list of links in the page.</p>
<p>We also want to maintain the semantic structure of the submenu panels in our mega menu; our links are organized into lists and separated by headings. Omitting <code class="prettyprint">role="menu"</code> and <code class="prettyprint">role="menuitem"</code> for the global navigation seems the safer way to go.</p>
<h2>Usage</h2>
<h3>HTML</h3>
<p>The HTML structure for the mega menu is a nav element, or any other container element, containing a list. Each list item contains a link which is followed by a div or any other container element which will serve as the pop up panel. The panel can contain any html content; in the following example, each panel contains three lists of links. You can explicitly define groups within the panel, between which a user can navigate quickly using the left and right arrow keys; in the following example, the CSS class <code class="prettyprint">.sub-nav-group</code> identifies a navigable group.</p>
<pre class="prettyprint">
<nav>
<ul class="nav-menu">
<li class="nav-item">
<a href="?movie">Movies</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?movie&genre=0">Action & Adventure</a></li>
<li><a href="?movie&genre=2">Children & Family</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=7">Dramas</a></li>
<li><a href="?movie&genre=9">Foreign</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=14">Musicals</a></li>
<li><a href="?movie&genre=15">Romance</a></li>
<li>&#8230;</li>
</ul>
</div>
</li>
<li class="nav-item">
<a href="?tv">TV Shows</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?tv&genre=20">Classic TV</a></li>
<li><a href="?tv&genre=21">Crime TV</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=27">Reality TV</a></li>
<li><a href="?tv&genre=30">TV Action</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=33">TV Dramas</a></li>
<li><a href="?tv&genre=34">TV Horror</a></li>
<li>&#8230;</li>
</ul>
</div>
</li>
</ul>
</nav></pre>
<p>By default, accessibleMegaMenu uses the the following CSS classes to define the top-level navigation items, panels, groups within the panels, and the hover, focus, and open states. It also defines a prefix for unique id strings, which are required to indicate the relationship of a top-level navigation item to the panel it controls.</p>
<pre class="prettyprint">
defaults = {
/* unique ID's are required to indicate aria-owns, aria-controls and aria-labelledby */
uuidPrefix: "accessible-megamenu",
/* default css class used to define the megamenu styling */
menuClass: "accessible-megamenu",
/* default css class for a top-level navigation item in the megamenu */
topNavItemClass: "accessible-megamenu-top-nav-item",
/* default css class for a megamenu panel */
panelClass: "accessible-megamenu-panel",
/* default css class for a group of items within a megamenu panel */
panelGroupClass: "accessible-megamenu-panel-group",
/* default css class for the hover state */
hoverClass: "hover",
/* default css class for the focus state */
focusClass: "focus",
/* default css class for the open state */
openClass: "open"
}</pre>
<p>You can optionally override the defaults to use the CSS classes you may have already defined for your mega menu.</p>
<h3>JavaScript</h3>
<p>Be sure to include jQuery and the jquery-accessibleMegaMenu.js plugin script.</p>
<pre class="prettyprint">
<script src="js/vendor/jquery-1.10.1.min.js"></script>
<script src="js/jquery-accessibleMegaMenu.js"></script></pre>
<p>The following initializes the first nav element in the document as an accessibleMegaMenu, with optional CSS class overrides.</p>
<pre class="prettyprint">
$("nav:first").accessibleMegaMenu({
/* prefix for generated unique id attributes, which are required
to indicate aria-owns, aria-controls and aria-labelledby */
uuidPrefix: "accessible-megamenu",
/* css class used to define the megamenu styling */
menuClass: "nav-menu",
/* css class for a top-level navigation item in the megamenu */
topNavItemClass: "nav-item",
/* css class for a megamenu panel */
panelClass: "sub-nav",
/* css class for a group of items within a megamenu panel */
panelGroupClass: "sub-nav-group",
/* css class for the hover state */
hoverClass: "hover",
/* css class for the focus state */
focusClass: "focus",
/* css class for the open state */
openClass: "open"
});</pre>
<h3>CSS</h3>
<p>AccessibleMegaMenu handles the showing and hiding of panels by adding or removing a CSS class. No inline styles are added to hide elements or create animation between states.</p>
<p>Following is some rudimentary CSS for our example which enables the showing/hiding of and the layout of lists panels in the mega menu.</p>
<pre class="prettyprint">
/* Rudimentary mega menu CSS for demonstration */
/* mega menu list */
.nav-menu {
display: block;
position: relative;
list-style: none;
margin: 0;
padding: 0;
z-index: 15;
}
/* a top level navigation item in the mega menu */
.nav-item {
list-style: none;
display: inline-block;
padding: 0;
margin: 0;
}
/* first descendant link within a top level navigation item */
.nav-item > a {
position: relative;
display: inline-block;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
border: 1px solid transparent;
}
/* focus/open states of first descendant link within a top level
navigation item */
.nav-item > a:focus,
.nav-item > a.open {
border: 1px solid #dedede;
}
/* open state of first descendant link within a top level
navigation item */
.nav-item > a.open {
background-color: #fff;
border-bottom: none;
z-index: 1;
}
/* sub-navigation panel */
.sub-nav {
position: absolute;
display: none;
top: 2.2em;
margin-top: -1px;
padding: 0.5em 1em;
border: 1px solid #dedede;
background-color: #fff;
}
/* sub-navigation panel open state */
.sub-nav.open {
display: block;
}
/* list of items within sub-navigation panel */
.sub-nav ul {
display: inline-block;
vertical-align: top;
margin: 0 1em 0 0;
padding: 0;
}
/* list item within sub-navigation panel */
.sub-nav li {
display: block;
list-style-type: none;
margin: 0;
padding: 0;
}</pre>
<h3>Completed Example</h3>
<p>Putting it all together, here is the completed example:</p>
<style>
/* Rudimentary mega menu CSS for demonstration */
/* mega menu list */
.nav-menu {
display: block;
position: relative;
list-style: none;
margin: 0;
padding: 0;
z-index: 15;
}
/* a top level navigation item in the mega menu */
.nav-item {
list-style: none;
display: inline-block;
padding: 0;
margin: 0;
}
/* first descendant link within a top level navigation item */
.nav-item > a {
position: relative;
display: inline-block;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
border: 1px solid transparent;
}
/* focus/open states of first descendant link within a top level
navigation item */
.nav-item > a:focus,
.nav-item > a.nav-menu-open {
border: 1px solid #dedede;
}
/* open state of first descendant link within a top level
navigation item */
.nav-item > a.nav-menu-open {
background-color: #fff;
border-bottom: none;
z-index: 1;
}
/* sub-navigation panel */
.sub-nav {
position: absolute;
display: none;
top: 2.6em;
margin-top: -1px;
padding: 0.5em 1em;
border: 1px solid #dedede;
background-color: #fff;
}
/* sub-navigation panel open state */
.sub-nav.nav-menu-open {
display: block;
}
/* list of items within sub-navigation panel */
.sub-nav ul {
display: inline-block;
vertical-align: top;
margin: 0 1em 0 0;
padding: 0;
}
/* list item within sub-navigation panel */
.sub-nav li {
display: block;
list-style-type: none;
margin: 0;
padding: 0;
}
</style>
<nav id="test-nav-menu">
<ul class="nav-menu">
<li class="nav-item">
<a href="?movie">Movies</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?movie&genre=0">Action & Adventure</a></li>
<li><a href="?movie&genre=2">Children & Family</a></li>
<li>…</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=7">Dramas</a></li>
<li><a href="?movie&genre=9">Foreign</a></li>
<li>…</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=14">Musicals</a></li>
<li><a href="?movie&genre=15">Romance</a></li>
<li>…</li>
</ul>
</div>
</li>
<li class="nav-item">
<a href="?tv">TV Shows</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?tv&genre=20">Classic TV</a></li>
<li><a href="?tv&genre=21">Crime TV</a></li>
<li>…</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=27">Reality TV</a></li>
<li><a href="?tv&genre=30">TV Action</a></li>
<li>…</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=33">TV Dramas</a></li>
<li><a href="?tv&genre=34">TV Horror</a></li>
<li>…</li>
</ul>
</div>
</li>
</ul>
</nav>
<!-- initialize a selector as an accessibleMegaMenu -->
<script>
$("nav#test-nav-menu").accessibleMegaMenu({
/* prefix for generated unique id attributes, which are required
to indicate aria-owns, aria-controls and aria-labelledby */
uuidPrefix: "accessible-megamenu",
/* css class used to define the megamenu styling */
menuClass: "nav-menu",
/* css class for a top-level navigation item in the megamenu */
topNavItemClass: "nav-item",
/* css class for a megamenu panel */
panelClass: "sub-nav",
/* css class for a group of items within a megamenu panel */
panelGroupClass: "sub-nav-group",
/* css class for the hover state */
hoverClass: "nav-menu-hover",
/* css class for the focus state */
focusClass: "nav-menu-focus",
/* css class for the open state */
openClass: "nav-menu-open"
});
</script>
<pre class="prettyprint">
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Accessible Mega Menu Example</title>
<style>
/* Rudimentary mega menu CSS for demonstration */
/* mega menu list */
.nav-menu {
display: block;
position: relative;
list-style: none;
margin: 0;
padding: 0;
z-index: 15;
}
/* a top level navigation item in the mega menu */
.nav-item {
list-style: none;
display: inline-block;
padding: 0;
margin: 0;
}
/* first descendant link within a top level navigation item */
.nav-item > a {
position: relative;
display: inline-block;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
border: 1px solid transparent;
}
/* focus/open states of first descendant link within a top level
navigation item */
.nav-item > a:focus,
.nav-item > a.open {
border: 1px solid #dedede;
}
/* open state of first descendant link within a top level
navigation item */
.nav-item > a.open {
background-color: #fff;
border-bottom: none;
z-index: 1;
}
/* sub-navigation panel */
.sub-nav {
position: absolute;
display: none;
top: 2.6em;
margin-top: -1px;
padding: 0.5em 1em;
border: 1px solid #dedede;
background-color: #fff;
}
/* sub-navigation panel open state */
.sub-nav.open {
display: block;
}
/* list of items within sub-navigation panel */
.sub-nav ul {
display: inline-block;
vertical-align: top;
margin: 0 1em 0 0;
padding: 0;
}
/* list item within sub-navigation panel */
.sub-nav li {
display: block;
list-style-type: none;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<nav>
<ul class="nav-menu">
<li class="nav-item">
<a href="?movie">Movies</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?movie&genre=0">Action &amp; Adventure</a></li>
<li><a href="?movie&genre=2">Children &amp; Family</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=7">Dramas</a></li>
<li><a href="?movie&genre=9">Foreign</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?movie&genre=14">Musicals</a></li>
<li><a href="?movie&genre=15">Romance</a></li>
<li>&#8230;</li>
</ul>
</div>
</li>
<li class="nav-item">
<a href="?tv">TV Shows</a>
<div class="sub-nav">
<ul class="sub-nav-group">
<li><a href="?tv&genre=20">Classic TV</a></li>
<li><a href="?tv&genre=21">Crime TV</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=27">Reality TV</a></li>
<li><a href="?tv&genre=30">TV Action</a></li>
<li>&#8230;</li>
</ul>
<ul class="sub-nav-group">
<li><a href="?tv&genre=33">TV Dramas</a></li>
<li><a href="?tv&genre=34">TV Horror</a></li>
<li>&#8230;</li>
</ul>
</div>
</li>
</ul>
</nav>
<!-- include jquery -->
<script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<!-- include the jquery-accessibleMegaMenu plugin script -->
<script src="js/jquery-accessibleMegaMenu.js"></script>
<!-- initialize a selector as an accessibleMegaMenu -->
<script>
$("nav:first").accessibleMegaMenu({
/* prefix for generated unique id attributes, which are required
to indicate aria-owns, aria-controls and aria-labelledby */
uuidPrefix: "accessible-megamenu",
/* css class used to define the megamenu styling */
menuClass: "nav-menu",
/* css class for a top-level navigation item in the megamenu */
topNavItemClass: "nav-item",
/* css class for a megamenu panel */
panelClass: "sub-nav",
/* css class for a group of items within a megamenu panel */
panelGroupClass: "sub-nav-group",
/* css class for the hover state */
hoverClass: "hover",
/* css class for the focus state */
focusClass: "focus",
/* css class for the open state */
openClass: "open"
});
</script>
</body>
</html>
</pre>
</main>
</div>
</body>
</html>