Splitting out header and footer templates

This commit is contained in:
Alex Yatskov 2016-04-17 18:20:39 -07:00
parent f079db0471
commit 6f45cc2871
7 changed files with 67 additions and 15 deletions

View File

@ -1,22 +1,19 @@
(function() { (function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['defs.html'] = template({"1":function(container,depth0,helpers,partials,data) { templates['footer.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1; var helper;
return " <div class=\"definition\">\n" return " <script src=\""
+ ((stack1 = container.invokePartial(partials["term.html"],depth0,{"name":"term.html","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + container.escapeExpression(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"root","hash":{},"data":data}) : helper)))
+ " </div>\n"; + "/js/popup.js\"></script>\n </body>\n</html>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { },"useData":true});
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; templates['header.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
return "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title></title>\n <link rel=\"stylesheet\" href=\"" return "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title></title>\n <link rel=\"stylesheet\" href=\""
+ alias4(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"root","hash":{},"data":data}) : helper))) + container.escapeExpression(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"root","hash":{},"data":data}) : helper)))
+ "/css/popup.css\">\n </head>\n <body>\n <div class=\"dictionary\">\n <a href=\"javascript:setActiveDict('edict');\">単</a><a href=\"javascript:setActiveDict('enamdict')\">名</a><a href=\"javascript:setActiveDict('kanjidic');\">漢</a>\n </div>\n\n" + "/css/popup.css\">\n </head>\n <body>\n <div class=\"dictionary\">\n <a href=\"javascript:setActiveDict('edict');\">単</a><a href=\"javascript:setActiveDict('enamdict')\">名</a><a href=\"javascript:setActiveDict('kanjidic');\">漢</a>\n </div>\n";
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") },"useData":true});
+ "\n <script src=\""
+ alias4(((helper = (helper = helpers.root || (depth0 != null ? depth0.root : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"root","hash":{},"data":data}) : helper)))
+ "/js/popup.js\"></script>\n </body>\n</html>\n";
},"usePartial":true,"useData":true});
templates['term.html'] = template({"1":function(container,depth0,helpers,partials,data) { templates['term.html'] = template({"1":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;
@ -73,4 +70,17 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </ol>\n</div>\n"; + " </ol>\n</div>\n";
},"useData":true}); },"useData":true});
templates['term-list.html'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
return "<div class=\"definition\">\n"
+ ((stack1 = container.invokePartial(partials["term.html"],depth0,{"name":"term.html","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
+ "</div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = container.invokePartial(partials["header.html"],depth0,{"name":"header.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = container.invokePartial(partials["footer.html"],depth0,{"name":"footer.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"usePartial":true,"useData":true});
})(); })();

21
ext/fg/header.html Normal file
View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="{{root}}/css/popup.css">
</head>
<body>
<div class="dictionary">
<a href="javascript:setActiveDict('edict');"></a><a href="javascript:setActiveDict('enamdict')"></a><a href="javascript:setActiveDict('kanjidic');"></a>
</div>
{{#each defs}}
<div class="definition">
{{> term.html}}
</div>
{{/each}}
<script src="{{root}}/js/popup.js"></script>
</body>
</html>

View File

@ -119,7 +119,7 @@ class Client {
this.hidePopup(); this.hidePopup();
} else { } else {
const params = {defs: results, root: chrome.extension.getURL('fg'), activeDict: this.activeDict}; const params = {defs: results, root: chrome.extension.getURL('fg'), activeDict: this.activeDict};
renderText(params, 'defs.html', (html) => this.showPopup(range, html, popupQuery, length)); renderText(params, 'term-list.html', (html) => this.showPopup(range, html, popupQuery, length));
} }
}); });
} }

3
util/tmpl/footer.html Normal file
View File

@ -0,0 +1,3 @@
<script src="{{root}}/js/popup.js"></script>
</body>
</html>

11
util/tmpl/header.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="{{root}}/css/popup.css">
</head>
<body>
<div class="dictionary">
<a href="javascript:setActiveDict('edict');"></a><a href="javascript:setActiveDict('enamdict')"></a><a href="javascript:setActiveDict('kanjidic');"></a>
</div>

7
util/tmpl/term-list.html Normal file
View File

@ -0,0 +1,7 @@
{{> header.html}}
{{#each defs}}
<div class="definition">
{{> term.html}}
</div>
{{/each}}
{{> footer.html}}