aboutsummaryrefslogtreecommitdiff
path: root/ext/client.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-27 22:27:30 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-27 22:27:30 -0700
commit43d4abf317bb69c936d51a9850314e76923eaee7 (patch)
tree57604330d7e5b0cc46b9a708732eb6fe9109239a /ext/client.js
parentc8d0a8624f4925f8227be67da5f40d888e9e5756 (diff)
Updating styling
Diffstat (limited to 'ext/client.js')
-rw-r--r--ext/client.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/client.js b/ext/client.js
index 95308eec..74b246f3 100644
--- a/ext/client.js
+++ b/ext/client.js
@@ -23,16 +23,23 @@ class Client {
this.popupOffset = 10;
this.enabled = false;
- $('body').append(this.popup);
+ $('body').append(this.popup).click(() => this.hidePopup());
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
window.addEventListener('mousemove', this.onMouseMove.bind(this));
+ window.addEventListener('keydown', this.onKeyDown.bind(this));
getState((state) => this.setEnabled(state === 'enabled'));
}
+ onKeyDown(e) {
+ if (e.keyCode === 16 || e.charCode === 16) {
+ this.hidePopup();
+ }
+ }
+
onMouseMove(e) {
- if (!this.enabled || !e.shiftKey) {
+ if (!this.enabled || (!e.shiftKey && e.which !== 2)) {
return;
}
@@ -53,7 +60,7 @@ class Client {
this.hidePopup();
} else {
range.setEnd(range.endContainer, range.startOffset + length);
- renderTemplate({defs: results.slice(0, 5)}, 'defs.html', (html) => {
+ renderTemplate({defs: results}, 'defs.html', (html) => {
this.popup.html(html);
this.showPopup(range);
});