This commit is contained in:
Alex Yatskov 2017-03-15 21:13:58 -07:00
parent 8fb398aad8
commit 8893db14ca
5 changed files with 26 additions and 7 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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));
}

View File

@ -46,6 +46,8 @@
<div class="glossary-item">{{#multiLine}}{{glossary.[0]}}{{/multiLine}}</div>
{{/if}}
</div>
<a href="#" class="term-source">Back</a>
</p>
{{/inline}}