From 056179ee4acf5d9a389fa72211f4aa2b4aa716d2 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 18 Feb 2011 19:31:33 -0500 Subject: Don't redirect if the user has interacted with the page by scrolling --- data/js/bug-page-mod.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js index 740ba1f..a7d952b 100644 --- a/data/js/bug-page-mod.js +++ b/data/js/bug-page-mod.js @@ -58,8 +58,19 @@ 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); + } var timer = d.defaultView.setTimeout(function() { - d.location.href = url; + // don't redirect if the user is using the page (for now, we just see + // if they have scrolled the page, in which case we assume that they + // are using the page.) + if (d.defaultView.scrollY > 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 +80,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); -- cgit