summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/search-query-parser.js8
-rw-r--r--ext/fg/js/frontend.js35
-rw-r--r--ext/mixed/js/display.js4
-rw-r--r--ext/mixed/js/dom.js20
4 files changed, 28 insertions, 39 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 42e53989..1a43347c 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -38,7 +38,7 @@ class QueryParser {
}
onMouseDown(e) {
- if (Frontend.isMouseButton('primary', e)) {
+ if (DOM.isMouseButtonPressed(e, 'primary')) {
this.clickScanPrevent = false;
}
}
@@ -47,7 +47,7 @@ class QueryParser {
if (
this.search.options.scanning.clickGlossary &&
!this.clickScanPrevent &&
- Frontend.isMouseButton('primary', e)
+ DOM.isMouseButtonPressed(e, 'primary')
) {
const selectText = this.search.options.scanning.selectText;
this.onTermLookup(e, {disableScroll: true, selectText});
@@ -55,7 +55,7 @@ class QueryParser {
}
onMouseMove(e) {
- if (this.pendingLookup || Frontend.isMouseButton('primary', e)) {
+ if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) {
return;
}
@@ -63,7 +63,7 @@ class QueryParser {
const scanningModifier = scanningOptions.modifier;
if (!(
Frontend.isScanningModifierPressed(scanningModifier, e) ||
- (scanningOptions.middleMouse && Frontend.isMouseButton('auxiliary', e))
+ (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary'))
)) {
return;
}
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 81c159db..ee653d78 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -80,7 +80,7 @@ class Frontend {
onMouseMove(e) {
this.popupTimerClear();
- if (this.pendingLookup || Frontend.isMouseButtonDown('primary', e)) {
+ if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) {
return;
}
@@ -88,7 +88,7 @@ class Frontend {
const scanningModifier = scanningOptions.modifier;
if (!(
Frontend.isScanningModifierPressed(scanningModifier, e) ||
- (scanningOptions.middleMouse && Frontend.isMouseButtonDown('auxiliary', e))
+ (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary'))
)) {
return;
}
@@ -487,37 +487,6 @@ class Frontend {
default: return false;
}
}
-
- static isMouseButton(button, mouseEvent) {
- switch (mouseEvent.type) {
- case 'mouseup':
- case 'mousedown':
- case 'click':
- return Frontend.isMouseButtonPressed(button, mouseEvent);
- default:
- return Frontend.isMouseButtonDown(button, mouseEvent);
- }
- }
-
- static isMouseButtonPressed(button, mouseEvent) {
- const mouseEventButton = mouseEvent.button;
- switch (button) {
- case 'primary': return mouseEventButton === 0;
- case 'secondary': return mouseEventButton === 2;
- case 'auxiliary': return mouseEventButton === 1;
- default: return false;
- }
- }
-
- static isMouseButtonDown(button, mouseEvent) {
- const mouseEventButtons = mouseEvent.buttons;
- switch (button) {
- case 'primary': return (mouseEventButtons & 0x1) !== 0x0;
- case 'secondary': return (mouseEventButtons & 0x2) !== 0x0;
- case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0;
- default: return false;
- }
- }
}
Frontend.windowMessageHandlers = {
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index cbf8efb7..854418f4 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -85,7 +85,7 @@ class Display {
}
onGlossaryMouseDown(e) {
- if (Frontend.isMouseButtonPressed('primary', e)) {
+ if (DOM.isMouseButtonPressed(e, 'primary')) {
this.clickScanPrevent = false;
}
}
@@ -95,7 +95,7 @@ class Display {
}
onGlossaryMouseUp(e) {
- if (!this.clickScanPrevent && Frontend.isMouseButtonPressed('primary', e)) {
+ if (!this.clickScanPrevent && DOM.isMouseButtonPressed(e, 'primary')) {
this.onTermLookup(e);
}
}
diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js
index 4525dace..4e4d49e3 100644
--- a/ext/mixed/js/dom.js
+++ b/ext/mixed/js/dom.js
@@ -43,4 +43,24 @@ class DOM {
}
return false;
}
+
+ static isMouseButtonPressed(mouseEvent, button) {
+ const mouseEventButton = mouseEvent.button;
+ switch (button) {
+ case 'primary': return mouseEventButton === 0;
+ case 'secondary': return mouseEventButton === 2;
+ case 'auxiliary': return mouseEventButton === 1;
+ default: return false;
+ }
+ }
+
+ static isMouseButtonDown(mouseEvent, button) {
+ const mouseEventButtons = mouseEvent.buttons;
+ switch (button) {
+ case 'primary': return (mouseEventButtons & 0x1) !== 0x0;
+ case 'secondary': return (mouseEventButtons & 0x2) !== 0x0;
+ case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0;
+ default: return false;
+ }
+ }
}