From e5b53bb238e59b1cd6371c0379d6171a3e1e68fa Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 3 Apr 2022 22:52:53 -0400 Subject: [PATCH] Hide popup on cursor exit (#2109) * Update phrasing * Add new options * Add settings * Implement --- ext/data/schemas/options-schema.json | 13 +++++++++++- ext/js/app/frontend.js | 4 ++++ ext/js/data/options-util.js | 4 ++++ ext/settings.html | 31 ++++++++++++++++++++++++++-- ext/welcome.html | 4 ++-- test/test-options-util.js | 2 ++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 74ae3300..ef86f8c3 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -436,7 +436,9 @@ "enableOnSearchPage", "enableSearchTags", "layoutAwareScan", - "matchTypePrefix" + "matchTypePrefix", + "hidePopupOnCursorExit", + "hidePopupOnCursorExitDelay" ], "properties": { "inputs": { @@ -663,6 +665,15 @@ "matchTypePrefix": { "type": "boolean", "default": false + }, + "hidePopupOnCursorExit": { + "type": "boolean", + "default": false + }, + "hidePopupOnCursorExitDelay": { + "type": "number", + "minimum": 0, + "default": 0 } } }, diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 0dd58735..102cd299 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -343,6 +343,10 @@ class Frontend { _onPopupFramePointerOut() { this._isPointerOverPopup = false; + const scanningOptions = this._options.scanning; + if (scanningOptions.hidePopupOnCursorExit) { + this._clearSelectionDelayed(scanningOptions.hidePopupOnCursorExitDelay, false); + } } _clearSelection(passive) { diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 3422b773..593fed29 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -931,6 +931,8 @@ class OptionsUtil { // general.popupTheme's 'default' value changed to 'light' // general.popupOuterTheme's 'default' value changed to 'light' // general.popupOuterTheme's 'auto' value changed to 'site' + // Added scanning.hidePopupOnCursorExit. + // Added scanning.hidePopupOnCursorExitDelay. for (const profile of options.profiles) { const {general} = profile.options; if (general.popupTheme === 'default') { @@ -940,6 +942,8 @@ class OptionsUtil { case 'default': general.popupOuterTheme = 'light'; break; case 'auto': general.popupOuterTheme = 'site'; break; } + profile.options.scanning.hidePopupOnCursorExit = false; + profile.options.scanning.hidePopupOnCursorExitDelay = profile.options.scanning.hideDelay; } return options; } diff --git a/ext/settings.html b/ext/settings.html index fcd73f4d..6d91695d 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -418,7 +418,7 @@
Auto-hide search popup
-
When no definitions are found after scanning text, the popup will automatically hide.
+
When no definitions are found after scanning text, the popup will be hidden.
+
+
+
+
Hide popup on cursor exit
+
When the cursor exits the popup, the popup will be hidden.
+
+
+ +
+
+ +
Scan delay (in milliseconds)
diff --git a/ext/welcome.html b/ext/welcome.html index 6fda4d44..f67e186c 100644 --- a/ext/welcome.html +++ b/ext/welcome.html @@ -122,7 +122,7 @@
Auto-hide search popup
-
When no definitions are found after scanning text, the popup will automatically hide.
+
When no definitions are found after scanning text, the popup will be hidden.