From 9d4123cee1867ee7199b06bdc92d40611f547ecc Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Wed, 21 Jul 2021 14:54:07 -0500 Subject: Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/. --- assets/js/unminified/skip-link-focus-fix.js | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 assets/js/unminified/skip-link-focus-fix.js (limited to 'assets/js/unminified/skip-link-focus-fix.js') diff --git a/assets/js/unminified/skip-link-focus-fix.js b/assets/js/unminified/skip-link-focus-fix.js new file mode 100644 index 0000000..97496af --- /dev/null +++ b/assets/js/unminified/skip-link-focus-fix.js @@ -0,0 +1,37 @@ +/** + * File skip-link-focus-fix.js + * + * Helps with accessibility for keyboard only users. + * This is the source file for what is minified in the astra_skip_link_focus_fix() PHP function. + * + * Learn more: https://github.com/Automattic/_s/pull/136 + * + * @package Astra + */ + +( function() { + var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, + is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, + is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; + + if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { + window.addEventListener( 'hashchange', function() { + var id = location.hash.substring( 1 ), + element; + + if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { + return; + } + + element = document.getElementById( id ); + + if ( element ) { + if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { + element.tabIndex = -1; + } + + element.focus(); + } + }, false ); + } +})(); -- cgit v1.2.3-60-g2f50