Skip to content

Commit

Permalink
frontend: templates: Prevent rapid btn clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
codemacabre committed Dec 23, 2022
1 parent a21a3af commit 4a49e93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cove_ofds/sass/_custom-ofds.sass
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ a pre
h4.validation-title
display: flex
justify-content: space-between
margin-top: 15px
margin-bottom: -10px

button.btn-link
color: #777
Expand Down
2 changes: 1 addition & 1 deletion cove_ofds/static/dataexplore/css/bootstrap-ofds.css

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions cove_ofds/templates/cove_ofds/jsonschema_validation_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,21 @@ <h4 class="validation-title">
const buttons = document.querySelectorAll('.validation-error-toggle');
buttons.forEach(button => {
button.addEventListener('click', () => {
if (button.classList.contains('collapsed')) {
let span = button.querySelector(".glyphicon-chevron-down");
span.classList.remove("glyphicon-chevron-down");
span.classList.add("glyphicon-chevron-up");
} else {
let span = button.querySelector(".glyphicon-chevron-up");
span.classList.remove("glyphicon-chevron-up");
span.classList.add("glyphicon-chevron-down");
}
setTimeout(() => {
if (button.getAttribute('aria-expanded') !== 'false') {
let span = button.querySelector(".glyphicon-chevron-down");
if (span) {
span.classList.remove("glyphicon-chevron-down");
span.classList.add("glyphicon-chevron-up");
}
} else {
let span = button.querySelector(".glyphicon-chevron-up");
if (span) {
span.classList.remove("glyphicon-chevron-up");
span.classList.add("glyphicon-chevron-down");
}
}
}, 500)
});
});
});
Expand Down

0 comments on commit 4a49e93

Please sign in to comment.