From a81d69d6c12a383664a92acb40c1c365b2425ca5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 2 Aug 2020 19:00:36 -0400 Subject: Add support for history navigation using mouse buttons in the popup window (#707) --- ext/fg/js/float.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'ext/fg') 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'); -- cgit v1.2.3