From d4e95c27d2cfe9bb67540e7c868c284735768877 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 5 Mar 2017 12:35:58 -0800 Subject: wip --- ext/bg/js/options.js | 20 ++++++++++++++++---- ext/bg/js/templates.js | 10 +++++----- tmpl/dictionary.html | 22 +++++++++++++++------- 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 "
\n

" + + "\">\n
\n
\n

" + 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))) + " 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))) - + "

\n\n
\n

\n\n
\n \n
\n
\n \n
\n
\n \n Result priority\n \n
\n
\n"; + + "\" class=\"form-control dict-priority\">\n \n \n
\n

\n

\n
\n \n\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 @@
-

{{title}} rev.{{revision}}

+
+
+

{{title}} rev.{{revision}}

-
- -
-
- - +
+ +
+
+ + +
+
+
+

+

+
-- cgit v1.2.3