Skip to content

Commit

Permalink
chages after review
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Mar 13, 2024
1 parent 0824f55 commit d6ed7ae
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ const element = document.getElementById('nav');
const pinButton = document.getElementById('pin-btn');

if (pinButton != null) {
pinButton.onclick = handleNavExpanded;
pinButton.addEventListener('click', () => {
handleNavToggle();
});
}

if (sessionStorage.getItem('navigation-pinned')) {
handleNavExpanded();
handleNavToggle();
}

function handleNavExpanded() {
if (element?.classList.contains('nav-block--pinned')) {
function handleNavToggle() {
if (element == null || pinButton == null) {
return null;
}

if (element.classList.contains('nav-block--pinned')) {
sessionStorage.removeItem('navigation-pinned');
element.classList.remove('nav-block--pinned');
pinButton?.setAttribute('title', gettext('Expand'));
pinButton.setAttribute('title', gettext('Expand'));
} else {
sessionStorage.setItem('navigation-pinned', 'true');
element?.classList.add('nav-block--pinned');
pinButton?.setAttribute('title', gettext('Collapse'));
element.classList.add('nav-block--pinned');
pinButton.setAttribute('title', gettext('Collapse'));
}
}

0 comments on commit d6ed7ae

Please sign in to comment.