summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-24 12:49:10 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-24 12:49:10 +0300
commit8400f0e4c0d0dc8253fbf1efcd7459c218a6886c (patch)
tree4ea28b3c5080c5cd34189b65289d0aca47c64e13 /ext
parente034ca3ad4f88282e8dfec27df5cb7c55e0a47c6 (diff)
Anki: use CSS classes for term frequency color
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/handlebars.js13
-rw-r--r--ext/bg/js/options.js13
2 files changed, 11 insertions, 15 deletions
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index 72908cab..66d5fa2b 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -75,18 +75,6 @@ function handlebarsMultiLine(options) {
return options.fn(this).split('\n').join('<br>');
}
-function handlebarsTermFrequencyColor(options) {
- const termFrequency = options.fn(this);
-
- if (termFrequency === 'popular') {
- return '#0275d8';
- } else if (termFrequency === 'rare') {
- return '#999';
- } else {
- return 'inherit';
- }
-}
-
function handlebarsRegisterHelpers() {
if (Handlebars.partials !== Handlebars.templates) {
Handlebars.partials = Handlebars.templates;
@@ -95,7 +83,6 @@ function handlebarsRegisterHelpers() {
Handlebars.registerHelper('furiganaPlain', handlebarsFuriganaPlain);
Handlebars.registerHelper('kanjiLinks', handlebarsKanjiLinks);
Handlebars.registerHelper('multiLine', handlebarsMultiLine);
- Handlebars.registerHelper('termFrequencyColor', handlebarsTermFrequencyColor);
}
}
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 87609fcb..2cb7dbec 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -19,6 +19,15 @@
function optionsFieldTemplates() {
return `
+<style>
+.expression-popular {
+ color: #0275d8;
+}
+
+.expression-rare {
+ color: #999;
+}
+</style>
{{#*inline "glossary-single"}}
{{~#unless brief~}}
{{~#if definitionTags~}}<i>({{#each definitionTags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})</i> {{/if~}}
@@ -79,7 +88,7 @@ function optionsFieldTemplates() {
{{#*inline "furigana"}}
{{~#if merge~}}
{{~#each definition.expressions~}}
- <span style="color: {{#termFrequencyColor}}{{termFrequency}}{{/termFrequencyColor}}">{{~#furigana}}{{{.}}}{{/furigana~}}</span>
+ <span class="expression-{{termFrequency}}">{{~#furigana}}{{{.}}}{{/furigana~}}</span>
{{~#unless @last}}、{{/unless~}}
{{~/each~}}
{{~else~}}
@@ -90,7 +99,7 @@ function optionsFieldTemplates() {
{{#*inline "furigana-plain"}}
{{~#if merge~}}
{{~#each definition.expressions~}}
- <span style="color: {{#termFrequencyColor}}{{termFrequency}}{{/termFrequencyColor}}">{{~#furiganaPlain}}{{{.}}}{{/furiganaPlain~}}</span>
+ <span class="expression-{{termFrequency}}">{{~#furiganaPlain}}{{{.}}}{{/furiganaPlain~}}</span>
{{~#unless @last}}、{{/unless~}}
{{~/each~}}
{{~else~}}