diff options
Merge branch 'master' into 'blog/black-hole-shader'
# Conflicts:
# src/blog/index.md
4 files changed, 13 insertions, 32 deletions
| -rw-r--r-- | src/scripts/expand-navbar.js | 8 | ||||
| -rw-r--r-- | src/scripts/image-show.js | 24 | ||||
| -rw-r--r-- | src/scripts/keyboard.js | 9 | ||||
| -rw-r--r-- | src/scripts/page-width.js | 4 |
diff --git a/src/scripts/expand-navbar.js b/src/scripts/expand-navbar.js index 4cea31c..988d211 100644 --- a/src/scripts/expand-navbar.js +++ b/src/scripts/expand-navbar.js @@ -1,15 +1,15 @@ const expandBtn = document.getElementById('expandNavbarBtn'); -const sidebarElem = document.getElementById('sidebar'); +const wrapperElem = document.getElementById('content-wrapper'); if (localStorage.getItem('navbar') === 'hidden' || window.innerWidth <= 610 || window.innerHeight <= 610) { expandBtn.innerText = '\u25BC'; - sidebarElem.classList.add('sidebar-hidden'); + wrapperElem.classList.add('content-wrapper-vertical'); } expandBtn.onclick = function() { - sidebarElem.classList.toggle('sidebar-hidden'); + wrapperElem.classList.toggle('content-wrapper-vertical'); - if (!sidebarElem.classList.contains('sidebar-hidden')) { + if (!wrapperElem.classList.contains('content-wrapper-vertical')) { expandBtn.innerText = '\u25B2'; // triangle pointing up if (window.innerWidth > 610) localStorage.setItem('navbar', 'norm'); } diff --git a/src/scripts/image-show.js b/src/scripts/image-show.js deleted file mode 100644 index 8664ef4..0000000 --- a/src/scripts/image-show.js +++ /dev/null @@ -1,24 +0,0 @@ -let scrollPosition = 0; - -function clickToView() { - if (scrollPosition === 0) { - scrollPosition = window.scrollY; - window.scrollTo(0, 0); - } - - this.classList.toggle('clicked-image'); - document.body.classList.toggle('body-on-clicked-image'); - - if (!this.classList.contains('clicked-image')) { - window.scrollTo(0, scrollPosition); - scrollPosition = 0; - } -} - -const images = document.getElementsByTagName('img'); - -for (const image of images) { - if (image.alt !== '🔗' && !image.classList.contains('unzoomable')) { - image.onclick = clickToView; - } -} diff --git a/src/scripts/keyboard.js b/src/scripts/keyboard.js index bacbea1..1de93cf 100644 --- a/src/scripts/keyboard.js +++ b/src/scripts/keyboard.js @@ -2,11 +2,16 @@ document.addEventListener('keydown', function (e) { if (e.ctrlKey) return; switch (e.code) { - /* theme-changer.js */ - case 'KeyC': + case 'KeyC': // theme-changer.js themeBtn.click(); break; + case 'KeyW': // page-width.js + widthBtn.click(); + break; + case 'KeyE': // expand-navbar.js + expandBtn.click(); + break; /* presentation.js */ diff --git a/src/scripts/page-width.js b/src/scripts/page-width.js index 784c0f2..353dc4d 100644 --- a/src/scripts/page-width.js +++ b/src/scripts/page-width.js @@ -4,11 +4,11 @@ const articleElem = document.getElementsByTagName('article')[0]; if (localStorage.getItem('width') === 'wide') { widthLabel.innerText = 'Narrow'; - articleElem.classList.add('noMaxWidth'); + articleElem.classList.add('article-wide'); } widthBtn.onclick = function() { - articleElem.classList.toggle('noMaxWidth'); + articleElem.classList.toggle('article-wide'); if (localStorage.getItem('width') !== 'norm') { widthLabel.innerText = 'Wide'; |