mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
added full functionality to support-model with arrows tab and enter/space.
This commit is contained in:
parent
b2cc35dcd0
commit
6cc0d05e78
3 changed files with 35 additions and 20 deletions
|
@ -573,22 +573,22 @@
|
||||||
|
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link active" href="#faqs" aria-controls="profile" role="tab" data-toggle="tab">
|
<a id="tab-1" class="nav-link active" href="#faqs" aria-controls="profile" role="tab" data-toggle="tab">
|
||||||
FAQs
|
FAQs
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link" href="#report-bug" aria-controls="messages" role="tab" data-toggle="tab">
|
<a id="tab-2" class="nav-link" href="#report-bug" aria-controls="messages" role="tab" data-toggle="tab">
|
||||||
Report a bug
|
Report a bug
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link" href="#about" aria-controls="messages" role="tab" data-toggle="tab">
|
<a id="tab-3" class="nav-link" href="#about" aria-controls="messages" role="tab" data-toggle="tab">
|
||||||
About
|
About
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link" href="#keybindings" aria-controls="messages" role="tab" data-toggle="tab">
|
<a id="tab-4" class="nav-link" href="#keybindings" aria-controls="messages" role="tab" data-toggle="tab">
|
||||||
Keybindings
|
Keybindings
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -78,6 +78,11 @@
|
||||||
border-left: 2px solid var(--primary-border-colour);
|
border-left: 2px solid var(--primary-border-colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p a:focus{
|
||||||
|
color: #0a6ebd;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.checkbox label input[type=checkbox]+.checkbox-decorator .check,
|
.checkbox label input[type=checkbox]+.checkbox-decorator .check,
|
||||||
.checkbox label input[type=checkbox]+.checkbox-decorator .check::before {
|
.checkbox label input[type=checkbox]+.checkbox-decorator .check::before {
|
||||||
border-color: var(--input-border-colour);
|
border-color: var(--input-border-colour);
|
||||||
|
|
|
@ -355,13 +355,14 @@ class ControlsWaiter {
|
||||||
const faqsAElement = faqs.getElementsByTagName("a");
|
const faqsAElement = faqs.getElementsByTagName("a");
|
||||||
for (let i = 0; i < faqsAElement.length; i++) {
|
for (let i = 0; i < faqsAElement.length; i++) {
|
||||||
faqsAElement[i].setAttribute("tabindex", "0");
|
faqsAElement[i].setAttribute("tabindex", "0");
|
||||||
|
faqsAElement[i].addEventListener("keydown", this.navigateFAQList, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabs = document.querySelectorAll('[role="tab"]');
|
const tabs = document.querySelectorAll('[role="tab"]');
|
||||||
|
|
||||||
for (let i = 0; i < tabs.length; i++) {
|
for (let i = 0; i < tabs.length; i++) {
|
||||||
tabs[i].addEventListener("keydown", this.changeTabs, false);
|
tabs[i].addEventListener("keydown", this.changeTabs, false);
|
||||||
tabs[i].addEventListener("keydown", this.navigateTabsList, false);
|
// tabs[i].addEventListener("keydown", this.navigateFAQList, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const reportBugInfo = document.getElementById("report-bug-info");
|
const reportBugInfo = document.getElementById("report-bug-info");
|
||||||
|
@ -403,26 +404,35 @@ ${navigator.userAgent}
|
||||||
} else {
|
} else {
|
||||||
prevTab.previousElementSibling.firstElementChild.focus();
|
prevTab.previousElementSibling.firstElementChild.focus();
|
||||||
}
|
}
|
||||||
} else if (ev.key === "Tab" && !ev.shiftKey) {
|
} else if (ev.key === "Tab" && !ev.shiftKey && ev.target === document.getElementById("tab-1")) {
|
||||||
tab.parentElement.parentElement.nextElementSibling.firstElementChild.querySelector("[class='btn btn-primary']").focus();
|
document.getElementById("faqs").querySelector("[class='btn btn-primary']").focus();
|
||||||
|
} else if (ev.key === "Tab" && !ev.shiftKey && ev.target === document.getElementById("tab-2")) {
|
||||||
|
document.getElementById("report-bug").querySelector("[class='btn btn-primary']").focus();
|
||||||
|
} else if (ev.key === "Tab" && !ev.shiftKey && ev.target === document.getElementById("tab-3")) {
|
||||||
|
document.getElementById("about").querySelector("[href]").focus();
|
||||||
|
} else if (ev.key === "Tab" && !ev.shiftKey && ev.target === document.getElementById("tab-4")) {
|
||||||
|
const button = document.getElementById("support-modal").getElementsByClassName("modal-footer");
|
||||||
|
const close = button[0].firstElementChild;
|
||||||
|
close.focus();
|
||||||
|
} else if (ev.key === "Enter" || ev.key === "Space" ||ev.key === " ") {
|
||||||
|
tab.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Event} ev
|
* @param {Event} ev
|
||||||
*/
|
*/
|
||||||
navigateTabsList(ev) {
|
navigateFAQList(ev) {
|
||||||
ev.preventDefault();
|
|
||||||
|
const el = ev.target.nextElementSibling;
|
||||||
if (ev.key === "Enter" || ev.key === "Space"|| ev.key === " "){
|
if (ev.key === "Enter" || ev.key === "Space"|| ev.key === " "){
|
||||||
const el = ev.target;
|
|
||||||
const targetElement = el.parentElement.parentElement;
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
for (let i = 0; i < targetElement.children.length; i++) {
|
const question = el.classList;
|
||||||
const targetChild = targetElement.children[i];
|
if(question !== undefined && question.value){
|
||||||
if (targetChild.children !== undefined && targetChild.children.classList.querySelectorAll("nav-link")) {
|
if (!question.value.includes("show")) {
|
||||||
if (!targetChild.contains("active")) {
|
question.add("show");
|
||||||
targetChild.add("active");
|
} else if (question.contains("show")) {
|
||||||
}
|
question.remove("show");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue