frontend: add collapsable sidebar
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f8dacef309
commit
48b9e595ff
3 changed files with 218 additions and 2 deletions
|
|
@ -13,4 +13,34 @@ const app = createApp(App).use(BootstrapIconsPlugin);
|
|||
_nacl.instantiate((nacl) => {
|
||||
window.nacl = nacl
|
||||
app.use(router).mount('#app')
|
||||
});
|
||||
});
|
||||
|
||||
window.closeAllDropdowns = function () {
|
||||
const dropdowns = document.getElementsByClassName("dropdown-menu");
|
||||
let i;
|
||||
for (i = 0; i < dropdowns.length; i++) {
|
||||
const openDropdown = dropdowns[i];
|
||||
if (openDropdown.classList.contains('show')) {
|
||||
openDropdown.classList.remove('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.onclick = function (event) {
|
||||
if (!event.target.matches('.dropdown-toggle *')
|
||||
&& !event.target.matches('.dropdown-toggle')
|
||||
&& !event.target.matches('.dropdown-menu *')
|
||||
&& !event.target.matches('.dropdown-menu')) {
|
||||
closeAllDropdowns();
|
||||
}
|
||||
if (!event.target.matches('.sidebar-toggle *')
|
||||
&& !event.target.matches('.sidebar-toggle')
|
||||
&& !event.target.matches('.sidebar *')
|
||||
&& !event.target.matches('.sidebar')) {
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
const marginLeft = parseInt(getComputedStyle(sidebar).marginLeft);
|
||||
if (sidebar.classList.contains('collapsed') && marginLeft === 0) {
|
||||
sidebar.classList.remove('collapsed');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue