From 76db73427fae6dc0fc8d23f5e1b65082808840c6 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 16 Oct 2022 18:39:12 +0200 Subject: [PATCH] updated event handlers --- frontend/src/ts/pages/settings.ts | 69 ++++++++++++------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 7dfa35602..d6e6da846 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -789,9 +789,9 @@ function toggleSettingsGroup(groupName: string): void { } } -$(document).on( +$(".pageSettings .section.paceCaret").on( "focusout", - ".pageSettings .section.paceCaret input.customPaceCaretSpeed", + "input.customPaceCaretSpeed", () => { UpdateConfig.setPaceCaretCustomSpeed( parseInt( @@ -803,7 +803,7 @@ $(document).on( } ); -$(document).on("click", ".pageSettings .section.paceCaret .button.save", () => { +$(".pageSettings .section.paceCaret").on("click", ".button.save", () => { UpdateConfig.setPaceCaretCustomSpeed( parseInt( $( @@ -813,9 +813,9 @@ $(document).on("click", ".pageSettings .section.paceCaret .button.save", () => { ); }); -$(document).on( +$(".pageSettings .section.minWpm").on( "focusout", - ".pageSettings .section.minWpm input.customMinWpmSpeed", + "input.customMinWpmSpeed", () => { UpdateConfig.setMinWpmCustomSpeed( parseInt( @@ -827,7 +827,7 @@ $(document).on( } ); -$(document).on("click", ".pageSettings .section.minWpm .button.save", () => { +$(".pageSettings .section.minWpm").on("click", ".button.save", () => { UpdateConfig.setMinWpmCustomSpeed( parseInt( $(".pageSettings .section.minWpm input.customMinWpmSpeed").val() as string @@ -835,19 +835,7 @@ $(document).on("click", ".pageSettings .section.minWpm .button.save", () => { ); }); -$(document).on( - "focusout", - ".pageSettings .section.minAcc input.customMinAcc", - () => { - UpdateConfig.setMinAccCustom( - parseInt( - $(".pageSettings .section.minAcc input.customMinAcc").val() as string - ) - ); - } -); - -$(document).on("click", ".pageSettings .section.minAcc .button.save", () => { +$(".pageSettings .section.minAcc").on("focusout", "input.customMinAcc", () => { UpdateConfig.setMinAccCustom( parseInt( $(".pageSettings .section.minAcc input.customMinAcc").val() as string @@ -855,9 +843,17 @@ $(document).on("click", ".pageSettings .section.minAcc .button.save", () => { ); }); -$(document).on( +$(".pageSettings .section.minAcc").on("click", ".button.save", () => { + UpdateConfig.setMinAccCustom( + parseInt( + $(".pageSettings .section.minAcc input.customMinAcc").val() as string + ) + ); +}); + +$(".pageSettings .section.minBurst").on( "focusout", - ".pageSettings .section.minBurst input.customMinBurst", + "input.customMinBurst", () => { UpdateConfig.setMinBurstCustomSpeed( parseInt( @@ -869,7 +865,7 @@ $(document).on( } ); -$(document).on("click", ".pageSettings .section.minBurst .button.save", () => { +$(".pageSettings .section.minBurst").on("click", ".button.save", () => { UpdateConfig.setMinBurstCustomSpeed( parseInt( $(".pageSettings .section.minBurst input.customMinBurst").val() as string @@ -877,19 +873,8 @@ $(document).on("click", ".pageSettings .section.minBurst .button.save", () => { ); }); -// Commented because started using combo-box for choosing languages instead of grouped buttons -// languages -// $(document).on( -// "click", -// ".pageSettings .section.languageGroups .button", -// (e) => { -// const group = $(e.currentTarget).attr("group"); -// LanguagePicker.setActiveGroup(group, true); -// } -// ); - //funbox -$(document).on("click", ".pageSettings .section.funbox .button", (e) => { +$(".pageSettings .section.funbox").on("click", ".button", (e) => { const funbox = $(e.currentTarget).attr("funbox"); const type = $(e.currentTarget).attr("type"); Funbox.setFunbox(funbox, type); @@ -897,9 +882,9 @@ $(document).on("click", ".pageSettings .section.funbox .button", (e) => { }); //tags -$(document).on( +$(".pageSettings .section.tags").on( "click", - ".pageSettings .section.tags .tagsList .tag .tagButton", + ".tagsList .tag .tagButton", (e) => { const target = e.currentTarget; const tagid = $(target).parent(".tag").attr("id") as string; @@ -908,9 +893,9 @@ $(document).on( } ); -$(document).on( +$(".pageSettings .section.presets").on( "click", - ".pageSettings .section.presets .presetsList .preset .presetButton", + ".presetsList .preset .presetButton", (e) => { const target = e.currentTarget; const presetid = $(target).parent(".preset").attr("id") as string; @@ -1039,9 +1024,9 @@ $(".pageSettings .section.updateCookiePreferences .button").on("click", () => { CookiePopup.showSettings(); }); -$(document).on( +$(".pageSettings .section.autoSwitchThemeInputs").on( "change", - `.pageSettings .section.autoSwitchThemeInputs select.light`, + `select.light`, (e) => { const target = $(e.currentTarget); if (target.hasClass("disabled") || target.hasClass("no-auto-handle")) { @@ -1051,9 +1036,9 @@ $(document).on( } ); -$(document).on( +$(".pageSettings .section.autoSwitchThemeInputs").on( "change", - `.pageSettings .section.autoSwitchThemeInputs select.dark`, + `select.dark`, (e) => { const target = $(e.currentTarget); if (target.hasClass("disabled") || target.hasClass("no-auto-handle")) {