From 1b1f4a3ed7eaf29379be576e31ec4116347c6140 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 8 Nov 2016 21:02:12 -0800 Subject: WIP --- ext/bg/js/options-form.js | 23 ++++++++++++++--------- ext/bg/js/templates.js | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 808aa941..1fcd0838 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -150,8 +150,7 @@ function populateDictionaries(opts) { } function onDictionaryDelete() { - const dictDelete = $(this); - dictDelete.prop('disabled', true); + const dictGroup = $(this).closest('.dict-group'); const dictError = $('#dict-error'); dictError.hide(); @@ -159,14 +158,20 @@ function onDictionaryDelete() { const dictSpinner = $('#dict-spinner'); dictSpinner.show(); - const dictGroup = dictDelete.closest('.dict-group'); + const dictProgress = dictGroup.find('.dict-delete-progress'); + dictProgress.show(); + + const dictControls = dictGroup.find('.dict-controls'); + dictControls.hide(); + database().deleteDictionary(dictGroup.data('title')).then(() => { dictGroup.slideUp(); }).catch(error => { dictError.show().find('span').text(error); - dictDelete.prop('disabled', false); }).then(() => { dictSpinner.hide(); + dictProgress.hide(); + dictControls.show(); }); } @@ -177,14 +182,14 @@ function onDictionaryImport() { const dictError = $('#dict-error'); dictError.hide(); + const dictProgress = $('#dict-import-progress'); + dictProgress.show(); + const dictSpinner = $('#dict-spinner'); dictSpinner.show(); - const progressbar = $('#dict-import-progress'); - progressbar.show(); - const callback = (total, current) => { - progressbar.find('div').css('width', `${current / total * 100.0}%`); + dictProgress.find('div').css('width', `${current / total * 100.0}%`); }; const dictUrl = $('#dict-url'); @@ -196,7 +201,7 @@ function onDictionaryImport() { dictImport.prop('disabled', false); dictUrl.val(''); dictUrl.trigger('input'); - progressbar.hide(); + dictProgress.hide(); dictSpinner.hide(); }); } diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index d198a76f..34347100 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -13,13 +13,13 @@ templates['dictionary.html'] = template({"1":function(container,depth0,helpers,p + 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))) + " v." + alias4(((helper = (helper = helpers.version || (depth0 != null ? depth0.version : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"version","hash":{},"data":data}) : helper))) - + "\n \n
\n \n
\n \n
\n
\n
\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n
\n
Enable term search\n
\n
\n