Skip to content

Commit

Permalink
Merge pull request #856 from NASA-IMPACT/147-pattern-modal-keys
Browse files Browse the repository at this point in the history
147 pattern modal keys
  • Loading branch information
Jmok19927 authored Jun 14, 2024
2 parents d809645 + 64e5101 commit 97d6cc3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sde_indexing_helper/static/js/candidate_url_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,21 @@ function getDocumentTypeColumn() {
};
}

//template to add enter and escape functionalities to add pattern modals
function addEnterEscapeKeypress(modalID, formID) {
$("body").on("keydown", function(event) {
let modal = $(modalID);
let form = $(formID)
if(event.key == "Escape" && modal.is(":visible")) {
modal.modal("hide");
}
if (event.key == "Enter" && modal.is(":visible")) {
form.submit();
modal.modal("hide");
}
})
}

function handleHideorShowKeypress() {
$("body").on("keydown", function () {
//Close modal via escape
Expand All @@ -816,6 +831,14 @@ function handleHideorShowKeypress() {
$("body").on("click", ".modal-backdrop", function () {
$("#hideShowColumnsModal").modal("hide");
});

//adding each modals keypress functionalities
addEnterEscapeKeypress("#excludePatternModal", "#exclude_pattern_form");
addEnterEscapeKeypress("#includePatternModal", "#include_pattern_form");
addEnterEscapeKeypress("#titlePatternModal", "#title_pattern_form");
addEnterEscapeKeypress("#documentTypePatternModal", "#document_type_pattern_form");


}

function handleHideorShowSubmitButton() {
Expand Down

0 comments on commit 97d6cc3

Please sign in to comment.