summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/dictionary-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-19 17:14:51 -0400
committerGitHub <noreply@github.com>2020-09-19 17:14:51 -0400
commit2ff4f830722940d2bfc35328fa913f93d04a330b (patch)
tree19eb865b31eaaa9c69f6bd913985ae5460e7340d /ext/bg/js/settings/dictionary-controller.js
parent613c7ebf69413723486ab49a7b2f928422de3541 (diff)
Modal refactor (#842)
* Add Modal class * Use Modal class
Diffstat (limited to 'ext/bg/js/settings/dictionary-controller.js')
-rw-r--r--ext/bg/js/settings/dictionary-controller.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js
index 75022d1f..afc198e2 100644
--- a/ext/bg/js/settings/dictionary-controller.js
+++ b/ext/bg/js/settings/dictionary-controller.js
@@ -16,6 +16,7 @@
*/
/* global
+ * Modal
* ObjectPropertyAccessor
* api
*/
@@ -164,7 +165,7 @@ class DictionaryController {
this._checkIntegrityButton = document.querySelector('#dict-check-integrity');
this._dictionaryEntryContainer = document.querySelector('#dict-groups');
this._integrityExtraInfoContainer = document.querySelector('#dict-groups-extra');
- this._deleteDictionaryModal = document.querySelector('#dict-delete-modal');
+ this._deleteDictionaryModal = new Modal(document.querySelector('#dict-delete-modal'));
yomichan.on('databaseUpdated', this._onDatabaseUpdated.bind(this));
@@ -177,9 +178,9 @@ class DictionaryController {
deleteDictionary(dictionaryTitle) {
if (this._isDeleting) { return; }
const modal = this._deleteDictionaryModal;
- modal.dataset.dictionaryTitle = dictionaryTitle;
- modal.querySelector('#dict-remove-modal-dict-name').textContent = dictionaryTitle;
- this._setModalVisible(modal, true);
+ modal.node.dataset.dictionaryTitle = dictionaryTitle;
+ modal.node.querySelector('#dict-remove-modal-dict-name').textContent = dictionaryTitle;
+ modal.setVisible(true);
}
// Private
@@ -209,11 +210,11 @@ class DictionaryController {
e.preventDefault();
const modal = this._deleteDictionaryModal;
- this._setModalVisible(modal, false);
+ modal.setVisible(false);
- const title = modal.dataset.dictionaryTitle;
+ const title = modal.node.dataset.dictionaryTitle;
if (typeof title !== 'string') { return; }
- delete modal.dataset.dictionaryTitle;
+ delete modal.node.dataset.dictionaryTitle;
this._deleteDictionary(title);
}
@@ -223,10 +224,6 @@ class DictionaryController {
this._checkIntegrity();
}
- _setModalVisible(node, visible) {
- $(node).modal(visible ? 'show' : 'hide');
- }
-
_updateMainDictionarySelectOptions(dictionaries) {
const fragment = document.createDocumentFragment();