diff --git a/src/public/app/widgets/type_widgets/options/appearance/fonts.js b/src/public/app/widgets/type_widgets/options/appearance/fonts.ts similarity index 87% rename from src/public/app/widgets/type_widgets/options/appearance/fonts.js rename to src/public/app/widgets/type_widgets/options/appearance/fonts.ts index 427ec9991..ea8d00d4b 100644 --- a/src/public/app/widgets/type_widgets/options/appearance/fonts.js +++ b/src/public/app/widgets/type_widgets/options/appearance/fonts.ts @@ -1,6 +1,7 @@ import OptionsWidget from "../options_widget.js"; import utils from "../../../../services/utils.js"; import { t } from "../../../../services/i18n.js"; +import { OptionMap, OptionNames } from "../../../../../../services/options_interface.js"; const FONT_FAMILIES = [ { value: "theme", label: t("fonts.theme_defined") }, @@ -31,15 +32,15 @@ const FONT_FAMILIES = [ const TPL = `

${t("fonts.fonts")}

- +
${t("fonts.main_font")}
- +
- +
@@ -57,7 +58,7 @@ const TPL = `
- +
@@ -67,15 +68,15 @@ const TPL = `
- +
${t("fonts.note_detail_font")}
- +
- +
@@ -85,15 +86,15 @@ const TPL = `
- +
${t("fonts.monospace_font")}
- +
- +
@@ -107,7 +108,7 @@ const TPL = `

${t("fonts.note_tree_and_detail_font_sizing")}

${t("fonts.not_all_fonts_available")}

- +

${t("fonts.apply_font_changes")} @@ -115,6 +116,18 @@ const TPL = `

`; export default class FontsOptions extends OptionsWidget { + + private $mainFontSize!: JQuery; + private $mainFontFamily!: JQuery; + private $treeFontSize!: JQuery; + private $treeFontFamily!: JQuery; + private $detailFontSize!: JQuery; + private $detailFontFamily!: JQuery; + private $monospaceFontSize!: JQuery; + private $monospaceFontFamily!: JQuery; + + private _isEnabled?: boolean; + doRender() { this.$widget = $(TPL); @@ -134,10 +147,10 @@ export default class FontsOptions extends OptionsWidget { } isEnabled() { - return this._isEnabled; + return !!this._isEnabled; } - async optionsLoaded(options) { + async optionsLoaded(options: OptionMap) { this._isEnabled = (options.overrideThemeFonts === 'true'); this.toggleInt(this._isEnabled); if (!this._isEnabled) { @@ -156,7 +169,7 @@ export default class FontsOptions extends OptionsWidget { this.$monospaceFontSize.val(options.monospaceFontSize); this.fillFontFamilyOptions(this.$monospaceFontFamily, options.monospaceFontFamily); - const optionsToSave = [ + const optionsToSave: OptionNames[] = [ 'mainFontFamily', 'mainFontSize', 'treeFontFamily', 'treeFontSize', 'detailFontFamily', 'detailFontSize', @@ -164,12 +177,13 @@ export default class FontsOptions extends OptionsWidget { ]; for (const optionName of optionsToSave) { - this[`$${optionName}`].on('change', () => - this.updateOption(optionName, this[`$${optionName}`].val())); + const $el = (this as any)[`$${optionName}`]; + $el.on('change', () => + this.updateOption(optionName, $el.val())); } } - fillFontFamilyOptions($select, currentValue) { + fillFontFamilyOptions($select: JQuery, currentValue: string) { $select.empty(); for (const {value, label} of FONT_FAMILIES) {