diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-11-12 19:34:02 -0800 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-11-12 19:34:02 -0800 |
commit | 371c07ab1fb6125c065589d71c93477e0456aada (patch) | |
tree | 7260b408b9e1f9247f92b4ac9cb467fce054ba82 /ext/bg/js/options-form.js | |
parent | b5cc47a9d1d7df7ec5a596fb72fad21f79d2e01c (diff) |
Revert "Delete dictionary deletion"
This reverts commit 0ff41d5843b3bf39994ae32e4ab623bfe0e4e3ca.
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r-- | ext/bg/js/options-form.js | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 3d1530ad..3a201bc5 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -141,6 +141,7 @@ function populateDictionaries(opts) { }); $('.dict-enable-terms, .dict-enable-kanji').change(onOptionsChanged); + $('.dict-delete').click(onDictionaryDelete); }).catch(error => { dictError.show().find('span').text(error); }).then(() => { @@ -148,6 +149,36 @@ function populateDictionaries(opts) { }); } +function onDictionaryDelete() { + const dictGroup = $(this).closest('.dict-group'); + + const dictError = $('#dict-error'); + dictError.hide(); + + const dictSpinner = $('#dict-spinner'); + dictSpinner.show(); + + const dictProgress = dictGroup.find('.dict-delete-progress'); + dictProgress.show(); + + const dictControls = dictGroup.find('.dict-controls'); + dictControls.hide(); + + const callback = (total, current) => { + dictProgress.find('div').css('width', `${current / total * 100.0}%`); + }; + + database().deleteDictionary(dictGroup.data('title'), callback).then(() => { + dictGroup.slideUp(); + }).catch(error => { + dictError.show().find('span').text(error); + }).then(() => { + dictSpinner.hide(); + dictProgress.hide(); + dictControls.show(); + }); +} + function onDictionaryImport() { const dictImport = $(this); dictImport.prop('disabled', true); @@ -155,7 +186,7 @@ function onDictionaryImport() { const dictError = $('#dict-error'); dictError.hide(); - const dictProgress = $('.dict-progress'); + const dictProgress = $('.dict-import-progress'); dictProgress.show(); const dictSpinner = $('#dict-spinner'); |