This commit is contained in:
Alex Yatskov 2017-03-17 20:45:47 -07:00
parent 231b471f45
commit 1dbcb35eb7
4 changed files with 29 additions and 22 deletions

View File

@ -284,7 +284,7 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti
templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data) { templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : {}; var stack1, helper, alias1=depth0 != null ? depth0 : {};
return "<p>\n <div class=\"actions\">\n" return "<div class=\"entry\">\n <div class=\"actions\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n\n <div class=\"glyph\">" + " </div>\n\n <div class=\"glyph\">"
+ container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper))) + container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper)))
@ -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 : "") + ((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" + " </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 : "") + ((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\n <a href=\"#\" class=\"term-source\">Back</a>\n</p>\n"; + " </div>\n\n <a href=\"#\" class=\"term-source\">Back</a>\n</div>\n";
},"2":function(container,depth0,helpers,partials,data) { },"2":function(container,depth0,helpers,partials,data) {
var helper; var helper;
@ -444,7 +444,7 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
},"12":function(container,depth0,helpers,partials,data) { },"12":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : {}; var stack1, alias1=depth0 != null ? depth0 : {};
return "<p>\n <div class=\"actions\">\n" return "<div class=\"entry\">\n <div class=\"actions\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </div>\n\n" + " </div>\n\n"
@ -453,7 +453,7 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <div class=\"glossary\">\n" + "\n <div class=\"glossary\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(26, data, 0),"inverse":container.program(32, data, 0),"data":data})) != null ? stack1 : "") + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(26, data, 0),"inverse":container.program(32, data, 0),"data":data})) != null ? stack1 : "")
+ " </div>\n</p>\n"; + " </div>\n</div>\n";
},"13":function(container,depth0,helpers,partials,data) { },"13":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

View File

@ -66,20 +66,29 @@ class Display {
this.spinner.hide(); this.spinner.hide();
this.templateRender('terms.html', params).then(content => { this.templateRender('terms.html', params).then(content => {
window.scrollTo(0, 0);
this.container.html(content); this.container.html(content);
if (context && context.hasOwnProperty('index') && context.index < definitions.length) {
const entry = $('.entry').eq(context.index);
window.scrollTo(0, entry.offset().top);
} else {
window.scrollTo(0, 0);
}
$('.action-add-note').click(this.onActionAddNote.bind(this)); $('.action-add-note').click(this.onActionAddNote.bind(this));
$('.action-play-audio').click(this.onActionPlayAudio.bind(this)); $('.action-play-audio').click(this.onActionPlayAudio.bind(this));
$('.kanji-link').click(e => { $('.kanji-link').click(e => {
e.preventDefault(); e.preventDefault();
const character = $(e.target).text();
this.kanjiFind(character).then(kanjiDefs => { const link = $(e.target);
this.showKanjiDefs( if (context) {
kanjiDefs, context.source = {
options, definitions,
{definitions, sentence: context.sentence, url: context.url} index: $('.entry').index(link.closest('.entry'))
); };
}
this.kanjiFind(link.text()).then(kanjiDefs => {
this.showKanjiDefs(kanjiDefs, options, context);
}).catch(this.handleError.bind(this)); }).catch(this.handleError.bind(this));
}); });
@ -111,12 +120,10 @@ class Display {
$('.action-add-note').click(this.onActionAddNote.bind(this)); $('.action-add-note').click(this.onActionAddNote.bind(this));
$('.term-source').click(e => { $('.term-source').click(e => {
e.preventDefault(); e.preventDefault();
if (context.definitions) {
this.showTermDefs( if (context && context.source) {
context.definitions, context.index = context.source.index;
options, this.showTermDefs(context.source.definitions, options, context);
{sentence: context.sentence, url: context.url}
);
} }
}); });

View File

@ -1,5 +1,5 @@
{{#*inline "kanji"}} {{#*inline "kanji"}}
<p> <div class="entry">
<div class="actions"> <div class="actions">
{{#if addable}} {{#if addable}}
<a href="#" title="Add Kanji" class="action-add-note pending disabled" data-mode="kanji" data-index="{{@index}}"><img src="/mixed/img/add-kanji.png"></a> <a href="#" title="Add Kanji" class="action-add-note pending disabled" data-mode="kanji" data-index="{{@index}}"><img src="/mixed/img/add-kanji.png"></a>
@ -48,7 +48,7 @@
</div> </div>
<a href="#" class="term-source">Back</a> <a href="#" class="term-source">Back</a>
</p> </div>
{{/inline}} {{/inline}}
{{#if definitions}} {{#if definitions}}

View File

@ -18,7 +18,7 @@
{{/inline}} {{/inline}}
{{#*inline "term"}} {{#*inline "term"}}
<p> <div class="entry">
<div class="actions"> <div class="actions">
{{#if addable}} {{#if addable}}
<a href="#" title="Add term as expression" class="action-add-note pending disabled" data-mode="term-kanji" data-index="{{@index}}"><img src="/mixed/img/add-term-kanji.png"></a> <a href="#" title="Add term as expression" class="action-add-note pending disabled" data-mode="term-kanji" data-index="{{@index}}"><img src="/mixed/img/add-term-kanji.png"></a>
@ -58,7 +58,7 @@
{{> definition}} {{> definition}}
{{/if}} {{/if}}
</div> </div>
</p> </div>
{{/inline}} {{/inline}}
{{#if definitions}} {{#if definitions}}