summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/templates.js2
-rw-r--r--ext/fg/js/display-frame.js2
-rw-r--r--ext/fg/js/popup.js4
-rw-r--r--ext/mixed/js/display.js23
4 files changed, 24 insertions, 7 deletions
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index 2a8bf5b3..ebff387b 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -296,7 +296,7 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n\n <div class=\"glossary\">\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(13, data, 0),"data":data})) != null ? stack1 : "")
- + " </div>\n</p>\n";
+ + " </div>\n\n <a href=\"#\" class=\"term-source\">Back</a>\n</p>\n";
},"2":function(container,depth0,helpers,partials,data) {
var helper;
diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js
index bc2e15df..8f15b1bc 100644
--- a/ext/fg/js/display-frame.js
+++ b/ext/fg/js/display-frame.js
@@ -55,12 +55,10 @@ window.displayFrame = new class extends Display {
onMessage(e) {
const handlers = new class {
api_showTermDefs({definitions, options, context}) {
- window.scrollTo(0, 0);
this.showTermDefs(definitions, options, context);
}
api_showKanjiDefs({definitions, options, context}) {
- window.scrollTo(0, 0);
this.showKanjiDefs(definitions, options, context);
}
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 7da75446..210a3688 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -24,8 +24,8 @@ class Popup {
this.container.addEventListener('mousedown', e => e.stopPropagation());
this.container.addEventListener('scroll', e => e.stopPropagation());
this.container.setAttribute('src', chrome.extension.getURL('/fg/frame.html'));
- this.container.style.width='0px';
- this.container.style.height='0px';
+ this.container.style.width = '0px';
+ this.container.style.height = '0px';
this.injected = false;
}
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 1de65f22..cab2cfea 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -66,14 +66,20 @@ class Display {
this.spinner.hide();
this.templateRender('terms.html', params).then(content => {
+ window.scrollTo(0, 0);
this.container.html(content);
+
$('.action-add-note').click(this.onActionAddNote.bind(this));
$('.action-play-audio').click(this.onActionPlayAudio.bind(this));
$('.kanji-link').click(e => {
e.preventDefault();
const character = $(e.target).text();
- this.kanjiFind(character).then(definitions => {
- this.showKanjiDefs(definitions, options, context);
+ this.kanjiFind(character).then(kanjiDefs => {
+ this.showKanjiDefs(
+ kanjiDefs,
+ options,
+ {definitions, sentence: context.sentence, url: context.url}
+ );
}).catch(this.handleError.bind(this));
});
@@ -99,8 +105,21 @@ class Display {
this.spinner.hide();
this.templateRender('kanji.html', params).then(content => {
+ window.scrollTo(0, 0);
this.container.html(content);
+
$('.action-add-note').click(this.onActionAddNote.bind(this));
+ $('.term-source').click(e => {
+ e.preventDefault();
+ if (context.definitions) {
+ this.showTermDefs(
+ context.definitions,
+ options,
+ {sentence: context.sentence, url: context.url}
+ );
+ }
+ });
+
return this.adderButtonsUpdate(['kanji'], sequence);
}).catch(this.handleError.bind(this));
}