Make WordPress Core

Ticket #34484: 34484.4.patch

File 34484.4.patch, 5.2 KB (added by afercia, 9 years ago)
  • src/wp-includes/embed-template.php

     
    165165                                        </div>
    166166                                </div>
    167167                        </div>
    168                         <div class="wp-embed-share-dialog hidden">
     168                        <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>">
    169169                                <div class="wp-embed-share-dialog-content">
    170170                                        <div class="wp-embed-share-dialog-text">
    171171                                                <ul class="wp-embed-share-tabs" role="tablist">
    172                                                         <li id="wp-embed-share-tab-button-wordpress" class="wp-embed-share-tab-button" role="presentation">
    173                                                                 <button role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
     172                                                        <li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation">
     173                                                                <button type="button" role="tab" aria-controls="wp-embed-share-tab-wordpress" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button>
    174174                                                        </li>
    175                                                         <li id="wp-embed-share-tab-button-embed" class="wp-embed-share-tab-button" role="presentation">
    176                                                                 <button role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
     175                                                        <li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation">
     176                                                                <button type="button" role="tab" aria-controls="wp-embed-share-tab-html" aria-selected="false" tabindex="-1"><?php esc_html_e( 'HTML Embed' ); ?></button>
    177177                                                        </li>
    178178                                                </ul>
    179                                                 <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">
    180                                                         <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" tabindex="0" readonly/>
     179                                                <div id="wp-embed-share-tab-wordpress" class="wp-embed-share-tab" role="tabpanel" aria-hidden="false">
     180                                                        <input type="text" value="<?php the_permalink(); ?>" class="wp-embed-share-input" aria-describedby="wp-embed-share-description-wordpress" tabindex="0" readonly />
    181181
    182                                                         <p class="wp-embed-share-description">
     182                                                        <p class="wp-embed-share-description" id="wp-embed-share-description-wordpress">
    183183                                                                <?php _e( 'Copy and paste this URL into your WordPress site to embed' ); ?>
    184184                                                        </p>
    185185                                                </div>
    186                                                 <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">
    187                                                         <textarea class="wp-embed-share-input" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
     186                                                <div id="wp-embed-share-tab-html" class="wp-embed-share-tab" role="tabpanel" aria-hidden="true">
     187                                                        <textarea class="wp-embed-share-input" aria-describedby="wp-embed-share-description-html" tabindex="0" readonly><?php echo esc_textarea( get_post_embed_html( 600, 400 ) ); ?></textarea>
    188188
    189                                                         <p class="wp-embed-share-description">
     189                                                        <p class="wp-embed-share-description" id="wp-embed-share-description-html">
    190190                                                                <?php _e( 'Copy and paste this code into your site to embed' ); ?>
    191191                                                        </p>
    192192                                                </div>
  • src/wp-includes/js/wp-embed-template.js

     
    3838
    3939                function openSharingDialog() {
    4040                        share_dialog.className = share_dialog.className.replace( 'hidden', '' );
    41                         share_input[ 0 ].select();
     41                        // Initial focus should go on the currently selected tab in the dialog.
     42                        document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' ).focus();
    4243                }
    4344
    4445                function closeSharingDialog() {
     
    4748                }
    4849
    4950                if ( share_dialog_open ) {
    50                         share_dialog_open.addEventListener( 'click', function ( e ) {
     51                        share_dialog_open.addEventListener( 'click', function () {
    5152                                openSharingDialog();
    52                                 e.preventDefault();
    5353                        } );
    5454                }
    5555
    5656                if ( share_dialog_close ) {
    57                         share_dialog_close.addEventListener( 'click', function ( e ) {
     57                        share_dialog_close.addEventListener( 'click', function () {
    5858                                closeSharingDialog();
    59                                 e.preventDefault();
    6059                        } );
    6160                }
    6261
     
    110109                }
    111110
    112111                document.addEventListener( 'keydown', function ( e ) {
    113                         if ( e.keyCode === 27 && -1 === share_dialog.className.indexOf( 'hidden' ) ) {
     112                        if ( 27 === e.keyCode && -1 === share_dialog.className.indexOf( 'hidden' ) ) {
    114113                                closeSharingDialog();
     114                        } else if ( 9 === e.keyCode ) {
     115                                constrainTabbing( e );
    115116                        }
    116117                }, false );
    117118
     119                function constrainTabbing( e ) {
     120                        // Need to re-get the selected tab each time.
     121                        var firstFocusable = document.querySelector( '.wp-embed-share-tab-button [aria-selected="true"]' );
     122
     123                        if ( share_dialog_close === e.target && ! e.shiftKey ) {
     124                                firstFocusable.focus();
     125                                e.preventDefault();
     126                        } else if ( firstFocusable === e.target && e.shiftKey ) {
     127                                share_dialog_close.focus();
     128                                e.preventDefault();
     129                        }
     130                }
     131
    118132                if ( window.self === window.top ) {
    119133                        return;
    120134                }