aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-29 19:52:51 -0400
committerGitHub <noreply@github.com>2020-05-29 19:52:51 -0400
commit5f9889fd26f38396aa6ffaa5c669081b02467393 (patch)
tree6f8991ee47439830ae0f7a33f8c5440c12c971c2 /ext/bg/js/settings/main.js
parentfde0072118128ea698e15472c9b61b17b4827c8a (diff)
Anki settings controllers (#567)
* Convert anki-templates.js to a class * Convert anki.js to a class
Diffstat (limited to 'ext/bg/js/settings/main.js')
-rw-r--r--ext/bg/js/settings/main.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 64611ad5..872f8f05 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -16,17 +16,15 @@
*/
/* global
+ * AnkiController
+ * AnkiTemplatesController
* ProfileController
* SettingsBackup
* SettingsController
- * ankiInitialize
- * ankiTemplatesInitialize
- * ankiTemplatesUpdateValue
* api
* appearanceInitialize
* audioSettingsInitialize
* dictSettingsInitialize
- * onAnkiOptionsChanged
* onDictionaryOptionsChanged
* storageInfoInitialize
* utilBackend
@@ -269,9 +267,13 @@ async function onOptionsUpdated({source}) {
const options = await getOptionsMutable(optionsContext);
document.querySelector('#enable-clipboard-popups').checked = options.general.enableClipboardPopups;
- ankiTemplatesUpdateValue();
+ if (ankiTemplatesController !== null) {
+ ankiTemplatesController.updateValue();
+ }
onDictionaryOptionsChanged();
- onAnkiOptionsChanged();
+ if (ankiController !== null) {
+ ankiController.optionsChanged();
+ }
await formWrite(options);
}
@@ -302,6 +304,8 @@ async function settingsPopulateModifierKeys() {
}
}
+let ankiController = null;
+let ankiTemplatesController = null;
async function onReady() {
api.forwardLogsToBackend();
@@ -318,8 +322,10 @@ async function onReady() {
await audioSettingsInitialize();
await (new ProfileController()).prepare();
await dictSettingsInitialize();
- ankiInitialize();
- ankiTemplatesInitialize();
+ ankiController = new AnkiController();
+ ankiController.prepare();
+ ankiTemplatesController = new AnkiTemplatesController(ankiController);
+ ankiTemplatesController.prepare();
new SettingsBackup().prepare();
storageInfoInitialize();