aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/client.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-04-24 11:04:24 -0700
committerAlex Yatskov <alex@foosoft.net>2016-04-24 11:04:24 -0700
commit709094455e77d8ceba199316631381fcad47ef5d (patch)
treeb4423fd57ce0731ee92fc78263cb5e8c288734a2 /ext/fg/js/client.js
parent75d5d84811354cc6dc92c635fb77ad62b4c0aafe (diff)
Improvements
Diffstat (limited to 'ext/fg/js/client.js')
-rw-r--r--ext/fg/js/client.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index f15519c9..a7c11e92 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -87,16 +87,17 @@ class Client {
return;
}
- range.setLength(this.options.scanLength);
-
- if (this.lastRange !== null && this.lastRange.equals(range)) {
+ if (this.lastRange !== null && this.lastRange.compareOrigin(range) === 0) {
return;
}
+ range.setLength(this.options.scanLength);
findTerm(range.text(), ({results, length}) => {
if (length === 0) {
this.hidePopup();
} else {
+ range.setLength(length);
+
const params = {
defs: results,
root: chrome.extension.getURL('fg')
@@ -105,17 +106,21 @@ class Client {
renderText(
params,
'term-list.html',
- (content) => this.showPopup(range, length, content)
+ (content) => this.showPopup(range, content)
);
}
});
}
- showPopup(range, length, content) {
- this.popup.showNextTo(range, content);
+ showPopup(range, content) {
+ this.popup.showNextTo(range.getRect(), content);
if (this.options.highlightText) {
- range.select(length);
+ if (this.lastRange !== null) {
+ this.lastRange.deselect();
+ }
+
+ range.select();
}
this.lastRange = range;