aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/front.js
diff options
context:
space:
mode:
authorZarino Zappia <mail@zarino.co.uk>2018-09-19 11:24:46 +0100
committerZarino Zappia <mail@zarino.co.uk>2018-09-19 12:13:46 +0100
commit48c0835f2dd2bb130eb0ae3703f3f2477cd3042e (patch)
tree10de6a97d0e0e4d58351aaa605687c5fd16cf887 /web/js/front.js
parent8f2ce13bec69151aa10ef0676d9c417b0fde6fa3 (diff)
Clicking "Report" header links on homepage focusses #pc input
Works for both the "Report" button shown in the mobile header, and the "Report a problem" span on the desktop site. Thanks to Louise for suggesting this in mysociety/collideoscope#42!
Diffstat (limited to 'web/js/front.js')
-rw-r--r--web/js/front.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/web/js/front.js b/web/js/front.js
index db0228597..1efa516fd 100644
--- a/web/js/front.js
+++ b/web/js/front.js
@@ -10,6 +10,7 @@ document.getElementById('pc').focus();
el.value = 1;
form.insertBefore(el, form.firstChild);
}
+
var around_links = document.querySelectorAll('a[href*="around"]');
for (i=0; i<around_links.length; i++) {
var link = around_links[i];
@@ -18,8 +19,19 @@ document.getElementById('pc').focus();
var lk = document.querySelector('span.report-a-problem-btn');
if (lk && lk.addEventListener) {
- lk.addEventListener('click', function(){
+ lk.addEventListener('click', function(e){
+ e.preventDefault();
+ scrollTo(0,0);
+ document.getElementById('pc').focus();
+ });
+ }
+
+ var cta = document.getElementById('report-cta');
+ if (cta && cta.addEventListener) {
+ cta.addEventListener('click', function(e) {
+ e.preventDefault();
scrollTo(0,0);
+ document.getElementById('pc').focus();
});
}
})();