/**
* AngularJS Service that performs some accessibility stuff.
*
* @module accessibilityService
* @see https://docs.angularjs.org/api/ng/type/angular.Module#service
*/
angular.module('tgaApp').service('accessibilityService', ['$document',
function accessibilityService($document) {
/**
* (Re)initialize accessibility service.
*/
this.init = () => {
this.setInputClassHandler();
};
/**
* Sets using-mouse class when they are using the mouse.
*/
this.setInputClassHandler = () => {
const { body } = $document[0];
// let the document know when the mouse is being used
body.addEventListener('mousedown', () => {
body.classList.add('using-mouse');
});
// re-enable focus styling when Tab is pressed
body.addEventListener('keydown', (event) => {
if (event.keyCode === 9) {
body.classList.remove('using-mouse');
}
});
};
},
]);