Skip to content

Commit

Permalink
Add hamburger button JavaScript
Browse files Browse the repository at this point in the history
A new JavaScript file base.js is introduced and included in the base
template so the hamburger button will work on every page.
  • Loading branch information
Phosphenius committed Nov 4, 2019
1 parent 376ba50 commit d36434f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sitestatic/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

document.addEventListener('DOMContentLoaded', function () {
var hamburger = document.getElementById('hamburger');
var hamburgerState = false;

hamburger.onclick = function () {
hamburgerState = !hamburgerState;

if (hamburgerState) {
hamburger.classList.add('open');
} else {
hamburger.classList.remove('open');
}
};
}, false);
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Arch Linux{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% static "archweb.css" %}" media="screen" />
<script src="{% static "base.js" %}"></script>
<link rel="icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
<link rel="shortcut icon" type="image/x-icon" href="{% static "favicon.ico" %}" />
<link rel="apple-touch-icon" href="{% static "logos/apple-touch-icon-57x57.png" %}" />
Expand Down

0 comments on commit d36434f

Please sign in to comment.