Make WordPress Core

Changeset 30013


Ignore:
Timestamp:
10/24/2014 03:14:02 PM (12 years ago)
Author:
iandstewart
Message:

Twenty Fifteen: valid HTML for accessible child page menu expanding and collapsing -- now with even better accessiblity.

Props afercia, davidakennedy, iamtakashi, fixes #30083.

Location:
trunk/src/wp-content/themes/twentyfifteen
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/css/ie.css

    r30012 r30013  
    131131    line-height: 1.8462;
    132132    margin-top: 0;
    133 }
    134 
    135 .dropdown-toggle {
    136     margin-top: -21px;
    137133}
    138134
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r29892 r30013  
    220220    wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20141010', true );
    221221    wp_localize_script( 'twentyfifteen-script', 'screenReaderText', array(
    222         'expand'   => '<span class="screen-reader-text">' . esc_html__( 'Expand', 'twentyfifteen' ) . '</span>',
    223         'collapse' => '<span class="screen-reader-text">' . esc_html__( 'Collapse', 'twentyfifteen' ) . '</span>',
     222        'expand'   => '<span class="screen-reader-text">' . esc_html__( 'expand child menu', 'twentyfifteen' ) . '</span>',
     223        'collapse' => '<span class="screen-reader-text">' . esc_html__( 'collapse child menu', 'twentyfifteen' ) . '</span>',
    224224    ) );
    225225}
  • trunk/src/wp-content/themes/twentyfifteen/js/functions.js

    r29893 r30013  
    1010
    1111    // Add dropdown toggle that display child menu items.
    12     $( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a' ).append( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
     12    $( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
    1313
    1414    $( '.dropdown-toggle' ).click( function( e ) {
     
    1616        e.preventDefault();
    1717        _this.toggleClass( 'toggle-on' );
    18         _this.parent().next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
     18        _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
    1919        _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
    2020        _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
  • trunk/src/wp-content/themes/twentyfifteen/style.css

    r30011 r30013  
    693693    box-sizing: content-box;
    694694    content: "";
    695     display: block;
    696     font-size: 15px;
    697     font-size: 1.5rem;
    698695    height: 42px;
    699696    padding: 0;
    700697    position: absolute;
    701     top: 50%;
     698    text-transform: lowercase; /* Stop screen readers to read the text as capital letters */
     699    top: 3px;
    702700    right: 0;
    703     -webkit-transform: translateY(-50%);
    704     -ms-transform: translateY(-50%);
    705     transform: translateY(-50%);
    706701    width: 42px;
    707702}
     
    25532548
    25542549    .main-navigation ul {
    2555         border-top: 1px solid #eaeaea;
    25562550        border-top: 1px solid rgba(51, 51, 51, 0.1);
    2557         border-bottom: 1px solid #eaeaea;
    25582551        border-bottom: 1px solid rgba(51, 51, 51, 0.1);
    25592552    }
     
    50795072    .dropdown-toggle {
    50805073        height: 32px;
     5074        top: 4px;
    50815075        width: 32px;
    50825076    }
Note: See TracChangeset for help on using the changeset viewer.