diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css
index b755b33b..fbea04c0 100644
--- a/ext/bg/css/settings.css
+++ b/ext/bg/css/settings.css
@@ -23,6 +23,7 @@
html:root:not([data-options-anki-enable=true]) #anki-general,
html:root:not([data-options-general-debug-info=true]) .debug,
html:root:not([data-options-general-show-advanced=true]) .options-advanced,
+html:root[data-options-general-show-advanced=true] .options-non-advanced,
html:root:not([data-options-general-result-output-mode=merge]) #dictionary-main-group {
display: none;
}
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 3b2ff29d..b7d7879c 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -28,6 +28,7 @@
* PopupPreviewController
* ProfileController
* ScanInputsController
+ * ScanInputsSimpleController
* SettingsController
* StorageController
* api
@@ -100,6 +101,9 @@ async function setupEnvironmentInfo() {
const scanInputsController = new ScanInputsController(settingsController);
scanInputsController.prepare();
+ const simpleScanningInputController = new ScanInputsSimpleController(settingsController);
+ simpleScanningInputController.prepare();
+
yomichan.ready();
} catch (e) {
yomichan.logError(e);
diff --git a/ext/bg/js/settings/scan-inputs-controller.js b/ext/bg/js/settings/scan-inputs-controller.js
index 04469a8d..f4aeb236 100644
--- a/ext/bg/js/settings/scan-inputs-controller.js
+++ b/ext/bg/js/settings/scan-inputs-controller.js
@@ -37,10 +37,10 @@ class ScanInputsController {
this._addButton = document.querySelector('#scan-input-add');
this._addButton.addEventListener('click', this._onAddButtonClick.bind(this), false);
+ this._settingsController.on('scanInputsChanged', this._onScanInputsChanged.bind(this));
this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this));
- const options = await this._settingsController.getOptions();
- this._onOptionsChanged({options});
+ this.refresh();
}
removeInput(index) {
@@ -51,13 +51,14 @@ class ScanInputsController {
for (let i = index, ii = this._entries.length; i < ii; ++i) {
this._entries[i].index = i;
}
- this._settingsController.modifyProfileSettings([{
+ this._modifyProfileSettings([{
action: 'splice',
path: 'scanning.inputs',
start: index,
deleteCount: 1,
items: []
}]);
+ return true;
}
setProperty(index, property, value) {
@@ -69,8 +70,18 @@ class ScanInputsController {
return this._settingsController.instantiateTemplate(name);
}
+ async refresh() {
+ const options = await this._settingsController.getOptions();
+ this._onOptionsChanged({options});
+ }
+
// Private
+ _onScanInputsChanged({source}) {
+ if (source === this) { return; }
+ this.refresh();
+ }
+
_onOptionsChanged({options}) {
const {inputs} = options.scanning;
@@ -92,26 +103,12 @@ class ScanInputsController {
const include = '';
const exclude = '';
this._addOption(index, include, exclude);
- this._settingsController.modifyProfileSettings([{
+ this._modifyProfileSettings([{
action: 'splice',
path: 'scanning.inputs',
start: index,
deleteCount: 0,
- items: [{
- include,
- exclude,
- types: {mouse: true, touch: false, pen: false},
- options: {
- showAdvanced: false,
- searchTerms: true,
- searchKanji: true,
- scanOnTouchMove: true,
- scanOnPenHover: true,
- scanOnPenPress: true,
- scanOnPenRelease: false,
- preventTouchScrolling: true
- }
- }]
+ items: [ScanInputsController.createDefaultMouseInput(include, exclude)]
}]);
}
@@ -120,6 +117,29 @@ class ScanInputsController {
this._entries.push(field);
field.prepare(this._container, include, exclude);
}
+
+ async _modifyProfileSettings(targets) {
+ await this._settingsController.modifyProfileSettings(targets);
+ this._settingsController.trigger('scanInputsChanged', {source: this});
+ }
+
+ static createDefaultMouseInput(include, exclude) {
+ return {
+ include,
+ exclude,
+ types: {mouse: true, touch: false, pen: false},
+ options: {
+ showAdvanced: false,
+ searchTerms: true,
+ searchKanji: true,
+ scanOnTouchMove: true,
+ scanOnPenHover: true,
+ scanOnPenPress: true,
+ scanOnPenRelease: false,
+ preventTouchScrolling: true
+ }
+ };
+ }
}
class ScanInputField {
diff --git a/ext/bg/js/settings/scan-inputs-simple-controller.js b/ext/bg/js/settings/scan-inputs-simple-controller.js
new file mode 100644
index 00000000..636fd102
--- /dev/null
+++ b/ext/bg/js/settings/scan-inputs-simple-controller.js
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2020 Yomichan Authors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see