diff options
author | Ehsan Akhgari <ehsan@mozilla.com> | 2011-02-18 19:31:33 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan@mozilla.com> | 2011-02-18 19:31:33 -0500 |
commit | 056179ee4acf5d9a389fa72211f4aa2b4aa716d2 (patch) | |
tree | 5395bcaa9bbec579480f2a9ea250967798dbe48b /data | |
parent | ddc145837e2b910d3655f3dca169c9297316dc0f (diff) | |
download | bugzilla-triage-056179ee4acf5d9a389fa72211f4aa2b4aa716d2.tar.gz |
Don't redirect if the user has interacted with the page by scrolling
Diffstat (limited to 'data')
-rw-r--r-- | data/js/bug-page-mod.js | 16 |
1 files changed, 13 insertions, 3 deletions
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); |