diff --git a/ui/analyse/src/explorer/explorerConfig.ts b/ui/analyse/src/explorer/explorerConfig.ts index 17d0534ced52..2c7c468bf0a1 100644 --- a/ui/analyse/src/explorer/explorerConfig.ts +++ b/ui/analyse/src/explorer/explorerConfig.ts @@ -333,6 +333,7 @@ const playerModal = (ctrl: ExplorerConfigCtrl) => { ctrl.data.playerName.open(false); ctrl.root.redraw(); }, + modal: true, vnodes: [ h('h2', 'Personal opening explorer'), h('div.input-wrapper', [ diff --git a/ui/analyse/src/keyboard.ts b/ui/analyse/src/keyboard.ts index f170fb024f54..79ac69eb1d03 100644 --- a/ui/analyse/src/keyboard.ts +++ b/ui/analyse/src/keyboard.ts @@ -140,6 +140,7 @@ export function view(ctrl: AnalyseCtrl): VNode { return snabDialog({ class: 'help.keyboard-help', htmlUrl: xhr.url('/analysis/help', { study: !!ctrl.study }), + modal: true, onClose() { ctrl.keyboardHelp = false; ctrl.redraw(); diff --git a/ui/analyse/src/serverSideUnderboard.ts b/ui/analyse/src/serverSideUnderboard.ts index 670677529043..e8f68cc14cb9 100644 --- a/ui/analyse/src/serverSideUnderboard.ts +++ b/ui/analyse/src/serverSideUnderboard.ts @@ -150,7 +150,8 @@ export default function (element: HTMLElement, ctrl: AnalyseCtrl) { const url = `${baseUrl()}/embed/game/${data.game.id}?theme=auto&bg=auto${location.hash}`; const iframe = ``; domDialog({ - show: 'modal', + modal: true, + show: true, htmlText: '
' + $(this).html() + diff --git a/ui/analyse/src/study/chapterEditForm.ts b/ui/analyse/src/study/chapterEditForm.ts index e622342a438a..adc97a939d4a 100644 --- a/ui/analyse/src/study/chapterEditForm.ts +++ b/ui/analyse/src/study/chapterEditForm.ts @@ -68,6 +68,8 @@ export function view(ctrl: StudyChapterEditForm): VNode | undefined { ctrl.current(null); ctrl.redraw(); }, + modal: true, + noClickAway: true, vnodes: [ h('h2', i18n.study.editChapter), h( diff --git a/ui/analyse/src/study/chapterNewForm.ts b/ui/analyse/src/study/chapterNewForm.ts index 48283094e401..459cc9d33257 100644 --- a/ui/analyse/src/study/chapterNewForm.ts +++ b/ui/analyse/src/study/chapterNewForm.ts @@ -141,6 +141,7 @@ export function view(ctrl: StudyChapterNewForm): VNode { ctrl.isOpen(false); ctrl.redraw(); }, + modal: true, noClickAway: true, vnodes: [ activeTab !== 'edit' && diff --git a/ui/analyse/src/study/inviteForm.ts b/ui/analyse/src/study/inviteForm.ts index 57b78ed0c656..ab9602a15efd 100644 --- a/ui/analyse/src/study/inviteForm.ts +++ b/ui/analyse/src/study/inviteForm.ts @@ -64,6 +64,7 @@ export function view(ctrl: ReturnType): VNode { ctrl.open(false); ctrl.redraw(); }, + modal: true, noScrollable: true, vnodes: [ h('h2', i18n.study.inviteToTheStudy), diff --git a/ui/analyse/src/study/studyForm.ts b/ui/analyse/src/study/studyForm.ts index ed4428bf7c2a..0549059f7b35 100644 --- a/ui/analyse/src/study/studyForm.ts +++ b/ui/analyse/src/study/studyForm.ts @@ -256,6 +256,7 @@ export function view(ctrl: StudyForm): VNode { ctrl.open(false); ctrl.redraw(); }, + modal: true, noClickAway: true, vnodes: [ h( diff --git a/ui/analyse/src/study/studySearch.ts b/ui/analyse/src/study/studySearch.ts index 3be0b08190c0..41a08916db2d 100644 --- a/ui/analyse/src/study/studySearch.ts +++ b/ui/analyse/src/study/studySearch.ts @@ -55,6 +55,7 @@ export function view(ctrl: SearchCtrl) { onClose() { ctrl.open(false); }, + modal: true, vnodes: [ h('input', { attrs: { autofocus: 1, placeholder: `Search in ${ctrl.studyName}`, value: ctrl.query() }, diff --git a/ui/analyse/src/study/topics.ts b/ui/analyse/src/study/topics.ts index 3a3b887c5902..d9949f56572b 100644 --- a/ui/analyse/src/study/topics.ts +++ b/ui/analyse/src/study/topics.ts @@ -41,6 +41,7 @@ export const formView = (ctrl: TopicsCtrl, userId?: string): VNode => ctrl.open(false); ctrl.redraw(); }, + modal: true, vnodes: [ h('h2', i18n.study.topics), h( diff --git a/ui/analyse/src/view/actionMenu.ts b/ui/analyse/src/view/actionMenu.ts index 18602b38079e..f066a68bea65 100644 --- a/ui/analyse/src/view/actionMenu.ts +++ b/ui/analyse/src/view/actionMenu.ts @@ -117,7 +117,9 @@ export function view(ctrl: AnalyseCtrl): VNode { h( 'a', { - hook: bind('click', () => domDialog({ cash: $('.continue-with.g_' + d.game.id), show: 'modal' })), + hook: bind('click', () => + domDialog({ cash: $('.continue-with.g_' + d.game.id), modal: true, show: true }), + ), attrs: dataIcon(licon.Swords), }, i18n.site.continueFromHere, diff --git a/ui/bits/src/bits.cropDialog.ts b/ui/bits/src/bits.cropDialog.ts index 9414167412ff..7768fe4977c5 100644 --- a/ui/bits/src/bits.cropDialog.ts +++ b/ui/bits/src/bits.cropDialog.ts @@ -66,6 +66,7 @@ export async function initModule(o?: CropOpts): Promise { const dlg = await domDialog({ class: 'crop-viewer', css: [{ hashed: 'bits.cropDialog' }, { url: 'npm/cropper.min.css' }], + modal: true, htmlText: `

Crop image to desired shape

@@ -81,7 +82,7 @@ export async function initModule(o?: CropOpts): Promise { }, }); - dlg.showModal(); + dlg.show(); async function crop() { const view = dlg.view.querySelector('.crop-view') as HTMLElement; diff --git a/ui/bits/src/bits.diagnosticDialog.ts b/ui/bits/src/bits.diagnosticDialog.ts index 98f00fa6bc2e..c11095983256 100644 --- a/ui/bits/src/bits.diagnosticDialog.ts +++ b/ui/bits/src/bits.diagnosticDialog.ts @@ -31,6 +31,7 @@ export async function initModule(): Promise { const dlg = await domDialog({ class: 'diagnostic', css: [{ hashed: 'bits.diagnosticDialog' }], + modal: true, htmlText: `

Diagnostics

${flash}
${escaped}
@@ -52,7 +53,7 @@ export async function initModule(): Promise { setTimeout(() => copied.remove(), 2000); }), ); - dlg.showModal(); + dlg.show(); } const storageProxy: { [key: string]: { storageKey: string; validate: (val?: string) => boolean } } = { diff --git a/ui/bits/src/bits.forum.ts b/ui/bits/src/bits.forum.ts index 34ecccd45524..e8e70f433650 100644 --- a/ui/bits/src/bits.forum.ts +++ b/ui/bits/src/bits.forum.ts @@ -11,6 +11,7 @@ site.load.then(() => { domDialog({ cash: $('.forum-delete-modal'), attrs: { view: { action: link.href } }, + modal: true, }).then(dlg => { $(dlg.view) .find('form') @@ -22,7 +23,7 @@ site.load.then(() => { dlg.close(); }); $(dlg.view).find('form button.cancel').on('click', dlg.close); - dlg.showModal(); + dlg.show(); }); return false; }) @@ -31,10 +32,11 @@ site.load.then(() => { domDialog({ cash: $('.forum-relocate-modal'), attrs: { view: { action: link.href } }, + modal: true, }).then(dlg => { $(dlg.view).find('form').attr('action', link.href); $(dlg.view).find('form button.cancel').on('click', dlg.close); - dlg.showModal(); + dlg.show(); }); return false; }) diff --git a/ui/bits/src/bits.publicChats.ts b/ui/bits/src/bits.publicChats.ts index 0d9819cd2962..913094f026ee 100644 --- a/ui/bits/src/bits.publicChats.ts +++ b/ui/bits/src/bits.publicChats.ts @@ -40,7 +40,7 @@ site.load.then(() => { $('#communication').on('click', '.line:not(.lichess)', function (this: HTMLDivElement) { const $l = $(this); - domDialog({ cash: $('.timeout-modal') }).then(dlg => { + domDialog({ cash: $('.timeout-modal'), modal: true }).then(dlg => { $('.username', dlg.view).text($l.find('.user-link').text()); $('.text', dlg.view).text($l.text().split(' ').slice(1).join(' ')); $('.button', dlg.view).on('click', function (this: HTMLButtonElement) { @@ -58,7 +58,7 @@ site.load.then(() => { }).then(_ => setTimeout(reloadNow, 1000)); dlg.close(); }); - dlg.showModal(); + dlg.show(); }); }); }; diff --git a/ui/ceval/src/util.ts b/ui/ceval/src/util.ts index 7507d84d8346..801705a85620 100644 --- a/ui/ceval/src/util.ts +++ b/ui/ceval/src/util.ts @@ -39,6 +39,7 @@ export const sharedWasmMemory = (lo: number, hi = 32767): WebAssembly.Memory => export function showEngineError(engine: string, error: string): void { domDialog({ class: 'engine-error', + modal: true, htmlText: `

${escapeHtml(engine)} error

` + (error.includes('Status 503') @@ -57,6 +58,6 @@ export function showEngineError(engine: string, error: string): void { window.getSelection()?.addRange(range); }, 0); dlg.view.querySelector('.err')?.addEventListener('focus', select); - dlg.showModal(); + dlg.show(); }); } diff --git a/ui/cli/src/cli.ts b/ui/cli/src/cli.ts index e54c70740d95..aaad653f7748 100644 --- a/ui/cli/src/cli.ts +++ b/ui/cli/src/cli.ts @@ -60,7 +60,8 @@ function help() { domDialog({ css: [{ hashed: 'cli.help' }], class: 'clinput-help', - show: 'modal', + modal: true, + show: true, htmlText: '

Commands

' + commandHelp('/tv /follow', ' ', 'Watch someone play') + diff --git a/ui/common/src/dialog.ts b/ui/common/src/dialog.ts index 73f1054384ba..0889e41b77d4 100644 --- a/ui/common/src/dialog.ts +++ b/ui/common/src/dialog.ts @@ -13,7 +13,7 @@ export interface Dialog { readonly view: HTMLElement; // your content div readonly returnValue?: 'ok' | 'cancel' | string; // how did we close? - show(): Promise; // resolves on close with returnValue (if needed) + show(): Promise; // promise resolves on close updateActions(actions?: Action | Action[]): void; // set new actions or reattach existing if no args close(returnValue?: string): void; } diff --git a/ui/common/src/linkPopup.ts b/ui/common/src/linkPopup.ts index 4d6653237c08..0413854a9319 100644 --- a/ui/common/src/linkPopup.ts +++ b/ui/common/src/linkPopup.ts @@ -28,10 +28,11 @@ export const onClick = (a: HTMLLinkElement): boolean => { ${i18n.site.proceedToX(url.host)}
`, + modal: true, }).then(dlg => { $('.cancel', dlg.view).on('click', dlg.close); $('a', dlg.view).on('click', () => setTimeout(dlg.close, 1000)); - dlg.showModal(); + dlg.show(); }); return false; }; diff --git a/ui/editor/src/view.ts b/ui/editor/src/view.ts index 843e30d6d5e7..aa3597fe7340 100644 --- a/ui/editor/src/view.ts +++ b/ui/editor/src/view.ts @@ -247,7 +247,7 @@ function controls(ctrl: EditorCtrl, state: EditorState): VNode { class: { button: true, 'button-empty': true, disabled: !state.playable }, on: { click: () => { - if (state.playable) domDialog({ cash: $('.continue-with'), show: 'modal' }); + if (state.playable) domDialog({ cash: $('.continue-with'), modal: true, show: true }); }, }, }, diff --git a/ui/keyboardMove/src/exports.ts b/ui/keyboardMove/src/exports.ts index e54d570a28ab..638cf2242fba 100644 --- a/ui/keyboardMove/src/exports.ts +++ b/ui/keyboardMove/src/exports.ts @@ -84,6 +84,7 @@ export function render(ctrl: KeyboardMove): VNode { class: 'help.keyboard-move-help', htmlUrl: '/help/keyboard-move', onClose: () => ctrl.helpModalOpen(false), + modal: true, }) : null, ]); diff --git a/ui/lobby/src/view/setup/modal.ts b/ui/lobby/src/view/setup/modal.ts index c40dd937242b..b4344a0d7c18 100644 --- a/ui/lobby/src/view/setup/modal.ts +++ b/ui/lobby/src/view/setup/modal.ts @@ -19,6 +19,7 @@ export default function setupModal(ctrl: LobbyController): MaybeVNode { class: 'game-setup', css: [{ hashed: 'lobby.setup' }], onClose: setupCtrl.closeModal, + modal: true, vnodes: [...views[setupCtrl.gameType](ctrl), ratingView(ctrl)], }); } diff --git a/ui/puzzle/src/keyboard.ts b/ui/puzzle/src/keyboard.ts index 78538e662b01..102e709e2bc3 100644 --- a/ui/puzzle/src/keyboard.ts +++ b/ui/puzzle/src/keyboard.ts @@ -39,4 +39,5 @@ export const view = (ctrl: PuzzleCtrl) => class: 'help', htmlUrl: '/training/help', onClose: () => ctrl.keyboardHelp(false), + modal: true, }); diff --git a/ui/puzzle/src/report.ts b/ui/puzzle/src/report.ts index ed3c7b2f0c28..ed0fff670bb8 100644 --- a/ui/puzzle/src/report.ts +++ b/ui/puzzle/src/report.ts @@ -74,6 +74,7 @@ export default class Report { domDialog({ focus: '.apply', + modal: true, htmlText: '
' + 'Report multiple solutions' + @@ -101,7 +102,7 @@ export default class Report { xhrReport(puzzleId, reason); dlg.close(); }); - dlg.showModal(); + dlg.show(); }); }; } diff --git a/ui/round/src/keyboard.ts b/ui/round/src/keyboard.ts index 7ff532e8971c..d50f57110f07 100644 --- a/ui/round/src/keyboard.ts +++ b/ui/round/src/keyboard.ts @@ -40,4 +40,5 @@ export const view = (ctrl: RoundController): VNode => ctrl.keyboardHelp = false; ctrl.redraw(); }, + modal: true, }); diff --git a/ui/simul/src/view/created.ts b/ui/simul/src/view/created.ts index dffcf2b6b346..55319b316dda 100644 --- a/ui/simul/src/view/created.ts +++ b/ui/simul/src/view/created.ts @@ -38,12 +38,13 @@ export default function (showText: (ctrl: SimulCtrl) => VNode | false) { else domDialog({ cash: $('.simul .continue-with'), + modal: true, }).then(dlg => { $('button.button', dlg.view).on('click', function (this: HTMLButtonElement) { xhr.join(ctrl.data.id, this.dataset.variant as VariantKey); dlg.close(); }); - dlg.showModal(); + dlg.show(); }); }) : {}, diff --git a/ui/tournament/src/view/battle.ts b/ui/tournament/src/view/battle.ts index 9e28afd9cb8b..bf9261ad54b4 100644 --- a/ui/tournament/src/view/battle.ts +++ b/ui/tournament/src/view/battle.ts @@ -13,12 +13,13 @@ export function joinWithTeamSelector(ctrl: TournamentController) { }; return snabDialog({ class: 'team-battle__choice', + modal: true, onInsert(dlg) { $('.team-picker__team', dlg.view).on('click', e => { ctrl.join(e.target.dataset['id']); dlg.close(); }); - dlg.showModal(); + dlg.show(); }, onClose, vnodes: [ diff --git a/ui/voice/src/view.ts b/ui/voice/src/view.ts index 056119daca4d..6be32fbb4270 100644 --- a/ui/voice/src/view.ts +++ b/ui/voice/src/view.ts @@ -150,7 +150,7 @@ function renderHelpModal(ctrl: VoiceCtrl) { } html += ''; dlg.view.innerHTML = html; - if (!dlg.open) dlg.showModal(); + if (!dlg.open) dlg.show(); }; return snabDialog({ @@ -158,6 +158,7 @@ function renderHelpModal(ctrl: VoiceCtrl) { htmlUrl: `/help/voice/${ctrl.moduleId}`, css: [{ hashed: 'voice.move.help' }], onClose: () => ctrl.showHelp(false), + modal: true, onInsert: async dlg => { if (ctrl.showHelp() === 'list') { showMoveList(dlg); @@ -181,7 +182,7 @@ function renderHelpModal(ctrl: VoiceCtrl) { .join(' '); }); $('.all-phrases-button', dlg.view).on('click', () => showMoveList(dlg)); - dlg.showModal(); + dlg.show(); }, }); }