created settings.js file

This commit is contained in:
westtle 2024-02-07 02:02:34 +07:00
parent 82b3f17840
commit 0175bc73c2
3 changed files with 21 additions and 20 deletions

View file

@ -2,24 +2,6 @@
const inputTitle = document.querySelector(".simple-note__input--title");
const inputBody = document.querySelector(".simple-note__input--body");
const settingsToggle = document.querySelector(".settings__button--toggle-settings");
const settingsList = document.querySelector(".settings__buttons");
const settingsItems = settingsList.querySelectorAll("a, button");
function toggleSettings() {
const isExpanded = (settingsToggle.getAttribute("aria-expanded") == "true");
if (isExpanded) {
settingsToggle.setAttribute("aria-expanded", false);
settingsList.setAttribute("aria-hidden", true);
settingsItems.forEach(item => {item.tabIndex = -1});
} else {
settingsToggle.setAttribute("aria-expanded", true);
settingsList.setAttribute("aria-hidden", false);
settingsItems.forEach(item => {item.tabIndex = 0});
};
};
// Local Storage.
const note_title = "Note_Title";
const note_body = "Note_Body";
@ -60,8 +42,6 @@ document.addEventListener("DOMContentLoaded", () => {
loadNote();
});
settingsToggle.addEventListener("click", toggleSettings);
// function showDeleteConfirm() {
// confirmDeleteButton.style.display = "inline";
// deleteAllButton.style.display = "none";

View file

@ -0,0 +1,20 @@
// HTML.
const settingsToggle = document.querySelector(".settings__button--toggle-settings");
const settingsList = document.querySelector(".settings__buttons");
const settingsItems = settingsList.querySelectorAll("a, button");
function toggleSettings() {
const isExpanded = (settingsToggle.getAttribute("aria-expanded") == "true");
if (isExpanded) {
settingsToggle.setAttribute("aria-expanded", false);
settingsList.setAttribute("aria-hidden", true);
settingsItems.forEach(item => {item.tabIndex = -1});
} else {
settingsToggle.setAttribute("aria-expanded", true);
settingsList.setAttribute("aria-hidden", false);
settingsItems.forEach(item => {item.tabIndex = 0});
};
};
settingsToggle.addEventListener("click", toggleSettings);

View file

@ -84,5 +84,6 @@
</main>
<script type="text/javascript" src="./assets/scripts/script.js"></script>
<script type="text/javascript" src="./assets/scripts/settings.js"></script>
</body>
</html>