allow users to return to article list and select blog button when visiting directly from a link

This commit is contained in:
hippoz 2020-10-25 18:34:19 +02:00
parent cb452398f9
commit f2b1b230ff

View file

@ -1,6 +1,7 @@
let selectedButtonId = 'button-home';
const loadedScripts = [];
let selectedButtonId = 'button-home';
const changeSelected = (buttonId) => {
A(`#${selectedButtonId}`).removeClass('button-selected');
A(`#${buttonId}`).addClass('button-selected');
@ -77,12 +78,15 @@ const dynamicRoutesActions = {
peformRouteAction('/404');
return;
}
changeSelected(getButtonFromPathname('/blog'));
blogVisitArticle(arg, desc);
}
};
const onButtonClick = (buttonId) => {
if (selectedButtonId === buttonId) {
// The condition after && is kinda of a hack, the reason I do this is because I want users to be able to click the blog button and return to the article list to continue reading when they are already on an article.
if (selectedButtonId === buttonId && buttonId !== 'button-blog') {
return;
}
changeSelected(buttonId);