diff options
Diffstat (limited to 'data')
-rw-r--r-- | data/js/bug-page-mod.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js index 1fb70e8..2af545d 100644 --- a/data/js/bug-page-mod.js +++ b/data/js/bug-page-mod.js @@ -58,8 +58,25 @@ function tweakBugzilla(d) { url = url.replace("process_bug.cgi", "show_bug.cgi"); url = url.replace("attachment.cgi", "show_bug.cgi"); url += "?id=" + bug; + function cancelRedirection() { + d.defaultView.clearTimeout(timer); + redirectMsg.parentNode.removeChild(redirectMsg); + d.body.removeEventListener("mousedown", interactionDetector, false); + d.body.removeEventListener("keydown", interactionDetector, false); + } + function interactionDetector() { + cancelRedirection(); + } + d.body.addEventListener("mousedown", interactionDetector, false); + d.body.addEventListener("keydown", interactionDetector, false); var timer = d.defaultView.setTimeout(function() { - d.location.href = url; + // don't redirect if the user is using the page. + if (d.defaultView.scrollY > 0 || + d.defaultView.getSelection().rangeCount > 0) { + cancelRedirection(); + } else { + d.location.href = url; + } }, 2000); var redirectMsg = d.createElement("div"); redirectMsg.setAttribute("style", "font-weight: bold; text-align: center; border: 1px solid gray; margin: 10px 0; color: gray;"); @@ -69,8 +86,7 @@ function tweakBugzilla(d) { cancelLink.setAttribute("style", "color: black;"); cancelLink.addEventListener("click", function(event) { event.preventDefault = true; - d.defaultView.clearTimeout(timer); - redirectMsg.parentNode.removeChild(redirectMsg); + cancelRedirection(); }, false); cancelLink.appendChild(d.createTextNode("Cancel")); redirectMsg.appendChild(cancelLink); |