diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2018-09-19 11:24:46 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2018-09-19 12:13:46 +0100 |
commit | 48c0835f2dd2bb130eb0ae3703f3f2477cd3042e (patch) | |
tree | 10de6a97d0e0e4d58351aaa605687c5fd16cf887 /web | |
parent | 8f2ce13bec69151aa10ef0676d9c417b0fde6fa3 (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')
-rw-r--r-- | web/js/front.js | 14 |
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(); }); } })(); |