aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/float.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-02 19:00:36 -0400
committerGitHub <noreply@github.com>2020-08-02 19:00:36 -0400
commita81d69d6c12a383664a92acb40c1c365b2425ca5 (patch)
tree79c1603df2cc820c4b94cc2e396d10eda7644c44 /ext/fg/js/float.js
parent1184320e3e0863c86238a68bc90dc77b3355e332 (diff)
Add support for history navigation using mouse buttons in the popup window (#707)
Diffstat (limited to 'ext/fg/js/float.js')
-rw-r--r--ext/fg/js/float.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index fa571fcc..794ccc6e 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -49,6 +49,9 @@ class DisplayFloat extends Display {
['setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}]
]);
window.addEventListener('message', this._onWindowMessage.bind(this), false);
+ document.documentElement.addEventListener('mouseup', this._onMouseUp.bind(this), false);
+ document.documentElement.addEventListener('click', this._onClick.bind(this), false);
+ document.documentElement.addEventListener('auxclick', this._onClick.bind(this), false);
this.initializeState();
@@ -138,6 +141,38 @@ class DisplayFloat extends Display {
// Private
+ _onMouseUp(e) {
+ switch (e.button) {
+ case 3: // Back
+ if (this._history.hasPrevious()) {
+ e.preventDefault();
+ }
+ break;
+ case 4: // Forward
+ if (this._history.hasNext()) {
+ e.preventDefault();
+ }
+ break;
+ }
+ }
+
+ _onClick(e) {
+ switch (e.button) {
+ case 3: // Back
+ if (this._history.hasPrevious()) {
+ e.preventDefault();
+ this._history.back();
+ }
+ break;
+ case 4: // Forward
+ if (this._history.hasNext()) {
+ e.preventDefault();
+ this._history.forward();
+ }
+ break;
+ }
+ }
+
_copySelection() {
if (window.getSelection().toString()) { return false; }
this._invoke('copySelection');