Skip to content

Commit 5fa4c74

Browse files
committed
Move js to page bottom
1 parent 64273cc commit 5fa4c74

File tree

3 files changed

+60
-45
lines changed

3 files changed

+60
-45
lines changed

_includes/footer.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="page__footer-follow">
2+
<ul class="social-icons">
3+
{% if site.data.ui-text[site.locale].follow_label %}
4+
<li><strong>{{ site.data.ui-text[site.locale].follow_label }}</strong></li>
5+
{% endif %}
6+
7+
{% if site.footer.links %}
8+
{% for link in site.footer.links %}
9+
{% if link.label and link.url %}
10+
<li><a href="{{ link.url }}" rel="nofollow noopener noreferrer"><i class="{{ link.icon | default: 'fas fa-link' }}" aria-hidden="true"></i> {{ link.label }}</a></li>
11+
{% endif %}
12+
{% endfor %}
13+
{% endif %}
14+
15+
{% unless site.atom_feed.hide %}
16+
<li><a href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | relative_url }}{% endif %}"><i class="fas fa-fw fa-rss-square" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].feed_label | default: "Feed" }}</a></li>
17+
{% endunless %}
18+
</ul>
19+
</div>
20+
pyOpenSci is a fiscally sponsored project of Community Initiatives
21+
22+
<div class="page__footer-copyright">&copy; {{ site.time | date: '%Y' }} {{ site.name | default: site.title }}</div>
23+
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
24+
<script src="/assets/js/dropdown.js"></script>

_includes/masthead.html

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
{% endif %}
4747
-->
4848

49-
5049
<ul class="hidden-links hidden"></ul>
5150
<!-- Burger button - span class for screen readers-->
5251
<button class="hamburger__btn-toggle" type="button" count="1" aria-expanded="false">
@@ -56,47 +55,4 @@
5655
</nav>
5756
</div>
5857
</div>
59-
</div>
60-
61-
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-->
66-
<script>
67-
$(document).ready(function () {
68-
$(".hamburger__btn-toggle").click(function (e) {
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-
74-
e.preventDefault();
75-
$(".nav__links").toggleClass("vertical");
76-
});
77-
78-
$(".dropdown").click(function (e) {
79-
// close when user clicks nav
80-
$(this).find(".dropdown-content").toggleClass("open");
81-
// Handle making sure other drop menus are "closed" when another is open
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' });
90-
});
91-
92-
// Close dropdown when u click outside of the nav ul
93-
$(document).click(function (e) {
94-
if (!e.target.closest("ul") && $(".dropdown-content").hasClass("open")) {
95-
$(".dropdown-content").removeClass("open");
96-
}
97-
98-
99-
});
100-
});
101-
102-
</script>
58+
</div>

assets/js/dropdown.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//Jquery to manage drop downs and accessibility
2+
$(document).ready(function () {
3+
$(".hamburger__btn-toggle").click(function (e) {
4+
$(this).toggleClass("close");
5+
// toggle expanded to try on click
6+
$(this).attr('aria-expanded', function (i, attr) {
7+
return attr == 'true' ? 'false' : 'true'});
8+
9+
e.preventDefault();
10+
$(".nav__links").toggleClass("vertical");
11+
});
12+
13+
$(".dropdown").click(function (e) {
14+
// close when user clicks nav
15+
$(this).find(".dropdown-content").toggleClass("open");
16+
// Handle making sure other drop menus are "closed" when another is open
17+
$(this).siblings(".dropdown").find(".dropdown-content").removeClass("open");
18+
$(this).siblings(".dropdown").find(".dropbtn").attr("aria-expanded", "false");
19+
20+
// this works but if user clicks on another drop down it should also return to closed
21+
// with this code it just toggles the next thing that the user clicks so both
22+
// dropdowns are set to expanded:true
23+
$(this).find(".dropbtn").attr('aria-expanded', function (i, attr) {
24+
return attr == 'true' ? 'false' : 'true' });
25+
});
26+
27+
// Close dropdown when u click outside of the nav ul
28+
$(document).click(function (e) {
29+
if (!e.target.closest("ul") && $(".dropdown-content").hasClass("open")) {
30+
$(".dropdown-content").removeClass("open");
31+
}
32+
33+
34+
});
35+
});

0 commit comments

Comments
 (0)