From 9ccf652c00457e46eaf46fc4cb8f6d0ee582c5ef Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 1 Oct 2021 14:32:43 +0200 Subject: Initial commit --- .../hugo-whisper-theme/assets/js/libs/library.js | 1 + .../hugo-whisper-theme/assets/js/pages/services.js | 1 + themes/hugo-whisper-theme/assets/js/scripts.js | 35 ++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 themes/hugo-whisper-theme/assets/js/libs/library.js create mode 100644 themes/hugo-whisper-theme/assets/js/pages/services.js create mode 100644 themes/hugo-whisper-theme/assets/js/scripts.js (limited to 'themes/hugo-whisper-theme/assets/js') diff --git a/themes/hugo-whisper-theme/assets/js/libs/library.js b/themes/hugo-whisper-theme/assets/js/libs/library.js new file mode 100644 index 0000000..3e79cea --- /dev/null +++ b/themes/hugo-whisper-theme/assets/js/libs/library.js @@ -0,0 +1 @@ +console.log('Library') diff --git a/themes/hugo-whisper-theme/assets/js/pages/services.js b/themes/hugo-whisper-theme/assets/js/pages/services.js new file mode 100644 index 0000000..ee2e7d6 --- /dev/null +++ b/themes/hugo-whisper-theme/assets/js/pages/services.js @@ -0,0 +1 @@ +console.log('Services') diff --git a/themes/hugo-whisper-theme/assets/js/scripts.js b/themes/hugo-whisper-theme/assets/js/scripts.js new file mode 100644 index 0000000..0c697d0 --- /dev/null +++ b/themes/hugo-whisper-theme/assets/js/scripts.js @@ -0,0 +1,35 @@ +var body = document.querySelector('body') +var menuTrigger = document.querySelector('#toggle-main-menu-mobile'); +var menuContainer = document.querySelector('#main-menu-mobile'); + +menuTrigger.onclick = function() { + menuContainer.classList.toggle('open'); + menuTrigger.classList.toggle('is-active') + body.classList.toggle('lock-scroll') +} + +var content = document.querySelector('.content.anchor-link-enabled') +if (content) { + addHeaderAnchors(content); +} + +function addHeaderAnchors(content) { + var headers = content.querySelectorAll('h1, h2, h3, h4'); + // SVG data from https://iconmonstr.com/link-1-svg/ + var linkSvg = ' '; + var anchorForId = function (id) { + var anchor = document.createElement('a'); + anchor.classList.add('header-anchor'); + anchor.href = "#" + id; + anchor.innerHTML = linkSvg; + return anchor; + }; + + for (var h = 0; h < headers.length; h++) { + var header = headers[h]; + + if (typeof header.id !== "undefined" && header.id !== "") { + header.appendChild(anchorForId(header.id)); + } + } +} -- cgit v1.2.3