Files
notifications-admin/app/assets/javascripts/main.js
Chris Hill-Scott 3106ea0e15 Make send yourself a test form stay at top of page
You might need to scroll this page quite a lot to see where a
placeholder appears in your template – especially if you have a long
email or letter.

One of the things I’m trying to stop happening so much is a lot of
scrolling back and forth. This would happen if you were scrolling down
to see the placeholder, then back up to fill in its value.

So this commit makes the textbox ‘sticky’, ie it always stays at the top
of the viewport, even when you scroll down. This lets you see the
placeholder and the textbox side by side, no matter how long the
template is.

The code to do this mostly comes from the GOV.UK Frontend Toolkit
(documented here: d9489a9870/docs/javascript.md (stick-at-top-when-scrolling)).
I had to add some extra CSS to make it look good when it overlaps the
content of the page, which the GOV.UK Frontend Toolkit implementation
doesn’t really anticipate.
2017-05-22 10:50:41 +01:00

10 lines
260 B
JavaScript

$(() => $("time.timeago").timeago());
$(() => GOVUK.stickAtTopWhenScrolling.init());
$(() => GOVUK.modules.start());
$(() => $('.error-message').eq(0).parent('label').next('input').trigger('focus'));
$(() => $('.banner-dangerous').eq(0).trigger('focus'));