summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/options.js20
-rw-r--r--ext/bg/js/templates.js10
-rw-r--r--tmpl/dictionary.html22
3 files changed, 36 insertions, 16 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 274f2e64..0720b9ac 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -54,7 +54,7 @@ function getFormData() {
$('.dict-group').each((index, element) => {
const dictionary = $(element);
const title = dictionary.data('title');
- const priority = parseInt(dictionary.find('.dict-priority').val(), 10);
+ const priority = parseFloat(dictionary.find('.dict-priority').val());
const enabled = dictionary.find('.dict-enabled').prop('checked');
optionsNew.dictionaries[title] = {priority, enabled};
});
@@ -147,8 +147,8 @@ function populateDictionaries(options) {
let dictCount = 0;
return instDb().getDictionaries().then(rows => {
rows.forEach(row => {
- const dictOptions = options.dictionaries[row.title] || {enableTerms: false, enableKanji: false, priority: 0};
- const html = handlebarsRender('dictionary.html', {
+ const dictOptions = options.dictionaries[row.title];
+ const dictHtml = handlebarsRender('dictionary.html', {
title: row.title,
version: row.version,
revision: row.revision,
@@ -156,13 +156,25 @@ function populateDictionaries(options) {
enabled: dictOptions.enabled
});
- dictGroups.append($(html));
+ dictGroups.append($(dictHtml));
++dictCount;
});
updateVisibility(options);
$('.dict-enabled, .dict-priority').change(onOptionsChanged);
+ $('.dict-priority-up').click(e => {
+ const dictGroup = $(e.target).closest('.dict-group');
+ const dictPriority = dictGroup.find('.dict-priority');
+ dictPriority.val(parseFloat(dictPriority.val()) + 0.5);
+ onOptionsChanged(e);
+ });
+ $('.dict-priority-down').click(e => {
+ const dictGroup = $(e.target).closest('.dict-group');
+ const dictPriority = dictGroup.find('.dict-priority');
+ dictPriority.val(parseFloat(dictPriority.val()) - 0.5);
+ onOptionsChanged(e);
+ });
}).catch(showDictionaryError).then(() => {
showDictionarySpinner(false);
if (dictCount === 0) {
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index 2a8bf5b3..44eae7fa 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -7,19 +7,19 @@ templates['dictionary.html'] = template({"1":function(container,depth0,helpers,p
return "<div class=\"dict-group well well-sm\" data-title=\""
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
- + "\">\n <h4><span class=\"text-muted glyphicon glyphicon-book\"></span> "
+ + "\">\n <div class=\"row\">\n <div class=\"col-xs-6\">\n <h4><span class=\"text-muted glyphicon glyphicon-book\"></span> "
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ " <small>rev."
+ alias4(((helper = (helper = helpers.revision || (depth0 != null ? depth0.revision : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"revision","hash":{},"data":data}) : helper)))
- + "</small></h4>\n\n <div class=\"checkbox\">\n <label><input type=\"checkbox\" class=\"dict-enabled\" "
+ + "</small></h4>\n\n <div class=\"checkbox\">\n <label><input type=\"checkbox\" class=\"dict-enabled\" "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.enabled : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "> Enable search</label>\n </div>\n <div class=\"form-group options-advanced\">\n <label for=\"dict-"
+ + "> Enable search</label>\n </div>\n <div class=\"form-group options-advanced\">\n <label for=\"dict-"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
- + "\">Result priority</label>\n <input type=\"number\" value=\""
+ + "\">Result priority</label>\n <input type=\"number\" value=\""
+ alias4(((helper = (helper = helpers.priority || (depth0 != null ? depth0.priority : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"priority","hash":{},"data":data}) : helper)))
+ "\" id=\"dict-"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
- + "\" class=\"form-control dict-priority\">\n </div>\n</div>\n";
+ + "\" class=\"form-control dict-priority\">\n </div>\n </div>\n <div class=\"col-xs-6 text-right\">\n <p><button class=\"dict-priority-up glyphicon glyphicon-arrow-up\" title=\"Increase priority\"></button></p>\n <p><button class=\"dict-priority-down glyphicon glyphicon-arrow-down\" title=\"Decrease priority\"></button></p>\n </div>\n </div>\n</div>\n";
},"useData":true});
templates['fields.html'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1;
diff --git a/tmpl/dictionary.html b/tmpl/dictionary.html
index f2f7f687..5b5b6458 100644
--- a/tmpl/dictionary.html
+++ b/tmpl/dictionary.html
@@ -1,11 +1,19 @@
<div class="dict-group well well-sm" data-title="{{title}}">
- <h4><span class="text-muted glyphicon glyphicon-book"></span> {{title}} <small>rev.{{revision}}</small></h4>
+ <div class="row">
+ <div class="col-xs-6">
+ <h4><span class="text-muted glyphicon glyphicon-book"></span> {{title}} <small>rev.{{revision}}</small></h4>
- <div class="checkbox">
- <label><input type="checkbox" class="dict-enabled" {{#if enabled}}checked{{/if}}> Enable search</label>
- </div>
- <div class="form-group options-advanced">
- <label for="dict-{{title}}">Result priority</label>
- <input type="number" value="{{priority}}" id="dict-{{title}}" class="form-control dict-priority">
+ <div class="checkbox">
+ <label><input type="checkbox" class="dict-enabled" {{#if enabled}}checked{{/if}}> Enable search</label>
+ </div>
+ <div class="form-group options-advanced">
+ <label for="dict-{{title}}">Result priority</label>
+ <input type="number" value="{{priority}}" id="dict-{{title}}" class="form-control dict-priority">
+ </div>
+ </div>
+ <div class="col-xs-6 text-right">
+ <p><button class="dict-priority-up glyphicon glyphicon-arrow-up" title="Increase priority"></button></p>
+ <p><button class="dict-priority-down glyphicon glyphicon-arrow-down" title="Decrease priority"></button></p>
+ </div>
</div>
</div>