Skip to content

Commit

Permalink
Merge pull request #82 from stellarix/escape_key
Browse files Browse the repository at this point in the history
Added Escape key function for modal close button
  • Loading branch information
secure-77 authored May 30, 2023
2 parents 4b93073 + 158b32e commit 5dee792
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions perlite/.js/perlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -1547,11 +1547,20 @@ if (localStorage.getItem("showTOC") === 'true') {
});

// close modal
function hideElements(elementIds) {
elementIds.forEach(function (id) {
$("#" + id).css("display", "none");
});
}

$('.modal-close-button').click(function (e) {
$("#settings").css("display", "none");
$("#about").css("display", "none");
$("#popUp").css("display", "none");
$("#img-modal").css("display", "none");
hideElements(["settings", "about", "popUp", "img-modal"]);
});

$(document).keydown(function (e) {
if (e.key === "Escape") {
hideElements(["settings", "about", "popUp", "img-modal"]);
}
});

// local Graph & Toc (outline) Switch
Expand Down

0 comments on commit 5dee792

Please sign in to comment.