summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-05 12:35:58 -0800
committerAlex Yatskov <alex@foosoft.net>2017-03-05 12:35:58 -0800
commitd4e95c27d2cfe9bb67540e7c868c284735768877 (patch)
treee10ce6acfc88c57613101e84fcc7a3fea7926190 /ext/bg/js
parentca778d30f70997706bba85651bc3a26b5ebc3708 (diff)
wip
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/options.js20
-rw-r--r--ext/bg/js/templates.js10
2 files changed, 21 insertions, 9 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;