summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-19 08:52:22 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-19 08:52:22 -0700
commit7d93587acb250266782e3788894a9e26ddf1eaa5 (patch)
treed33165811c5f80d4a9d5ab956bba4073ebf919fa /ext/fg/js
parenta4a67be455aa8ac75efbee6183225fb8d70346d8 (diff)
Conditionally show add buttons
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/driver.js40
1 files changed, 35 insertions, 5 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js
index 1be69f11..75dbe219 100644
--- a/ext/fg/js/driver.js
+++ b/ext/fg/js/driver.js
@@ -139,14 +139,25 @@ class Driver {
});
const sequence = ++this.sequence;
- return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'term-list.html').then(content => {
+ const context = {
+ definitions,
+ sequence,
+ addable: this.options.ankiMethod !== 'disabled',
+ root: this.fgRoot,
+ options: this.options
+ };
+
+ return renderText(context, 'term-list.html').then(content => {
this.definitions = definitions;
this.pendingLookup = false;
this.showPopup(textSource, content);
return canAddDefinitions(definitions, ['term_kanji', 'term_kana']);
}).then(states => {
if (states !== null) {
- states.forEach((state, index) => this.popup.invokeApi('setActionState', {index, state, sequence}));
+ states.forEach((state, index) => this.popup.invokeApi(
+ 'setActionState',
+ {index, state, sequence}
+ ));
}
return true;
@@ -167,14 +178,25 @@ class Driver {
definitions.forEach(definition => definition.url = window.location.href);
const sequence = ++this.sequence;
- return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'kanji-list.html').then(content => {
+ const context = {
+ definitions,
+ sequence,
+ addable: this.options.ankiMethod !== 'disabled',
+ root: this.fgRoot,
+ options: this.options
+ };
+
+ return renderText(context, 'kanji-list.html').then(content => {
this.definitions = definitions;
this.pendingLookup = false;
this.showPopup(textSource, content);
return canAddDefinitions(definitions, ['kanji']);
}).then(states => {
if (states !== null) {
- states.forEach((state, index) => this.popup.invokeApi('setActionState', {index, state, sequence}));
+ states.forEach((state, index) => this.popup.invokeApi(
+ 'setActionState',
+ {index, state, sequence}
+ ));
}
return true;
@@ -278,7 +300,15 @@ class Driver {
definitions.forEach(definition => definition.url = window.location.href);
const sequence = ++this.sequence;
- return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'kanji-list.html').then(content => {
+ const context = {
+ definitions,
+ sequence,
+ addable: this.options.ankiMethod !== 'disabled',
+ root: this.fgRoot,
+ options: this.options
+ };
+
+ return renderText(context, 'kanji-list.html').then(content => {
this.definitions = definitions;
this.popup.setContent(content, definitions);
return canAddDefinitions(definitions, ['kanji']);