From d36434f9cbfd78abc198e8a1e4827aa383d62fa2 Mon Sep 17 00:00:00 2001 From: luca Date: Mon, 4 Nov 2019 22:32:46 +0100 Subject: [PATCH] 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. --- sitestatic/base.js | 16 ++++++++++++++++ templates/base.html | 1 + 2 files changed, 17 insertions(+) create mode 100644 sitestatic/base.js diff --git a/sitestatic/base.js b/sitestatic/base.js new file mode 100644 index 000000000..2d68bb26a --- /dev/null +++ b/sitestatic/base.js @@ -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); diff --git a/templates/base.html b/templates/base.html index c9851afc2..5e3549c73 100644 --- a/templates/base.html +++ b/templates/base.html @@ -6,6 +6,7 @@ {% block title %}Arch Linux{% endblock %} +