Skip to content

Commit

Permalink
#117 theme popup onclick (#132)
Browse files Browse the repository at this point in the history
* Re-added popup toggling when setting theme

* Fixed popup opening when body clicked
  • Loading branch information
Shabbyconnor committed Jul 25, 2022
1 parent 6997e6d commit 32da981
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 5 additions & 14 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
window.onload = runStageRequiredScripts();

//themeToggler ensures that it needs two clicks on body to close the themePopup, given that a click on the button that opens the popup counts as a click on body as well
var themeToggler = 0;
document.addEventListener("click", function (event) {
themeToggler++;
if ((themeToggler & 2) === 0) {
document.getElementById("themePopup").style.display = "none";
document.getElementById("doors_icon").style.visibility = "visible";
}
});

//Global vars
const totalStages = 4;
var stage = 1;
Expand Down Expand Up @@ -142,10 +132,11 @@ function toggleThemePopup() {

//when user clicks outside of theme popup, close it
function addPopupListener() {
window.addEventListener("click", function (e) {
if (document.getElementById("themePopup").hidden) {
return;
}


window.addEventListener('click', function (e) {

if (document.getElementById('themePopup').style.display == 'none') {return;}

if (e.target == document.body) {
toggleThemePopup();
Expand Down
2 changes: 2 additions & 0 deletions scripts/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const setTheme = (theme) => {
}

getTheme(currTheme);

toggleThemePopup()
};

const getTheme = (oldTheme) => {
Expand Down

0 comments on commit 32da981

Please sign in to comment.