Skip to content

Commit d36434f

Browse files
committed
Add hamburger button JavaScript
A new JavaScript file base.js is introduced and included in the base template so the hamburger button will work on every page.
1 parent 376ba50 commit d36434f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

sitestatic/base.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
3+
document.addEventListener('DOMContentLoaded', function () {
4+
var hamburger = document.getElementById('hamburger');
5+
var hamburgerState = false;
6+
7+
hamburger.onclick = function () {
8+
hamburgerState = !hamburgerState;
9+
10+
if (hamburgerState) {
11+
hamburger.classList.add('open');
12+
} else {
13+
hamburger.classList.remove('open');
14+
}
15+
};
16+
}, false);

templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<title>{% block title %}Arch Linux{% endblock %}</title>
88
<link rel="stylesheet" type="text/css" href="{% static "archweb.css" %}" media="screen" />
9+
<script src="{% static "base.js" %}"></script>
910
<link rel="icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
1011
<link rel="shortcut icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
1112
<link rel="apple-touch-icon" href="{% static "logos/apple-touch-icon-57x57.png" %}" />

0 commit comments

Comments
 (0)