Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Hide popup on cursor exit (#2109)
Browse files Browse the repository at this point in the history
* Update phrasing

* Add new options

* Add settings

* Implement
  • Loading branch information
toasted-nutbread authored Apr 4, 2022
1 parent 77c4d13 commit e5b53bb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
13 changes: 12 additions & 1 deletion ext/data/schemas/options-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@
"enableOnSearchPage",
"enableSearchTags",
"layoutAwareScan",
"matchTypePrefix"
"matchTypePrefix",
"hidePopupOnCursorExit",
"hidePopupOnCursorExitDelay"
],
"properties": {
"inputs": {
Expand Down Expand Up @@ -663,6 +665,15 @@
"matchTypePrefix": {
"type": "boolean",
"default": false
},
"hidePopupOnCursorExit": {
"type": "boolean",
"default": false
},
"hidePopupOnCursorExitDelay": {
"type": "number",
"minimum": 0,
"default": 0
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions ext/js/data/options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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;
}
Expand Down
31 changes: 29 additions & 2 deletions ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ <h1>Yomichan Settings</h1>
<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"
Expand All @@ -433,14 +433,41 @@ <h1>Yomichan Settings</h1>
<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">
</div>
</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>
Expand Down
4 changes: 2 additions & 2 deletions ext/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h2>Basic customization</h2>
<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"
Expand All @@ -137,7 +137,7 @@ <h2>Basic customization</h2>
<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">
Expand Down
2 changes: 2 additions & 0 deletions test/test-options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ function createProfileOptionsUpdatedTestData1() {
hideDelay: 0,
pointerEventsEnabled: false,
matchTypePrefix: false,
hidePopupOnCursorExit: false,
hidePopupOnCursorExitDelay: 0,
preventMiddleMouse: {
onWebPages: false,
onPopupPages: false,
Expand Down

0 comments on commit e5b53bb

Please sign in to comment.