From f5a116eea3d3ec09173b7f9048e4bb9fc05237d2 Mon Sep 17 00:00:00 2001 From: Jonathan Gamble Date: Tue, 29 Oct 2024 22:58:22 -0500 Subject: [PATCH] remove practiceNag from bits.ts as it requires dialog.ts --- modules/practice/src/main/PracticeUi.scala | 7 ++++++- ui/bits/src/bits.ts | 11 ----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/modules/practice/src/main/PracticeUi.scala b/modules/practice/src/main/PracticeUi.scala index 4866389433a8a..15bf6c4f9c6bb 100644 --- a/modules/practice/src/main/PracticeUi.scala +++ b/modules/practice/src/main/PracticeUi.scala @@ -53,7 +53,12 @@ final class PracticeUi(helpers: Helpers)( div(cls := "bar", style := s"width: ${data.progressPercent}%") ), postForm(action := routes.Practice.reset)( - if ctx.isAuth then (data.nbDoneChapters > 0).option(a(cls := "do-reset")("Reset my progress")) + if ctx.isAuth then + (data.nbDoneChapters > 0).option( + submitButton(cls := "button confirm", title := "You will lose your practice progress!")( + "Reset my progress" + ) + ) else a(href := routes.Auth.signup)("Sign up to save your progress") ) ), diff --git a/ui/bits/src/bits.ts b/ui/bits/src/bits.ts index f99835512c452..a361f56e926b1 100644 --- a/ui/bits/src/bits.ts +++ b/ui/bits/src/bits.ts @@ -2,7 +2,6 @@ import { text, formToXhr } from 'common/xhr'; import flairPickerLoader from './exports/flairPicker'; import { spinnerHtml } from 'common/spinner'; import { wireCropDialog } from './exports/crop'; -import { confirm } from 'common/dialog'; // avoid node_modules and pay attention to imports here. we don't want to force people // to download the entire toastui editor library just to do some light form processing. @@ -31,8 +30,6 @@ export function initModule(args: { fn: string } & any): void { return oauth(args); case 'pmAll': return pmAll(); - case 'practiceNag': - return practiceNag(); case 'relayForm': return relayForm(); case 'setAssetInfo': @@ -189,14 +186,6 @@ function pmAll() { }); } -function practiceNag() { - const el = document.querySelector('.do-reset'); - if (!(el instanceof HTMLAnchorElement)) return; - el.addEventListener('click', async () => { - if (await confirm('You will lose your practice progress!')) (el.parentNode as HTMLFormElement).submit(); - }); -} - // ensure maximum browser compatibility here, // as the oauth page can be embedded in very dubious webviews function oauth({ danger }: { danger: boolean }) {