summaryrefslogtreecommitdiff
path: root/ext/client.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-28 19:06:01 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-28 19:06:01 -0700
commit537d91dd10b9a84c72391a58942c4a8b3814939f (patch)
tree8bdf9a10b220220fe9949882268dac94efebea63 /ext/client.js
parentd77319e328137743bb0b024abba2d562017955e2 (diff)
WIP
Diffstat (limited to 'ext/client.js')
-rw-r--r--ext/client.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/client.js b/ext/client.js
index 76e4ceed..f5fdfb4d 100644
--- a/ext/client.js
+++ b/ext/client.js
@@ -27,32 +27,32 @@ class Client {
$('body').append(this.popup);
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
- window.addEventListener('mousedown', this.onMouseAction.bind(this));
- window.addEventListener('mousemove', this.onMouseAction.bind(this));
- window.addEventListener('keydown', this.onKeyAction.bind(this));
+ window.addEventListener('mousedown', this.onMouseDown.bind(this));
+ window.addEventListener('mousemove', this.onMouseMove.bind(this));
+ window.addEventListener('keydown', this.onKeyDown.bind(this));
getState((state) => this.setEnabled(state === 'enabled'));
}
- onKeyAction(e) {
- if (!this.enabled) {
- return;
- }
-
- if (this.lastMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) {
+ onKeyDown(e) {
+ if (this.enabled && this.lastMousePos !== null && (e.keyCode === 16 || e.charCode === 16)) {
this.searchAtPoint(this.lastMousePos);
}
}
- onMouseAction(e) {
+ onMouseMove(e) {
this.lastMousePos = {x: e.clientX, y: e.clientY};
-
- if (!this.enabled) {
- return;
+ if (this.enabled && (e.shiftKey || e.which === 2)) {
+ this.searchAtPoint(this.lastMousePos);
}
+ }
- if (e.shiftKey || e.which === 2) {
+ onMouseDown(e) {
+ this.lastMousePos = {x: e.clientX, y: e.clientY};
+ if (this.enabled && (e.shiftKey || e.which === 2)) {
this.searchAtPoint(this.lastMousePos);
+ } else {
+ this.hidePopup();
}
}