Skip to content

Commit

Permalink
fix buttonlist dropdown and remove bloat
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Andrés <[email protected]>
  • Loading branch information
DiegoAndresCortes authored and live627 committed Sep 12, 2024
1 parent 4db5b0b commit 80b8eed
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Themes/default/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1662,27 +1662,24 @@ function smc_resize(selector) {
}

document.addEventListener('DOMContentLoaded', () => {
const dropMenus = document.querySelectorAll('.buttonlist > .dropmenu');
const dropMenus = document.querySelectorAll('.buttonlist li > .top_menu');
for (const item of dropMenus) {
const prevElement = item.previousElementSibling;

prevElement.addEventListener('click', e => {
e.stopPropagation();
e.preventDefault();

if (window.getComputedStyle(item).display === 'block') {
item.style.display = 'none';
if (item.classList.contains('visible')) {
item.classList.remove('visible')
return true;
}

item.style.display = 'block';
item.style.top = (prevElement.offsetTop + prevElement.offsetHeight) + 'px';
item.style.left = Math.max(prevElement.offsetLeft - item.offsetWidth + prevElement.offsetWidth, 0) + 'px';
item.style.height = item.querySelector('div:first-child').offsetHeight + 'px';
item.classList.add('visible');
});

document.addEventListener('click', () => {
item.style.display = 'none';
item.classList.remove('visible');
});
}

Expand Down

0 comments on commit 80b8eed

Please sign in to comment.