Skip to content

Commit

Permalink
Code cleanup; removed roundabout JS implementation of settings menu's…
Browse files Browse the repository at this point in the history
… open and close buttons.
  • Loading branch information
00Fjongl committed Jul 18, 2024
1 parent 0d1d3c9 commit deb8338
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
3 changes: 1 addition & 2 deletions views/assets/css/styles-1644738239.css
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ details[open] summary {
z-index: 5; /* Ensures it appears above other content */
align-items: center;
justify-content: center;
display: none; /* Flexbox to center content */
}

.settings-content {
Expand All @@ -437,7 +436,7 @@ details[open] summary {
text-align: center;
}

.dropdown-parent:focus-within .dropdown-settings {
.dropdown-parent:focus-within .dropdown-settings:not(:is(:has(.close-settings-btn:active))) {
display: flex; /* Flexbox to center content */
}

Expand Down
2 changes: 1 addition & 1 deletion views/assets/js/common-16451543478.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ addEventListener("DOMContentLoaded", () => {

// Which function is used for the click event is determined by
// the corresponding location/index in the dirnames object.
let functionsList = [
const functionsList = [
() => goFrame(item.path),
() => goFrame("/?eg&core=" + item.core + "&rom=" + item.rom),
() => item.custom ? goProx[item.custom]("stealth") : goFrame("/archive/g/" + item.path)
Expand Down
3 changes: 3 additions & 0 deletions views/assets/js/csel.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ readCookie("HBHideAds").then(s => (s != "false") ? pageHideAds() : pageShowAds((
// All code below is used by the Settings UI in the navigation bar.
if (document.getElementById("csel")) {

let closeBtn = document.querySelector(".dropdown-settings .close-settings-btn");
closeBtn.addEventListener("click", () => {document.activeElement.blur()});

// Allow users to set a custom title with the UI.
let titleform = document.getElementById("titleform");
titleform.addEventListener("submit", e => {
Expand Down
30 changes: 2 additions & 28 deletions views/pages/misc/deobf/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,12 @@
</ul>
</div>
</li>
<li class="dropdown-parent open-settings-menu">
<li class="dropdown-parent">
<div class="pulse white-text">
<a href="#">Settings <i class="fas fa-cog pulse"></i></a>
</div>
<div class="dropdown-settings" tabindex="0">
<div id="csel"><!--SETTINGS--></div>
</div>
</li>
</ul>
<script>
function setupSettingsDropdown() {
const openSettingsBtn = document.querySelector('.open-settings-menu');
const settingsContent = document.querySelector('.dropdown-settings');

if (!openSettingsBtn || !settingsContent) {
console.error('Open settings button or settings content not found.');
return;
}

openSettingsBtn.addEventListener('click', () => {
settingsContent.style.display = 'flex'; // Display the settings dropdown
});

document.addEventListener('click', (event) => {
const isCloseBtn = event.target.closest('.close-settings-btn');
if (isCloseBtn) {
settingsContent.style.display = 'none'; // Hide the settings dropdown
}
});
}

document.addEventListener('DOMContentLoaded', () => {
setupSettingsDropdown();
});
</script>
</ul>

0 comments on commit deb8338

Please sign in to comment.