Make WordPress Core

Ticket #34484: 34484.patch

File 34484.patch, 5.3 KB (added by afercia, 10 years ago)
  • src/wp-includes/embed-template.php

     
    167167                                        </div>
    168168                                </div>
    169169                        </div>
    170                         <div class="wp-embed-share-dialog hidden">
     170                        <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>">
    171171                                <div class="wp-embed-share-dialog-content">
    172172                                        <div class="wp-embed-share-dialog-text">
    173173                                                <ul class="wp-embed-share-tabs" role="tablist">
    174                                                         <li id="wp-embed-share-tab-button-wordpress" class="wp-embed-share-tab-button" role="presentation">
    175                                                                 <button role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
     174                                                        <li class="wp-embed-share-tab-button" role="presentation">
     175                                                                <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
    176176                                                        </li>
    177                                                         <li id="wp-embed-share-tab-button-embed" class="wp-embed-share-tab-button" role="presentation">
    178                                                                 <button role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
     177                                                        <li class="wp-embed-share-tab-button" role="presentation">
     178                                                                <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
    179179                                                        </li>
    180180                                                </ul>
    181                                                 <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-labelledby="wp-embed-share-tab-button-wordpress" aria-hidden="false">
    182                                                         <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" tabindex="0" readonly/>
     181                                                <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
     182                                                        <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-url-description" tabindex="0" readonly />
    183183
    184                                                         <p class="wp-embed-share-description">
     184                                                        <p class="wp-embed-share-description" id="wp-embed-share-url-description">
    185185                                                                <?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?>
    186186                                                        </p>
    187187                                                </div>
    188                                                 <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-labelledby="wp-embed-share-tab-button-html" aria-hidden="true">
    189                                                         <textarea class="wp-embed-share-input" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( null, 600, 400 ) ); ?></textarea>
     188                                                <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
     189                                                        <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-code-description" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( null, 600, 400 ) ); ?></textarea>
    190190
    191                                                         <p class="wp-embed-share-description">
     191                                                        <p class="wp-embed-share-description" id="wp-embed-share-code-description">
    192192                                                                <?php _e( 'Copy and paste this code into your site to embed' ); ?>
    193193                                                        </p>
    194194                                                </div>
  • src/wp-includes/js/wp-embed-template.js

     
    3131
    3232                function openSharingDialog() {
    3333                        share_dialog.className = share_dialog.className.replace( 'hidden', '' );
    34                         share_input[ 0 ].select();
     34                        // Initial focus should go on the currently selected tab in the dialog.
     35                        document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' ).focus();
    3536                }
    3637
    3738                function closeSharingDialog() {
     
    4041                }
    4142
    4243                if ( share_dialog_open ) {
    43                         share_dialog_open.addEventListener( 'click', function ( e ) {
     44                        share_dialog_open.addEventListener( 'click', function () {
    4445                                openSharingDialog();
    45                                 e.preventDefault();
    4646                        } );
    4747                }
    4848
    4949                if ( share_dialog_close ) {
    50                         share_dialog_close.addEventListener( 'click', function ( e ) {
     50                        share_dialog_close.addEventListener( 'click', function () {
    5151                                closeSharingDialog();
    52                                 e.preventDefault();
    5352                        } );
    5453                }
    5554
     
    9796                if ( share_dialog_tabs ) {
    9897                        for ( i = 0; i < share_dialog_tabs.length; i++ ) {
    9998                                share_dialog_tabs[ i ].addEventListener( 'click', shareClickHandler );
    100 
    10199                                share_dialog_tabs[ i ].addEventListener( 'keydown', shareKeyHandler );
    102100                        }
    103101                }
    104102
    105103                document.addEventListener( 'keydown', function ( e ) {
    106                         if ( e.keyCode === 27 && -1 === share_dialog.className.indexOf( 'hidden' ) ) {
     104                        if ( 27 === e.keyCode && -1 === share_dialog.className.indexOf( 'hidden' ) ) {
    107105                                closeSharingDialog();
     106                        } else if ( 9 === e.keyCode ) {
     107                                constrainTabbing( e );
    108108                        }
    109109                }, false );
    110110
     111                function constrainTabbing( e ) {
     112                        // Need to re-get each time the selected tab.
     113                        var firstFocusable = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );
     114
     115                        if ( share_dialog_close === e.target && ! e.shiftKey ) {
     116                                firstFocusable.focus();
     117                                e.preventDefault();
     118                        } else if ( firstFocusable === e.target && e.shiftKey ) {
     119                                share_dialog_close.focus();
     120                                e.preventDefault();
     121                        }
     122                }
     123
    111124                if ( window.self === window.top ) {
    112125                        return;
    113126                }