Skip to content

Commit ec31dd8

Browse files
committed
refactor: remove jquery in modals/simple-modals
1 parent 13325db commit ec31dd8

File tree

1 file changed

+45
-28
lines changed

1 file changed

+45
-28
lines changed

frontend/src/ts/modals/simple-modals.ts

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { goToPage } from "../pages/leaderboards";
4646
import FileStorage from "../utils/file-storage";
4747
import { z } from "zod";
4848
import { remoteValidation } from "../utils/remote-validation";
49+
import { qs, qsr } from "../utils/dom";
4950

5051
type PopupKey =
5152
| "updateEmail"
@@ -1141,9 +1142,9 @@ list.updateCustomTheme = new SimpleModal({
11411142
if (updateColors === "true") {
11421143
for (const color of ThemeController.colorVars) {
11431144
newColors.push(
1144-
$(
1145+
qsr<HTMLInputElement>(
11451146
`.pageSettings .tabContent.customTheme #${color}[type='color']`,
1146-
).attr("value") as string,
1147+
).getValue() as string,
11471148
);
11481149
}
11491150
} else {
@@ -1336,89 +1337,105 @@ export function showPopup(
13361337
}
13371338

13381339
//todo: move these event handlers to their respective files (either global event files or popup files)
1339-
$(".pageAccountSettings").on("click", "#unlinkDiscordButton", () => {
1340+
qs(".pageAccountSettings")?.onChild("click", "#unlinkDiscordButton", () => {
13401341
showPopup("unlinkDiscord");
13411342
});
13421343

1343-
$(".pageAccountSettings").on("click", "#removeGoogleAuth", () => {
1344+
qs(".pageAccountSettings")?.onChild("click", "#removeGoogleAuth", () => {
13441345
showPopup("removeGoogleAuth");
13451346
});
13461347

1347-
$(".pageAccountSettings").on("click", "#removeGithubAuth", () => {
1348+
qs(".pageAccountSettings")?.onChild("click", "#removeGithubAuth", () => {
13481349
showPopup("removeGithubAuth");
13491350
});
13501351

1351-
$(".pageAccountSettings").on("click", "#removePasswordAuth", () => {
1352+
qs(".pageAccountSettings")?.onChild("click", "#removePasswordAuth", () => {
13521353
showPopup("removePasswordAuth");
13531354
});
13541355

1355-
$("#resetSettingsButton").on("click", () => {
1356+
qs("#resetSettingsButton")?.on("click", () => {
13561357
showPopup("resetSettings");
13571358
});
13581359

1359-
$(".pageAccountSettings").on("click", "#revokeAllTokens", () => {
1360+
qs(".pageAccountSettings")?.onChild("click", "#revokeAllTokens", () => {
13601361
showPopup("revokeAllTokens");
13611362
});
13621363

1363-
$(".pageAccountSettings").on("click", "#resetPersonalBestsButton", () => {
1364-
showPopup("resetPersonalBests");
1365-
});
1364+
qs(".pageAccountSettings")?.onChild(
1365+
"click",
1366+
"#resetPersonalBestsButton",
1367+
() => {
1368+
showPopup("resetPersonalBests");
1369+
},
1370+
);
13661371

1367-
$(".pageAccountSettings").on("click", "#updateAccountName", () => {
1372+
qs(".pageAccountSettings")?.onChild("click", "#updateAccountName", () => {
13681373
showPopup("updateName");
13691374
});
13701375

1371-
$("#bannerCenter").on("click", ".banner .text .openNameChange", () => {
1376+
qs("#bannerCenter")?.onChild("click", ".banner .text .openNameChange", () => {
13721377
showPopup("updateName");
13731378
});
13741379

1375-
$(".pageAccountSettings").on("click", "#addPasswordAuth", () => {
1380+
qs(".pageAccountSettings")?.onChild("click", "#addPasswordAuth", () => {
13761381
showPopup("addPasswordAuth");
13771382
});
13781383

1379-
$(".pageAccountSettings").on("click", "#emailPasswordAuth", () => {
1384+
qs(".pageAccountSettings")?.onChild("click", "#emailPasswordAuth", () => {
13801385
showPopup("updateEmail");
13811386
});
13821387

1383-
$(".pageAccountSettings").on("click", "#passPasswordAuth", () => {
1388+
qs(".pageAccountSettings")?.onChild("click", "#passPasswordAuth", () => {
13841389
showPopup("updatePassword");
13851390
});
13861391

1387-
$(".pageAccountSettings").on("click", "#deleteAccount", () => {
1392+
qs(".pageAccountSettings")?.onChild("click", "#deleteAccount", () => {
13881393
showPopup("deleteAccount");
13891394
});
13901395

1391-
$(".pageAccountSettings").on("click", "#resetAccount", () => {
1396+
qs(".pageAccountSettings")?.onChild("click", "#resetAccount", () => {
13921397
showPopup("resetAccount");
13931398
});
13941399

1395-
$(".pageAccountSettings").on("click", "#optOutOfLeaderboardsButton", () => {
1396-
showPopup("optOutOfLeaderboards");
1397-
});
1400+
qs(".pageAccountSettings")?.onChild(
1401+
"click",
1402+
"#optOutOfLeaderboardsButton",
1403+
() => {
1404+
showPopup("optOutOfLeaderboards");
1405+
},
1406+
);
13981407

1399-
$(".pageSettings").on(
1408+
qs(".pageSettings")?.onChild(
14001409
"click",
14011410
".section.themes .customTheme .delButton",
14021411
(e) => {
1403-
const $parentElement = $(e.currentTarget).parent(".customTheme.button");
1404-
const customThemeId = $parentElement.attr("customThemeId") as string;
1412+
const $parentElement = (e.childTarget as HTMLElement | null)?.closest(
1413+
".customTheme.button",
1414+
);
1415+
const customThemeId = $parentElement?.getAttribute(
1416+
"customThemeId",
1417+
) as string;
14051418
showPopup("deleteCustomTheme", [customThemeId]);
14061419
},
14071420
);
14081421

1409-
$(".pageSettings").on(
1422+
qs(".pageSettings")?.onChild(
14101423
"click",
14111424
".section.themes .customTheme .editButton",
14121425
(e) => {
1413-
const $parentElement = $(e.currentTarget).parent(".customTheme.button");
1414-
const customThemeId = $parentElement.attr("customThemeId") as string;
1426+
const $parentElement = (e.childTarget as HTMLElement | null)?.closest(
1427+
".customTheme.button",
1428+
);
1429+
const customThemeId = $parentElement?.getAttribute(
1430+
"customThemeId",
1431+
) as string;
14151432
showPopup("updateCustomTheme", [customThemeId], {
14161433
focusFirstInput: "focusAndSelect",
14171434
});
14181435
},
14191436
);
14201437

1421-
$(".pageSettings").on(
1438+
qs(".pageSettings")?.onChild(
14221439
"click",
14231440
".section[data-config-name='fontFamily'] button[data-config-value='custom']",
14241441
() => {

0 commit comments

Comments
 (0)