hugo.soucy.cc

The personnal website source code of Hugo Soucy. Creates from an homebrewed static website generator (Ferron).
Log | Files | Refs

commit ecce12438c3eb53b97aa9e80844f9e7076e86b0f
parent c38c1d7ce420d418851f9469afc10baac81773e5
Author: Hugo Soucy <hugo.soucy@toumoro.com>
Date:   Fri, 27 Mar 2020 15:11:44 -0400

Removes unused JS

Diffstat:
Mstatic/src/js/custom/init.js | 98+------------------------------------------------------------------------------
Mtemplates/partials/bottom_script.mustache | 9+++++----
2 files changed, 6 insertions(+), 101 deletions(-)

diff --git a/static/src/js/custom/init.js b/static/src/js/custom/init.js @@ -1,97 +1 @@ -function setNavigation() { - 'use strict'; - var $nav = document.querySelector('.nav'); - var visible = 'state--visible'; - var hidden = 'state--hidden'; - - var $nav_panel; - var $nav_button; - var $nav_close; - - if (du.isElement($nav)) { - $nav_panel = $nav.querySelector('.nav__panel'); - - document.body.insertAdjacentHTML( - 'afterbegin', document.querySelector('#navButtonTpl').innerHTML - ); - - $nav_panel.insertAdjacentHTML( - 'afterbegin', document.querySelector('#navCloseTpl').innerHTML - ); - - $nav_panel.insertAdjacentHTML( - 'afterbegin', document.querySelector('#navTrapTpl').innerHTML - ); - - $nav_panel.insertAdjacentHTML( - 'beforeend', document.querySelector('#navTrapTpl').innerHTML - ); - - $nav_button = document.querySelector('.nav-button'); - $nav_close = $nav_panel.querySelector('.nav__close'); - - du.setClass($nav_panel, hidden); - - du.setEvent($nav_button, 'click', function(thatEvt) { - thatEvt.preventDefault(); - - du.toggleClass($nav_panel, hidden); - du.toggleClass($nav_panel, visible); - - $nav_close.focus(); - }); - - du.setEvent($nav_close, 'click', function(thatEvt) { - thatEvt.preventDefault(); - - du.toggleClass($nav_panel, hidden); - du.toggleClass($nav_panel, visible); - - $nav_button.focus(); - }); - - du.setEventList( - $nav_panel.querySelectorAll('.nav__trap'), 'focus', function() { - $nav_close.focus(); - } - ); - - du.setEvent( - $nav_panel, 'focus', function() { - $nav_button.focus(); - } - ); - - // Close the panel whith the Escape key - du.setEvent(document, 'keydown', function(thatEvt) { - if (thatEvt.keyCode == '27') { - thatEvt.preventDefault(); - - du.triggerEvent($nav_close, 'click'); - } - }); - } -} - -// function setCurrentPage() { -// 'use strict'; -// var navLinks = document.querySelectorAll('.nav__link'); -// var lengthOf; -// var pathname; - -// if (navLinks.item(0)) { -// pathname = window.location.pathname; -// lengthOf = navLinks.length; - -// while(lengthOf--) { -// var navLinkHref = navLinks[lengthOf].getAttribute('href'); - -// if (navLinkHref.indexOf(pathname.split('/')[1]) > 0) { -// navLinks[lengthOf].removeAttribute('href'); -// } -// } -// } -// } - -// setNavigation(); -//setCurrentPage(); +// diff --git a/templates/partials/bottom_script.mustache b/templates/partials/bottom_script.mustache @@ -3,12 +3,13 @@ var bottomjs; if (cuttingTheMustard) { - bottomjs = document.createElement('script'); + /* bottomjs = document.createElement('script'); */ /* bottomjs.src = '{{{ site.baseurl }}}/js/script.min.js'; */ - bottomjs.src = '{{{ site.baseurl }}}/js/index.js'; - bottomjs.id = 'bottomjs'; + /* bottomjs.src = '{{{ site.baseurl }}}/js/index.js'; */ + /* bottomjs.id = 'bottomjs'; */ + + /* document.body.appendChild(bottomjs); */ - document.body.appendChild(bottomjs); document.querySelector('html').classList.remove('no-js'); document.querySelector('html').classList.add('js'); }