[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentysixteen/js/ -> skip-link-focus-fix.js (source)

   1  /**
   2   * File skip-link-focus-fix.js.
   3   *
   4   * Helps with accessibility for keyboard only users.
   5   *
   6   * Learn more: https://git.io/vWdr2
   7   */
   8  
   9  ( function() {
  10      var isIe = /(trident|msie)/i.test( navigator.userAgent );
  11  
  12      if ( isIe && document.getElementById && window.addEventListener ) {
  13          window.addEventListener( 'hashchange', function() {
  14              var id = location.hash.substring( 1 ),
  15                  element;
  16  
  17              if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
  18                  return;
  19              }
  20  
  21              element = document.getElementById( id );
  22  
  23              if ( element ) {
  24                  if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
  25                      element.tabIndex = -1;
  26                  }
  27  
  28                  element.focus();
  29  
  30                  // Repositions the window on jump-to-anchor to account for admin bar and border height.
  31                  window.scrollBy( 0, -53 );
  32              }
  33          }, false );
  34      }
  35  } )();


Generated : Mon Mar 18 08:20:01 2024 Cross-referenced by PHPXref