mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-28 10:59:46 +08:00
removed dependencies
commandline no longer is responsible for closing popups on escape each popup should handle this in their own module if a popup is visible commandline keypress handler just stops fixes 3 circular dependencies part of #2462
This commit is contained in:
parent
fe8f8e6851
commit
825a8e2732
2 changed files with 24 additions and 30 deletions
|
|
@ -1,15 +1,8 @@
|
|||
import * as Leaderboards from "./leaderboards";
|
||||
import * as ThemeController from "../controllers/theme-controller";
|
||||
import Config, * as UpdateConfig from "../config";
|
||||
import * as Focus from "../test/focus";
|
||||
import * as CommandlineLists from "./commandline-lists";
|
||||
import * as TestUI from "../test/test-ui";
|
||||
import * as PractiseWords from "../test/practise-words";
|
||||
import * as SimplePopups from "../popups/simple-popups";
|
||||
import * as CustomWordAmountPopup from "../popups/custom-word-amount-popup";
|
||||
import * as CustomTestDurationPopup from "../popups/custom-test-duration-popup";
|
||||
import * as CustomTextPopup from "../popups/custom-text-popup";
|
||||
import * as QuoteSearchPopupWrapper from "../popups/quote-search-popup";
|
||||
|
||||
let commandLineMouseMode = false;
|
||||
|
||||
|
|
@ -343,29 +336,20 @@ $(document).ready((e) => {
|
|||
(event.key === "Tab" && Config.swapEscAndTab)
|
||||
) {
|
||||
event.preventDefault();
|
||||
if (!$("#leaderboardsWrapper").hasClass("hidden")) {
|
||||
//maybe add more condition for closing other dialogs in the future as well
|
||||
event.preventDefault();
|
||||
Leaderboards.hide();
|
||||
} else if (!$("#practiseWordsPopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
PractiseWords.hidePopup();
|
||||
} else if (!$("#simplePopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
SimplePopups.hide();
|
||||
} else if (!$("#customWordAmountPopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
CustomWordAmountPopup.hide();
|
||||
} else if (!$("#customTestDurationPopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
CustomTestDurationPopup.hide();
|
||||
} else if (!$("#customTextPopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
CustomTextPopup.hide();
|
||||
} else if (!$("#quoteSearchPopupWrapper").hasClass("hidden")) {
|
||||
event.preventDefault();
|
||||
QuoteSearchPopupWrapper.hide();
|
||||
} else if (!$("#commandLineWrapper").hasClass("hidden")) {
|
||||
|
||||
const popups = document.querySelectorAll(".popupWrapper");
|
||||
|
||||
let popupVisible = false;
|
||||
for (const popup of popups) {
|
||||
if (!popup.classList.contains("hidden") === true) {
|
||||
popupVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (popupVisible) return;
|
||||
|
||||
if (!$("#commandLineWrapper").hasClass("hidden")) {
|
||||
if (CommandlineLists.current.length > 1) {
|
||||
CommandlineLists.current.pop();
|
||||
$("#commandLine").removeClass("allCommands");
|
||||
|
|
|
|||
|
|
@ -204,6 +204,16 @@ $(document).on("click", "#quoteSearchPopup .report", async (e) => {
|
|||
});
|
||||
});
|
||||
|
||||
$(document).keydown((event) => {
|
||||
if (
|
||||
event.key === "Escape" &&
|
||||
!$("#quoteSearchPopupWrapper").hasClass("hidden")
|
||||
) {
|
||||
hide();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// $("#quoteSearchPopup input").keypress((e) => {
|
||||
// if (e.keyCode == 13) {
|
||||
// if (!isNaN(document.getElementById("searchBox").value)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue