Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions ts/a11y/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,30 @@ export function ExplorerMathDocumentMixin<

'mjx-help-sizer': {
position: 'fixed',
width: '40%',
width: '45%',
'max-width': '30em',
top: '3em',
left: '50%',
},
'mjx-help-dialog': {
'mjx-help-sizer > .mjx-help-dialog': {
position: 'absolute',
width: '200%',
left: '-100%',
'max-width': 'initial',
},
'.mjx-help-dialog': {
'max-width': 'calc(min(60em, 90%))',
border: '3px outset',
'border-radius': '15px',
color: 'black',
'background-color': '#DDDDDD',
'z-index': '301',
'box-shadow': '0px 10px 20px #808080',
'text-align': 'right',
},
'.mjx-help-dialog::backdrop': {
opacity: 0.75,
},
'mjx-help-dialog': {
'font-style': 'normal',
'text-indent': 0,
'text-transform': 'none',
Expand All @@ -443,8 +452,6 @@ export function ExplorerMathDocumentMixin<
'word-spacing': 'normal',
'word-wrap': 'normal',
float: 'none',
'box-shadow': '0px 10px 20px #808080',
outline: 'none',
},
'mjx-help-dialog > h1': {
'font-size': '24px',
Expand All @@ -453,7 +460,7 @@ export function ExplorerMathDocumentMixin<
},
'mjx-help-dialog > div': {
margin: '0 1em',
padding: '3px',
padding: '3px 10px',
overflow: 'auto',
height: '20em',
border: '2px inset black',
Expand Down Expand Up @@ -488,6 +495,7 @@ export function ExplorerMathDocumentMixin<
left: 0,
right: 0,
bottom: 0,
'z-index': 1001,
},
};

Expand Down
67 changes: 43 additions & 24 deletions ts/a11y/explorer/KeyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,40 +933,59 @@ export class SpeechExplorer
* Displays the help dialog.
*/
protected help() {
const isDialog = !!window.HTMLDialogElement;
const adaptor = this.document.adaptor;
const helpBackground = adaptor.node('mjx-help-background');
const helpBackground = isDialog
? null
: adaptor.node('mjx-help-background');
const close = (event: Event) => {
helpBackground.remove();
if (isDialog) {
helpDialog.close();
helpDialog.remove();
} else {
helpBackground.remove();
}
this.node.focus();
this.stopEvent(event);
};
helpBackground.addEventListener('click', close);
const helpSizer = adaptor.node('mjx-help-sizer', {}, [
adaptor.node(
'mjx-help-dialog',
{ tabindex: 0, role: 'dialog', 'aria-labeledby': 'mjx-help-label' },
[
adaptor.node('h1', { id: 'mjx-help-label' }, [
adaptor.text('MathJax Expression Explorer Help'),
]),
adaptor.node('div'),
adaptor.node('input', { type: 'button', value: 'Close' }),
]
),
]);
helpBackground.append(helpSizer);
const help = helpSizer.firstChild as HTMLElement;
help.addEventListener('click', (event) => this.stopEvent(event));
const helpDialog = adaptor.node(
'dialog',
{ closedby: 'any', class: 'mjx-help-dialog' },
[
adaptor.node(
'mjx-help-dialog',
{ role: 'dialog', 'aria-labeledby': 'mjx-help-label' },
[
adaptor.node('h1', { id: 'mjx-help-label' }, [
adaptor.text('MathJax Expression Explorer Help'),
]),
adaptor.node('div'),
adaptor.node('input', { type: 'button', value: 'Close' }),
]
),
]
) as HTMLDialogElement;
const help = helpDialog.firstChild as HTMLElement;
const [title, select] = helpData.get(context.os);
(help.childNodes[1] as HTMLElement).innerHTML = helpMessage(title, select);
help.lastChild.addEventListener('click', close);
help.addEventListener('keydown', (event: KeyboardEvent) => {
helpDialog.addEventListener('keydown', (event: KeyboardEvent) => {
if (event.code === 'Escape') {
close(event);
}
});
const [title, select] = helpData.get(context.os);
(help.childNodes[1] as HTMLElement).innerHTML = helpMessage(title, select);
document.body.append(helpBackground);
help.focus();
if (isDialog) {
document.body.append(helpDialog);
helpDialog.showModal();
} else {
helpDialog.setAttribute('tabindex', '0');
help.addEventListener('click', (event) => this.stopEvent(event));
helpBackground.addEventListener('click', close);
const helpSizer = adaptor.node('mjx-help-sizer', {}, [helpDialog]);
helpBackground.append(helpSizer);
document.body.append(helpBackground);
}
helpDialog.focus();
}

/********************************************************************/
Expand Down