Files
notifications-admin/app/assets/javascripts/autofocus.js
T

18 lines
484 B
JavaScript
Raw Normal View History

2016-02-02 16:16:29 +00:00
(function(Modules) {
"use strict";
Modules.Autofocus = function() {
this.start = function(component) {
var forceFocus = $(component).data('forceFocus');
2016-02-02 16:16:29 +00:00
2019-03-28 16:45:36 +00:00
// 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; }
$('input, textarea, select', component).eq(0).trigger('focus');
2016-02-02 16:16:29 +00:00
};
};
})(window.GOVUK.Modules);