From 8893db14caa6d34117dcb7e38ec1af32baa89b95 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 15 Mar 2017 21:13:58 -0700 Subject: wip --- ext/bg/js/templates.js | 2 +- ext/fg/js/display-frame.js | 2 -- ext/fg/js/popup.js | 4 ++-- ext/mixed/js/display.js | 23 +++++++++++++++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) (limited to 'ext') 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 : "") + " \n\n
\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 : "") - + "
\n

\n"; + + " \n\n Back\n

\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)); } -- cgit v1.2.3