From 92e9f69c8069644c544301a51fbbd351e799e99d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 25 Nov 2020 23:22:05 -0500 Subject: Popup style updates (#1066) * Replace compactGlossaries option with new glossaryLayoutMode option * Update attributes * Update attributes * Update color definitions * Fix default theme scrollbar --- ext/bg/data/options-schema.json | 9 +++---- ext/bg/js/anki-note-builder.js | 9 +++---- ext/bg/js/options.js | 3 +++ ext/bg/js/settings/anki-templates-controller.js | 4 ++-- ext/bg/search.html | 2 +- ext/bg/settings.html | 31 +++++++++++++++---------- 6 files changed, 35 insertions(+), 23 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index edb30074..2da48041 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -94,7 +94,7 @@ "popupScaleRelativeToVisualViewport", "showGuide", "compactTags", - "compactGlossaries", + "glossaryLayoutMode", "mainDictionary", "popupTheme", "popupOuterTheme", @@ -198,9 +198,10 @@ "type": "boolean", "default": false }, - "compactGlossaries": { - "type": "boolean", - "default": false + "glossaryLayoutMode": { + "type": "string", + "enum": ["default", "compact"], + "default": "default" }, "mainDictionary": { "type": "string" diff --git a/ext/bg/js/anki-note-builder.js b/ext/bg/js/anki-note-builder.js index d1e918c9..33cd3a0b 100644 --- a/ext/bg/js/anki-note-builder.js +++ b/ext/bg/js/anki-note-builder.js @@ -34,7 +34,7 @@ class AnkiNoteBuilder { checkForDuplicates=true, duplicateScope='collection', resultOutputMode='split', - compactGlossaries=false, + glossaryLayoutMode='default', compactTags=false, modeOptions: {fields, deck, model}, audioDetails=null, @@ -71,7 +71,7 @@ class AnkiNoteBuilder { } }; - const data = this._createNoteData(definition, mode, context, resultOutputMode, compactGlossaries, compactTags); + const data = this._createNoteData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags); const formattedFieldValuePromises = []; for (const [, fieldValue] of fieldEntries) { const formattedFieldValuePromise = this._formatField(fieldValue, data, templates, errors); @@ -105,7 +105,7 @@ class AnkiNoteBuilder { // Private - _createNoteData(definition, mode, context, resultOutputMode, compactGlossaries, compactTags) { + _createNoteData(definition, mode, context, resultOutputMode, glossaryLayoutMode, compactTags) { const pitches = DictionaryDataUtil.getPitchAccentInfos(definition); const pitchCount = pitches.reduce((i, v) => i + v.pitches.length, 0); return { @@ -118,7 +118,8 @@ class AnkiNoteBuilder { modeTermKanji: mode === 'term-kanji', modeTermKana: mode === 'term-kana', modeKanji: mode === 'kanji', - compactGlossaries, + compactGlossaries: (glossaryLayoutMode === 'compact'), + glossaryLayoutMode, compactTags, context }; diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index e4f6c8e4..dcc8471a 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -614,10 +614,13 @@ class OptionsUtil { // Updated handlebars templates to include "conjugation" definition. // Added global option showPopupPreview. // Added anki.checkForDuplicates. + // Added general.glossaryLayoutMode; removed general.compactGlossaries. await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v6.handlebars'); options.global.showPopupPreview = false; for (const profile of options.profiles) { profile.options.anki.checkForDuplicates = true; + profile.options.general.glossaryLayoutMode = (profile.options.general.compactGlossaries ? 'compact' : 'default'); + delete profile.options.general.compactGlossaries; const fieldTemplates = profile.options.anki.fieldTemplates; if (typeof fieldTemplates === 'string') { profile.options.anki.fieldTemplates = this._updateVersion6AnkiTemplatesCompactTags(fieldTemplates); diff --git a/ext/bg/js/settings/anki-templates-controller.js b/ext/bg/js/settings/anki-templates-controller.js index 35a08476..3ac4fa9e 100644 --- a/ext/bg/js/settings/anki-templates-controller.js +++ b/ext/bg/js/settings/anki-templates-controller.js @@ -184,14 +184,14 @@ class AnkiTemplatesController { const ankiNoteBuilder = new AnkiNoteBuilder({ renderTemplate: this._renderTemplate.bind(this) }); - const {general: {resultOutputMode, compactGlossaries, compactTags}} = options; + const {general: {resultOutputMode, glossaryLayoutMode, compactTags}} = options; const note = await ankiNoteBuilder.createNote({ definition, mode, context, templates, resultOutputMode, - compactGlossaries, + glossaryLayoutMode, compactTags, modeOptions: { fields: {field}, diff --git a/ext/bg/search.html b/ext/bg/search.html index 3588d871..c0f98d8c 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -1,5 +1,5 @@ - + diff --git a/ext/bg/settings.html b/ext/bg/settings.html index d3b13354..5083a6bc 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -144,10 +144,6 @@ -
- -
-
@@ -205,14 +201,6 @@ -
- - -
-
@@ -284,6 +272,25 @@
+
+
+
+ + +
+
+ + +
+
+
+
-- cgit v1.2.3