Hide popup on cursor exit (#2109)

* Update phrasing

* Add new options

* Add settings

* Implement
This commit is contained in:
toasted-nutbread 2022-04-03 22:52:53 -04:00 committed by GitHub
parent 77c4d135c7
commit e5b53bb238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 5 deletions

View File

@ -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
}
}
},

View File

@ -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) {

View File

@ -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;
}

View File

@ -418,7 +418,7 @@
<div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Auto-hide search popup</div>
<div class="settings-item-description">When no definitions are found after scanning text, the popup will automatically hide.</div>
<div class="settings-item-description">When no definitions are found after scanning text, the popup will be hidden.</div>
</div>
<div class="settings-item-right">
<label class="toggle"><input type="checkbox" data-setting="scanning.autoHideResults"
@ -433,7 +433,7 @@
<div class="settings-item-children settings-item-children-group" id="auto-hide-search-popup-options" hidden>
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Auto-hide delay <span class="light">(in milliseconds)</span></div>
<div class="settings-item-label">Delay <span class="light">(in milliseconds)</span></div>
</div>
<div class="settings-item-right">
<input type="number" data-setting="scanning.hideDelay" min="0">
@ -441,6 +441,33 @@
</div></div>
</div>
</div>
<div class="settings-item">
<div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Hide popup on cursor exit</div>
<div class="settings-item-description">When the cursor exits the popup, the popup will be hidden.</div>
</div>
<div class="settings-item-right">
<label class="toggle"><input type="checkbox" data-setting="scanning.hidePopupOnCursorExit"
data-transform='{
"type": "setVisibility",
"selector": "#hide-popup-on-cursor-exit-options",
"condition": {"op": "===", "value": true}
}'
><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
</div>
</div>
<div class="settings-item-children settings-item-children-group" id="hide-popup-on-cursor-exit-options" hidden>
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Delay <span class="light">(in milliseconds)</span></div>
</div>
<div class="settings-item-right">
<input type="number" data-setting="scanning.hidePopupOnCursorExitDelay" min="0">
</div>
</div></div>
</div>
</div>
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Scan delay <span class="light">(in milliseconds)</span></div>

View File

@ -122,7 +122,7 @@
<div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Auto-hide search popup</div>
<div class="settings-item-description">When no definitions are found after scanning text, the popup will automatically hide.</div>
<div class="settings-item-description">When no definitions are found after scanning text, the popup will be hidden.</div>
</div>
<div class="settings-item-right">
<label class="toggle"><input type="checkbox" data-setting="scanning.autoHideResults"
@ -137,7 +137,7 @@
<div class="settings-item-children settings-item-children-group" id="auto-hide-search-popup-options" hidden>
<div class="settings-item"><div class="settings-item-inner">
<div class="settings-item-left">
<div class="settings-item-label">Popup auto-hide delay <span class="light">(in milliseconds)</span></div>
<div class="settings-item-label">Delay <span class="light">(in milliseconds)</span></div>
</div>
<div class="settings-item-right">
<input type="number" data-setting="scanning.hideDelay" min="0">

View File

@ -345,6 +345,8 @@ function createProfileOptionsUpdatedTestData1() {
hideDelay: 0,
pointerEventsEnabled: false,
matchTypePrefix: false,
hidePopupOnCursorExit: false,
hidePopupOnCursorExitDelay: 0,
preventMiddleMouse: {
onWebPages: false,
onPopupPages: false,