Skip to content

Commit 8dcbb4f

Browse files
committed
Add actions for locale and speechRules, as requested by Volker.
1 parent cc7ce06 commit 8dcbb4f

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

ts/a11y/explorer.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -524,19 +524,6 @@ export function setA11yOption(document: HTMLDOCUMENT, option: string, value: str
524524
break;
525525
}
526526
break;
527-
//
528-
// TODO(v3.2): These two cases should be handled directly in the menu
529-
// variable actions.
530-
//
531-
case 'speechRules':
532-
let [domain, style] = (value as string).split('-');
533-
document.options.sre.domain = domain;
534-
document.options.sre.style = style;
535-
break;
536-
case 'locale':
537-
document.options.sre.locale = value;
538-
SRE.setupEngine({locale: value as string});
539-
break;
540527
default:
541528
document.options.a11y[option] = value;
542529
}

ts/ui/menu/Menu.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,13 @@ export class Menu {
402402
this.variable<boolean>('semantics'),
403403
this.variable<string> ('zoom'),
404404
this.variable<string> ('zscale'),
405-
this.variable<string> ('renderer', (jax: string) => this.setRenderer(jax)),
405+
this.variable<string> ('renderer', (jax) => this.setRenderer(jax)),
406406
this.variable<boolean>('alt'),
407407
this.variable<boolean>('cmd'),
408408
this.variable<boolean>('ctrl'),
409409
this.variable<boolean>('shift'),
410-
this.variable<string> ('scale', (scale: string) => this.setScale(scale)),
411-
this.variable<boolean>('explorer', (explore: boolean) => this.setExplorer(explore)),
410+
this.variable<string> ('scale', (scale) => this.setScale(scale)),
411+
this.variable<boolean>('explorer', (explore) => this.setExplorer(explore)),
412412
this.a11yVar<string> ('highlight'),
413413
this.a11yVar<string> ('backgroundColor'),
414414
this.a11yVar<string> ('backgroundOpacity'),
@@ -418,18 +418,22 @@ export class Menu {
418418
this.a11yVar<boolean>('subtitles'),
419419
this.a11yVar<boolean>('braille'),
420420
this.a11yVar<boolean>('viewBraille'),
421-
this.a11yVar<string>('locale'),
422-
this.a11yVar<string> ('speechRules'),
421+
this.a11yVar<string>('locale', (value) => SRE.setupEngine({locale: value as string})),
422+
this.a11yVar<string> ('speechRules', (value) => {
423+
const [domain, style] = value.split('-');
424+
this.document.options.sre.domain = domain;
425+
this.document.options.sre.style = style;
426+
}),
423427
this.a11yVar<string> ('magnification'),
424428
this.a11yVar<string> ('magnify'),
425429
this.a11yVar<boolean>('treeColoring'),
426430
this.a11yVar<boolean>('infoType'),
427431
this.a11yVar<boolean>('infoRole'),
428432
this.a11yVar<boolean>('infoPrefix'),
429433
this.variable<boolean>('autocollapse'),
430-
this.variable<boolean>('collapsible', (collapse: boolean) => this.setCollapsible(collapse)),
431-
this.variable<boolean>('inTabOrder', (tab: boolean) => this.setTabOrder(tab)),
432-
this.variable<boolean>('assistiveMml', (mml: boolean) => this.setAssistiveMml(mml))
434+
this.variable<boolean>('collapsible', (collapse) => this.setCollapsible(collapse)),
435+
this.variable<boolean>('inTabOrder', (tab) => this.setTabOrder(tab)),
436+
this.variable<boolean>('assistiveMml', (mml) => this.setAssistiveMml(mml))
433437
],
434438
items: [
435439
this.submenu('Show', 'Show Math As', [
@@ -864,6 +868,7 @@ export class Menu {
864868
this.transferMathList(document);
865869
this.document.processed = document.processed;
866870
if (!Menu._loadingPromise) {
871+
this.document.outputJax.reset();
867872
this.rerender(component === 'complexity' || noEnrich ? STATE.COMPILED : STATE.TYPESET);
868873
}
869874
});
@@ -1044,7 +1049,7 @@ export class Menu {
10441049
*
10451050
* @tempate T The type of variable being defined
10461051
*/
1047-
public a11yVar<T extends (string | boolean)>(name: keyof MenuSettings): Object {
1052+
public a11yVar<T extends (string | boolean)>(name: keyof MenuSettings, action?: (value: T) => void): Object {
10481053
return {
10491054
name: name,
10501055
getter: () => this.getA11y(name),
@@ -1053,6 +1058,7 @@ export class Menu {
10531058
let options: {[key: string]: any} = {};
10541059
options[name] = value;
10551060
this.setA11y(options);
1061+
action && action(value);
10561062
this.saveUserSettings();
10571063
}
10581064
};

0 commit comments

Comments
 (0)