Custom JS to set "Start" tag + allow removal of "All" tag #1481
wazski
started this conversation in
Customisations
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Here is my custom CSS and javascript that will put a red border around the current tag and will remove the ALL tag and start on the tag of choice.
In the JavaScript on the second line, you would change the variable startMenu to the tag that you would like to start on. I start my menu on the 'Home Servers' tag, so I would change "const startMenu = 'change-me'" to "const startMenu = 'Home Servers'". If you don't change anything and run the script as is, you would start on the 'Home dashboard' tag, and the ALL tag will be gone.
Custom CSS ------------------------------
.taglist {
gap: 15px;
}
.taglist .tag {
border: black solid 1px;
outline-offset: 2px;
outline: 2px solid black;
}
.taglist .tag.current {
border: black solid 2px;
outline: 2px solid red;
}
Custom JavaScript ----------------------------------
$(document).ready(function () {
const startMenu = 'change-me';
let setTag = '';
if (startMenu === 'change-me') {
setTag = '0-dash';
} else {
setTag = startMenu.replace(/[^a-zA-Z0-9\s]/g, '').split(' ').join('-').toLowerCase();
}
const currentTag = document.querySelector("[data-tag=all]");
const startTag = document.querySelector("[data-tag=tag-" + setTag + "]");
currentTag.classList.remove('current');
startTag.classList.add('current');
startTag.click();
const menuItems = document.querySelectorAll("section");
for (items of menuItems) {
if (!items.classList.contains('tag-' + setTag)) {
items.setAttribute("style", "display: none;");
}
}
currentTag.remove();
});
Beta Was this translation helpful? Give feedback.
All reactions