sidebar.js 999 B

1234567891011121314151617181920212223242526272829303132333435
  1. ( function() {
  2. var sidebar, button, footer;
  3. sidebar = document.getElementById( 'secondary' );
  4. if ( ! sidebar ) {
  5. return;
  6. }
  7. button = document.getElementsByClassName( 'sidebar-toggle' )[0];
  8. if ( 'undefined' === typeof button ) {
  9. return;
  10. }
  11. footer = document.getElementById( 'colophon' );
  12. sidebar.setAttribute( 'aria-expanded', 'false' );
  13. button.onclick = function() {
  14. if ( -1 !== sidebar.className.indexOf( 'toggled' ) ) {
  15. sidebar.className = sidebar.className.replace( ' toggled', '' );
  16. button.className = button.className.replace( ' toggled', '' );
  17. footer.className = footer.className.replace( ' sidebar-toggled', '' );
  18. sidebar.setAttribute( 'aria-expanded', 'false' );
  19. button.setAttribute( 'aria-expanded', 'false' );
  20. } else {
  21. sidebar.className += ' toggled';
  22. button.className += ' toggled';
  23. footer.className += ' sidebar-toggled';
  24. sidebar.setAttribute( 'aria-expanded', 'true' );
  25. button.setAttribute( 'aria-expanded', 'true' );
  26. }
  27. };
  28. } )();