From a55b74c92ecb21fb688d4199811c43dd3eeb3451 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 17 Mar 2017 21:03:52 -0700 Subject: adding back link on kanji defs --- ext/bg/js/templates.js | 51 ++++++++++++++++++++++-------------------- ext/manifest.json | 13 +---------- ext/mixed/css/frame.css | 4 ++-- ext/mixed/img/source-term.png | Bin 0 -> 680 bytes ext/mixed/js/display.js | 3 ++- tmpl/kanji.html | 7 +++--- 6 files changed, 36 insertions(+), 42 deletions(-) create mode 100644 ext/mixed/img/source-term.png diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index fbdd2d11..a8e5c65f 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -286,17 +286,18 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia return "
\n
\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.source : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
\n\n
" + 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))) + "
\n\n
\n \n \n \n \n \n \n \n \n \n
Kunyomi:\n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
Onyomi:\n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
\n
\n\n
\n" - + ((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(9, 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 Back\n
\n"; + + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.program(15, data, 0),"data":data})) != null ? stack1 : "") + + " \n\n"; },"2":function(container,depth0,helpers,partials,data) { var helper; @@ -304,15 +305,17 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + container.escapeExpression(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"index","hash":{},"data":data}) : helper))) + "\">\n"; },"4":function(container,depth0,helpers,partials,data) { + return " \n"; +},"6":function(container,depth0,helpers,partials,data) { var stack1; return " " + container.escapeExpression(container.lambda(depth0, depth0)) - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n"; -},"5":function(container,depth0,helpers,partials,data) { - return ", "; },"7":function(container,depth0,helpers,partials,data) { + return ", "; +},"9":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " " + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + "\n"; -},"9":function(container,depth0,helpers,partials,data) { +},"11":function(container,depth0,helpers,partials,data) { var stack1; return "
    \n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
\n"; -},"10":function(container,depth0,helpers,partials,data) { +},"12":function(container,depth0,helpers,partials,data) { var stack1, helper, options, buffer = "
  • "; - stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper)); + stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper)); if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "
  • \n"; -},"11":function(container,depth0,helpers,partials,data) { - return container.escapeExpression(container.lambda(depth0, depth0)); },"13":function(container,depth0,helpers,partials,data) { + return container.escapeExpression(container.lambda(depth0, depth0)); +},"15":function(container,depth0,helpers,partials,data) { var stack1, helper, options, buffer = "
    "; - stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper)); + stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper)); if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "
    \n"; -},"14":function(container,depth0,helpers,partials,data) { +},"16":function(container,depth0,helpers,partials,data) { var stack1; return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["0"] : stack1), depth0)); -},"16":function(container,depth0,helpers,partials,data,blockParams,depths) { +},"18":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(17, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"17":function(container,depth0,helpers,partials,data,blockParams,depths) { + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(19, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"19":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return " " - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.first),{"name":"unless","hash":{},"fn":container.program(18, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.first),{"name":"unless","hash":{},"fn":container.program(20, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = container.invokePartial(partials.kanji,depth0,{"name":"kanji","hash":{"root":(depths[1] != null ? depths[1].root : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1])},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); -},"18":function(container,depth0,helpers,partials,data) { - return "
    "; + + ((stack1 = container.invokePartial(partials.kanji,depth0,{"name":"kanji","hash":{"root":(depths[1] != null ? depths[1].root : depths[1]),"source":(depths[1] != null ? depths[1].source : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1])},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); },"20":function(container,depth0,helpers,partials,data) { + return "
    "; +},"22":function(container,depth0,helpers,partials,data) { return "

    No results found.

    \n"; },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return "\n" - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(16, data, 0, blockParams, depths),"inverse":container.program(20, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(18, data, 0, blockParams, depths),"inverse":container.program(22, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); },"main_d": function(fn, props, container, depth0, data, blockParams, depths) { var decorators = container.decorators; diff --git a/ext/manifest.json b/ext/manifest.json index bb96ecc5..87dc3995 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -31,18 +31,7 @@ "", "storage" ], - "web_accessible_resources": [ - "fg/frame.html", - "fg/js/frame.js", - "mixed/css/frame.css", - "mixed/img/add-kanji.png", - "mixed/img/add-term-kana.png", - "mixed/img/add-term-kanji.png", - "mixed/img/play-audio.png", - "mixed/img/spinner.gif", - "mixed/mp3/button.mp3", - "mixed/ttf/kanji-stroke-orders.ttf" - ], + "web_accessible_resources": ["fg/frame.html"], "applications": { "gecko": { "id": "alex@foosoft.net", diff --git a/ext/mixed/css/frame.css b/ext/mixed/css/frame.css index e6a41aac..af689cbe 100644 --- a/ext/mixed/css/frame.css +++ b/ext/mixed/css/frame.css @@ -31,8 +31,8 @@ */ hr { - margin-top: 0.8em; - margin-bottom: 0.8em; + padding: 0px; + margin: 0px; } #spinner { diff --git a/ext/mixed/img/source-term.png b/ext/mixed/img/source-term.png new file mode 100644 index 00000000..2e53c698 Binary files /dev/null and b/ext/mixed/img/source-term.png differ diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 07a9f0c1..57c9b882 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -100,6 +100,7 @@ class Display { const sequence = ++this.sequence; const params = { definitions, + source: context && context.source, addable: options.anki.enable }; @@ -118,7 +119,7 @@ class Display { this.container.html(content); $('.action-add-note').click(this.onActionAddNote.bind(this)); - $('.term-source').click(e => { + $('.source-term').click(e => { e.preventDefault(); if (context && context.source) { diff --git a/tmpl/kanji.html b/tmpl/kanji.html index 00e4efd7..8f52eb4a 100644 --- a/tmpl/kanji.html +++ b/tmpl/kanji.html @@ -4,6 +4,9 @@ {{#if addable}} {{/if}} + {{#if source}} + + {{/if}}
    {{character}}
    @@ -46,15 +49,13 @@
    {{#multiLine}}{{glossary.[0]}}{{/multiLine}}
    {{/if}} - - Back {{/inline}} {{#if definitions}} {{#each definitions}} {{#unless @first}}
    {{/unless}} - {{> kanji addable=../addable root=../root}} + {{> kanji addable=../addable source=../source root=../root}} {{/each}} {{else}}

    No results found.

    -- cgit v1.2.3