From 68af0d86c3a941e185b34926fdbc57c457466e28 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 31 Aug 2019 11:51:31 -0400 Subject: Improve popup position for vertical text --- ext/bg/js/options.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ext/bg/js/options.js') diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 29d8a215..c4a7e681 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -199,6 +199,9 @@ function optionsSetDefaults(options) { popupHeight: 250, popupHorizontalOffset: 0, popupVerticalOffset: 10, + popupHorizontalOffset2: 10, + popupVerticalOffset2: 0, + popupVerticalTextPosition: 'before', showGuide: true, compactTags: false, compactGlossaries: false, -- cgit v1.2.3 From 85472d9407861f688e55b06b1767882f71229fc2 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 31 Aug 2019 11:56:12 -0400 Subject: Add option for position of popup for horizontal text --- ext/bg/js/options.js | 1 + ext/bg/js/settings.js | 2 ++ ext/bg/settings.html | 8 ++++++++ ext/fg/js/popup.js | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-) (limited to 'ext/bg/js/options.js') diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index c4a7e681..c76525b9 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -201,6 +201,7 @@ function optionsSetDefaults(options) { popupVerticalOffset: 10, popupHorizontalOffset2: 10, popupVerticalOffset2: 0, + popupHorizontalTextPosition: 'below', popupVerticalTextPosition: 'before', showGuide: true, compactTags: false, diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index 83a1c2f6..c4eb4842 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -32,6 +32,7 @@ async function formRead() { optionsNew.general.showAdvanced = $('#show-advanced-options').prop('checked'); optionsNew.general.maxResults = parseInt($('#max-displayed-results').val(), 10); optionsNew.general.popupDisplayMode = $('#popup-display-mode').val(); + optionsNew.general.popupHorizontalTextPosition = $('#popup-horizontal-text-position').val(); optionsNew.general.popupVerticalTextPosition = $('#popup-vertical-text-position').val(); optionsNew.general.popupWidth = parseInt($('#popup-width').val(), 10); optionsNew.general.popupHeight = parseInt($('#popup-height').val(), 10); @@ -171,6 +172,7 @@ async function onReady() { $('#show-advanced-options').prop('checked', options.general.showAdvanced); $('#max-displayed-results').val(options.general.maxResults); $('#popup-display-mode').val(options.general.popupDisplayMode); + $('#popup-horizontal-text-position').val(options.general.popupHorizontalTextPosition); $('#popup-vertical-text-position').val(options.general.popupVerticalTextPosition); $('#popup-width').val(options.general.popupWidth); $('#popup-height').val(options.general.popupHeight); diff --git a/ext/bg/settings.html b/ext/bg/settings.html index c6090c91..4f244602 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -107,6 +107,14 @@ +
+ + +
+
Automatically hide results
+
+ +
+
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 8bb857e7..727bc5d2 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -89,7 +89,7 @@ function docImposterCreate(element, isTextarea) { return [imposter, container]; } -function docRangeFromPoint({x, y}) { +function docRangeFromPoint({x, y}, options) { const elements = document.elementsFromPoint(x, y); let imposter = null; let imposterContainer = null; @@ -108,7 +108,7 @@ function docRangeFromPoint({x, y}) { } } - const range = caretRangeFromPointExt(x, y, elements); + const range = caretRangeFromPointExt(x, y, options.scanning.deepDomScan ? elements : []); if (range !== null) { if (imposter !== null) { docSetImposterStyle(imposterContainer.style, 'z-index', '-2147483646'); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 5a8d18c1..8a5c48d0 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -285,7 +285,7 @@ class Frontend { return; } - const textSource = docRangeFromPoint(point); + const textSource = docRangeFromPoint(point, this.options); let hideResults = !textSource || !textSource.containsPoint(point); let searched = false; let success = false; diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 4620e198..ebf56897 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -80,7 +80,7 @@ class Display { const {docRangeFromPoint, docSentenceExtract} = this.dependencies; const clickedElement = $(e.target); - const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY}); + const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY}, this.options); if (textSource === null) { return false; } -- cgit v1.2.3