From da0cb81801ac897fa41761af0b0b18fda9d16195 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 8 Oct 2016 18:47:24 -0700 Subject: [PATCH] Allow bootstrap in popup templates --- ext/bg/js/templates.js | 20 ++++++++++++-------- ext/fg/js/driver.js | 8 ++++---- ext/manifest.json | 7 ++++++- tmpl/footer.html | 2 +- tmpl/header.html | 8 +++++--- tmpl/kanji.html | 2 +- tmpl/term.html | 6 +++--- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 1f9e3c30..75bf7be5 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -5,18 +5,22 @@ templates['footer.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(c return " \n \n\n"; + + "/fg/js/frame.js\">\n \n\n"; },"useData":true}); templates['header.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return "\n\n \n \n \n \n \n \n \n \n"; + + "/lib/bootstrap-3.3.6-dist/css/bootstrap.min.css\">\n \n \n \n \n"; },"useData":true}); templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; @@ -33,7 +37,7 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + alias1(((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"; + + "/fg/img/add_kanji.png\">\n"; },"4":function(container,depth0,helpers,partials,data) { var stack1; @@ -108,7 +112,7 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial + alias1(((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"; + + "/fg/img/play_audio.png\">\n"; },"4":function(container,depth0,helpers,partials,data,blockParams,depths) { var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, alias5=container.lambda; @@ -116,11 +120,11 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial + alias4(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"index","hash":{},"data":data}) : helper))) + "\">\n \n \n"; + + "/fg/img/add_term_kana.png\">\n"; },"6":function(container,depth0,helpers,partials,data) { var stack1, helper, options, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", buffer = "
"; diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 1e817c1c..79a3eb9f 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -29,7 +29,7 @@ class Driver { this.options = null; this.definitions = null; this.sequence = 0; - this.fgRoot = chrome.extension.getURL('fg'); + this.extRoot = chrome.extension.getURL('.'); chrome.runtime.onMessage.addListener(this.onBgMessage.bind(this)); window.addEventListener('message', this.onFrameMessage.bind(this)); @@ -139,7 +139,7 @@ class Driver { }); const sequence = ++this.sequence; - return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'term-list.html').then(content => { + return renderText({definitions, sequence, root: this.extRoot, options: this.options}, 'term-list.html').then(content => { this.definitions = definitions; this.pendingLookup = false; this.showPopup(textSource, content); @@ -167,7 +167,7 @@ class Driver { definitions.forEach(definition => definition.url = window.location.href); const sequence = ++this.sequence; - return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'kanji-list.html').then(content => { + return renderText({definitions, sequence, root: this.extRoot, options: this.options}, 'kanji-list.html').then(content => { this.definitions = definitions; this.pendingLookup = false; this.showPopup(textSource, content); @@ -278,7 +278,7 @@ class Driver { definitions.forEach(definition => definition.url = window.location.href); const sequence = ++this.sequence; - return renderText({definitions, sequence, root: this.fgRoot, options: this.options}, 'kanji-list.html').then(content => { + return renderText({definitions, sequence, root: this.extRoot, options: this.options}, 'kanji-list.html').then(content => { this.definitions = definitions; this.popup.setContent(content, definitions); return canAddDefinitions(definitions, ['kanji']); diff --git a/ext/manifest.json b/ext/manifest.json index 02cfd6d8..dc766795 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -33,6 +33,11 @@ "fg/img/play_audio.png", "fg/js/frame.js", "fg/ttf/kanji-stroke-orders.ttf", - "fg/ttf/vl-gothic-regular.ttf" + "fg/ttf/vl-gothic-regular.ttf", + "lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css", + "lib/bootstrap-3.3.6-dist/css/bootstrap.min.css", + "lib/bootstrap-3.3.6-dist/fonts/glyphicons-halflings-regular.ttf", + "lib/bootstrap-3.3.6-dist/fonts/glyphicons-halflings-regular.woff", + "lib/bootstrap-3.3.6-dist/fonts/glyphicons-halflings-regular.woff2" ] } diff --git a/tmpl/footer.html b/tmpl/footer.html index 3840600f..2cb496c9 100644 --- a/tmpl/footer.html +++ b/tmpl/footer.html @@ -1,3 +1,3 @@ - + diff --git a/tmpl/header.html b/tmpl/header.html index b7fad070..e5ecb06e 100644 --- a/tmpl/header.html +++ b/tmpl/header.html @@ -6,13 +6,15 @@ - + + + diff --git a/tmpl/kanji.html b/tmpl/kanji.html index 0a0cfe11..80c642bd 100644 --- a/tmpl/kanji.html +++ b/tmpl/kanji.html @@ -2,7 +2,7 @@ {{#with options}}
{{#if enableAnkiConnect}} - + {{/if}}
{{/with}} diff --git a/tmpl/term.html b/tmpl/term.html index aff3e2ff..65278145 100644 --- a/tmpl/term.html +++ b/tmpl/term.html @@ -2,11 +2,11 @@ {{#with options}}
{{#if enableAudioPlayback}} - + {{/if}} {{#if enableAnkiConnect}} - - + + {{/if}}
{{/with}}