b0y-101 Mini Shell


Current Path : E:/wordpress/wp-content/themes/elearning-education/assets/js/
File Upload :
Current File : E:/wordpress/wp-content/themes/elearning-education/assets/js/focus-nav.js

( function( window, document ) {
  function elearning_education_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const elearning_education_nav = document.querySelector( '.sidenav' );
      if ( ! elearning_education_nav || ! elearning_education_nav.classList.contains( 'open' ) ) {
        return;
      }
      const elements = [...elearning_education_nav.querySelectorAll( 'input, a, button' )],
        elearning_education_lastEl = elements[ elements.length - 1 ],
        elearning_education_firstEl = elements[0],
        elearning_education_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;
      if ( ! shiftKey && tabKey && elearning_education_lastEl === elearning_education_activeEl ) {
        e.preventDefault();
        elearning_education_firstEl.focus();
      }
      if ( shiftKey && tabKey && elearning_education_firstEl === elearning_education_activeEl ) {
        e.preventDefault();
        elearning_education_lastEl.focus();
      }
    } );
  }
  elearning_education_keepFocusInMenu();
} )( window, document );

Copyright © 2019 by b0y-101