mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-10 13:23:40 -05:00
Since moving textboxes to GOV.UK Frontend we’ve started putting the data attribute on the `input` element itself, not a wrapper around it. This commit updates the Javascript accordingly.
18 lines
491 B
JavaScript
18 lines
491 B
JavaScript
(function(Modules) {
|
|
"use strict";
|
|
|
|
Modules.Autofocus = function() {
|
|
this.start = function(component) {
|
|
var forceFocus = $(component).data('forceFocus');
|
|
|
|
// if the page loads with a scroll position, we can't assume the item to focus onload
|
|
// is still where users intend to start
|
|
if (($(window).scrollTop() > 0) && !forceFocus) { return; }
|
|
|
|
$(component).filter('input, textarea, select').eq(0).trigger('focus');
|
|
|
|
};
|
|
};
|
|
|
|
})(window.GOVUK.Modules);
|