|
| 1 | +{% capture logo_path %}{{ site.logo }}{% endcapture %} |
| 2 | + |
| 3 | +<div class="masthead"> |
| 4 | + <div class="masthead__inner-wrap"> |
| 5 | + <div class="masthead__menu"> |
| 6 | + <nav id="site-nav" class="nav__topbar" aria-label="Main Navigation"> |
| 7 | + <!-- More accessible as a screen reader will group the title and image in the same link --> |
| 8 | + {% unless logo_path == empty %} |
| 9 | + <a class="site-logo" href="{{ '/' | relative_url }}"> |
| 10 | + <img src="{{ logo_path | relative_url }}" alt="{{ site.masthead_title | default: site.title }}"> |
| 11 | + <span class="site-title">pyOpenSci</span> |
| 12 | + </a> |
| 13 | + {% endunless %} |
| 14 | + |
| 15 | + <ul class="nav__links"> |
| 16 | + {%- for alink in site.data.navigation.main -%} |
| 17 | + {% if alink.sub-nav %} |
| 18 | + <!-- If there is sub nav to display --> |
| 19 | + <li class="dropdown"> |
| 20 | + <button class="dropbtn">{{ alink.title }} <i class="fas fa-caret-down"></i> |
| 21 | + </button> |
| 22 | + <ul class="dropdown-content"> |
| 23 | + {% for subnav in alink.sub-nav %} |
| 24 | + <li> |
| 25 | + <a href="{{ subnav.url }}" class="masthead__menu-item hover-underline">{{ subnav.title }}</a> |
| 26 | + </li> |
| 27 | + {% endfor %} |
| 28 | + </ul> |
| 29 | + </li> |
| 30 | + {% else %} |
| 31 | + <li> |
| 32 | + <a href="{{ alink.url | relative_url }}" class="hover-underline">{{ alink.title }}</a> |
| 33 | + </li> |
| 34 | + {% endif %} |
| 35 | + {% endfor %} |
| 36 | + </ul> |
| 37 | + <!-- Burger button - span class for screen readers--> |
| 38 | + <button class="hamburger__btn-toggle" type="button" count="1"> |
| 39 | + <span class="visually-hidden">Toggle menu</span> <!--screen readers--> |
| 40 | + <div class="burger__icon"></div> |
| 41 | + </button> |
| 42 | + </nav> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | +</div> |
| 47 | + {% if site.search == true %} |
| 48 | + <button class="search__toggle" type="button"> |
| 49 | + <span class="visually-hidden">{{ site.data.ui-text[site.locale].search_label | default: "Toggle search" }}</span> |
| 50 | + <i class="fas fa-search"></i> |
| 51 | + </button> |
| 52 | + {% endif %} |
| 53 | + <ul class="hidden-links hidden"></ul> |
| 54 | + </nav> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | +</div> |
| 58 | + |
| 59 | +<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script> |
| 60 | +<script> |
| 61 | + $(document).ready(function () { |
| 62 | + $(".hamburger__btn-toggle").click(function (e) { |
| 63 | + $(this).toggleClass("close"); |
| 64 | + e.preventDefault(); |
| 65 | + $(".nav__links").toggleClass("vertical"); |
| 66 | + }); |
| 67 | + |
| 68 | + $(".dropdown").click(function (e) { |
| 69 | + e.stopPropagation(); |
| 70 | + e.preventDefault(); |
| 71 | + // close when click outside |
| 72 | + $(this).find(".dropdown-content").toggleClass("open"); |
| 73 | + $(this).siblings(".dropdown").find(".dropdown-content").removeClass("open"); |
| 74 | + }); |
| 75 | + |
| 76 | + // Close dropdown when u click outside of the nav ul |
| 77 | + $(document).click(function (e) { |
| 78 | + if (!e.target.closest("ul") && $(".dropdown-content").hasClass("open")) { |
| 79 | + $(".dropdown-content").removeClass("open"); |
| 80 | + } |
| 81 | + }); |
| 82 | +}); |
| 83 | + |
| 84 | +</script> |
0 commit comments