|
3 | 3 | <div class="masthead">
|
4 | 4 | <div class="masthead__inner-wrap">
|
5 | 5 | <div class="masthead__menu">
|
6 |
| - <nav id="site-nav" class="nav__topbar" aria-label="Main Navigation"> |
| 6 | + <nav id="site-nav" class="nav__topbar" aria-label="Top Bar"> |
7 | 7 | <!-- More accessible as a screen reader will group the title and image in the same link -->
|
8 | 8 | {% unless logo_path == empty %}
|
9 | 9 | <a class="site-logo" href="{{ '/' | relative_url }}">
|
10 |
| - <img src="{{ logo_path | relative_url }}" alt="{{ site.masthead_title | default: site.title }}"> |
| 10 | + <img src="{{ logo_path | relative_url }}" alt="Welcome to the pyOpenSci website. This is the pyOpenSci logo."> |
11 | 11 | <span class="site-title">pyOpenSci</span>
|
12 | 12 | </a>
|
13 | 13 | {% endunless %}
|
|
17 | 17 | {% if alink.sub-nav %}
|
18 | 18 | <!-- If there is sub nav to display -->
|
19 | 19 | <li class="dropdown">
|
20 |
| - <button class="dropbtn" tabindex="0">{{ alink.title }} <i class="fas fa-caret-down"></i> |
| 20 | + <button class="dropbtn" tabindex="0" aria-expanded="false">{{ alink.title }} <i class="fas fa-caret-down"></i> |
21 | 21 | </button>
|
22 | 22 | <ul class="dropdown-content">
|
23 | 23 | {% for subnav in alink.sub-nav %}
|
|
37 | 37 |
|
38 | 38 | </li>
|
39 | 39 | </ul>
|
| 40 | + <!-- |
40 | 41 | {% if site.search == true %}
|
41 | 42 | <button class="search__toggle" type="button">
|
42 | 43 | <span class="visually-hidden">{{ site.data.ui-text[site.locale].search_label | default: "Toggle search" }}</span>
|
43 | 44 | <i class="fas fa-search"></i>
|
44 | 45 | </button>
|
45 | 46 | {% endif %}
|
| 47 | + --> |
46 | 48 |
|
47 | 49 |
|
48 | 50 | <ul class="hidden-links hidden"></ul>
|
49 | 51 | <!-- Burger button - span class for screen readers-->
|
50 |
| - <button class="hamburger__btn-toggle" type="button" count="1"> |
51 |
| - <span class="visually-hidden">Toggle menu</span> <!--screen readers--> |
| 52 | + <button class="hamburger__btn-toggle" type="button" count="1" aria-expanded="false"> |
| 53 | + <span class="visually-hidden">Toggle top navigation menu</span> <!--screen readers--> |
52 | 54 | <div class="burger__icon"></div>
|
53 | 55 | </button>
|
54 | 56 | </nav>
|
|
58 | 60 |
|
59 | 61 |
|
60 | 62 | <script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
|
| 63 | + |
| 64 | +<!-- This works now but when you open the menu its not saying aria expanded or |
| 65 | +prompting the screen reader--> |
61 | 66 | <script>
|
62 | 67 | $(document).ready(function () {
|
63 | 68 | $(".hamburger__btn-toggle").click(function (e) {
|
64 | 69 | $(this).toggleClass("close");
|
| 70 | + // toggle expanded to try on click |
| 71 | + $(this).attr('aria-expanded', function (i, attr) { |
| 72 | + return attr == 'true' ? 'false' : 'true'}); |
| 73 | + |
65 | 74 | e.preventDefault();
|
66 | 75 | $(".nav__links").toggleClass("vertical");
|
67 | 76 | });
|
68 | 77 |
|
69 | 78 | $(".dropdown").click(function (e) {
|
70 |
| - //e.stopPropagation(); |
71 |
| - //e.preventDefault(); |
72 |
| - // close when click outside |
| 79 | + // close when user clicks nav |
73 | 80 | $(this).find(".dropdown-content").toggleClass("open");
|
| 81 | + // Handle making sure other drop menus are "closed" when another is open |
74 | 82 | $(this).siblings(".dropdown").find(".dropdown-content").removeClass("open");
|
| 83 | + $(this).siblings(".dropdown").find(".dropbtn").attr("aria-expanded", "false"); |
| 84 | + |
| 85 | + // this works but if user clicks on another drop down it should also return to closed |
| 86 | + // with this code it just toggles the next thing that the user clicks so both |
| 87 | + // dropdowns are set to expanded:true |
| 88 | + $(this).find(".dropbtn").attr('aria-expanded', function (i, attr) { |
| 89 | + return attr == 'true' ? 'false' : 'true' }); |
75 | 90 | });
|
76 | 91 |
|
77 | 92 | // Close dropdown when u click outside of the nav ul
|
78 | 93 | $(document).click(function (e) {
|
79 | 94 | if (!e.target.closest("ul") && $(".dropdown-content").hasClass("open")) {
|
80 | 95 | $(".dropdown-content").removeClass("open");
|
81 | 96 | }
|
| 97 | + |
| 98 | + |
82 | 99 | });
|
83 | 100 | });
|
84 | 101 |
|
|
0 commit comments