diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-26 19:24:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-26 19:24:21 -0400 |
commit | 73dd578821d1373d4504778318e2e2f26b79a80e (patch) | |
tree | 7b96fd5bfef81de55175fc5a97ddee11cbb2ed1b /ext/fg/js/frontend.js | |
parent | 9c7b9d666087add0f72900c045ee43ed05c5b467 (diff) |
Add middle mouse prevention option (#868)
* Add preventMiddleMouse option to TextScanner
* Add preventMiddleMouse options
* Add options
* Apply preventMiddleMouse options
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r-- | ext/fg/js/frontend.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 13b0d80c..95c9eb1b 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -320,6 +320,7 @@ class Frontend { await this._updatePopup(); + const preventMiddleMouse = this._getPreventMiddleMouseValueForPageType(scanningOptions.preventMiddleMouse); this._textScanner.setOptions({ inputs: scanningOptions.inputs, deepContentScan: scanningOptions.deepDomScan, @@ -329,7 +330,8 @@ class Frontend { pointerEventsEnabled: scanningOptions.pointerEventsEnabled, scanLength: scanningOptions.length, sentenceExtent: options.anki.sentenceExt, - layoutAwareScan: scanningOptions.layoutAwareScan + layoutAwareScan: scanningOptions.layoutAwareScan, + preventMiddleMouse }); this._updateTextScannerEnabled(); @@ -616,4 +618,13 @@ class Frontend { await this._updatePendingOptions(); return await this.getOptionsContext(); } + + _getPreventMiddleMouseValueForPageType(preventMiddleMouseOptions) { + switch (this._pageType) { + case 'web': return preventMiddleMouseOptions.onWebPages; + case 'popup': return preventMiddleMouseOptions.onPopupPages; + case 'search': return preventMiddleMouseOptions.onSearchPages; + default: return false; + } + } } |