Make WordPress Core

Ticket #22502: 22502.3.diff

File 22502.3.diff, 6.4 KB (added by koopersmith, 12 years ago)
  • wp-includes/css/media-views.css

     
    372372        user-select: none;
    373373}
    374374
    375 .media-menu li {
     375.media-menu .media-menu-item {
     376        display: block;
    376377        position: relative;
    377378        padding: 4px 20px;
    378379        margin: 0;
    379380        line-height: 18px;
    380381        font-size: 14px;
    381         color: #21759B;
    382382        text-shadow: 0 1px 0 #fff;
     383        text-decoration: none;
    383384}
    384385
    385 .media-menu-item {
    386         cursor: pointer;
    387 }
    388 
    389 .media-menu li:hover {
     386.media-menu .media-menu-item:hover,
     387.media-menu .media-menu-item:focus {
     388        color: #21759B;
     389        background: #f1f1f1;
    390390        background: rgba( 0, 0, 0, 0.04 );
     391        outline: none;
    391392}
    392393
    393 .media-menu .active,
    394 .media-menu .active:hover {
     394.media-menu .media-menu-item.active,
     395.media-menu .media-menu-item.active:hover {
    395396        color: #333;
    396397        font-weight: bold;
    397398}
     
    523524        cursor: pointer;
    524525}
    525526
     527.attachment-preview:focus {
     528        outline: thin dotted;
     529}
     530
    526531.attachment .icon {
    527532        margin: 0 auto;
    528533        overflow: hidden;
     
    13541359                width: 119px;
    13551360        }
    13561361
    1357         .media-menu li {
     1362        .media-menu .media-menu-item {
    13581363                padding: 4px 10px;
    13591364        }
    13601365
  • wp-includes/js/media-editor.js

     
    535535                                workflow.open();
    536536                        else
    537537                                workflow = wp.media.editor.add( id );
    538 
     538                       
     539                        // Add focus to modal
     540                        $( '.media-menu .active' ).focus();
     541                       
    539542                        return workflow;
    540543                }
    541544        };
  • wp-includes/js/media-views.js

     
    16481648                tagName:  'div',
    16491649                template: media.template('media-modal'),
    16501650
     1651                attributes: {
     1652                        tabindex: 0
     1653                },
     1654
    16511655                events: {
    1652                         'click .media-modal-backdrop, .media-modal-close' : 'closeHandler'
     1656                        'click .media-modal-backdrop, .media-modal-close': 'closeHandler',
     1657                        'keydown': 'keydown'
    16531658                },
    16541659
    16551660                initialize: function() {
     
    16591664                                container: document.body,
    16601665                                title:     ''
    16611666                        });
     1667
     1668                        _.bindAll( this, '_captureBodyKeydown' );
    16621669                },
    16631670
    16641671                render: function() {
     
    16911698                },
    16921699
    16931700                open: function() {
     1701                        document.addEventListener( 'keydown', this._captureBodyKeydown, true );
    16941702                        this.$el.show();
    16951703                        this.trigger('open');
    16961704                        return this;
    16971705                },
    16981706
    16991707                close: function() {
     1708                        document.removeEventListener( 'keydown', this._captureBodyKeydown, true );
    17001709                        this.$el.hide();
    17011710                        this.trigger('close');
    17021711                        return this;
     
    17151724                        // Set and render the content.
    17161725                        this.options.$content = ( $content instanceof Backbone.View ) ? $content.$el : $content;
    17171726                        return this.render();
     1727                },
     1728
     1729
     1730                // Thanks to jQuery UI dialog, which also limits tabbing to a modal
     1731                // window. The `:tabbable` expression, `$.ui.keyCode` object, and
     1732                // the overloaded `$.fn.focus( delay )` signature are all from the
     1733                // jQuery UI core.
     1734                keydown: function( event ) {
     1735                        var tabbables, first, last;
     1736
     1737                        // Close the modal when escape is pressed.
     1738                        if ( $.ui.keyCode.ESCAPE === event.which ) {
     1739                                event.preventDefault();
     1740                                this.close();
     1741                                return;
     1742                        }
     1743
     1744                        // Prevent tabbing outside of the modal.
     1745                        if ( event.keyCode !== $.ui.keyCode.TAB )
     1746                                return;
     1747
     1748                        tabbables = this.$(':tabbable');
     1749                        first     = tabbables.filter(':first');
     1750                        last      = tabbables.filter(':last');
     1751
     1752                        // If we attempt to tab past the last tabbable element, skip
     1753                        // straight to the first tabbable element (and vice versa).
     1754                        if ( event.target === last[0] && ! event.shiftKey ) {
     1755                                first.focus( 1 );
     1756                                return false;
     1757                        } else if ( event.target === first[0] && event.shiftKey ) {
     1758                                last.focus( 1 );
     1759                                return false;
     1760                        }
     1761                },
     1762
     1763                // If the focus somehow escapes the modal, restores focus to the
     1764                // first focusable element inside the modal.
     1765                //
     1766                // Captures the document's keydown event when the modal is open.
     1767                _captureBodyKeydown: function() {
     1768                        if ( event.keyCode !== $.ui.keyCode.TAB )
     1769                                return;
     1770
     1771                        if ( ! $.contains( this.el, document.activeElement ) )
     1772                                this.$(':tabbable').first().focus( 1 );
    17181773                }
    17191774        });
    17201775
     
    23472402         * wp.media.view.Menu
    23482403         */
    23492404        media.view.Menu = media.view.PriorityList.extend({
    2350                 tagName:   'ul',
    23512405                className: 'media-menu',
    23522406
    23532407                toView: function( options, state ) {
     
    23722426        });
    23732427
    23742428        media.view.MenuItem = media.View.extend({
    2375                 tagName:   'li',
     2429                tagName:   'a',
    23762430                className: 'media-menu-item',
    23772431
     2432                attributes: {
     2433                        href: '#'
     2434                },
     2435
    23782436                events: {
    23792437                        'click': 'click'
    23802438                },
    23812439
    2382                 click: function() {
     2440                click: function( event ) {
    23832441                        var options = this.options;
    23842442
     2443                        event.preventDefault();
     2444
    23852445                        if ( options.click )
    23862446                                options.click.call( this );
    23872447                        else if ( options.state )
     
    24172477
    24182478                events: {
    24192479                        'click .attachment-preview':      'toggleSelection',
     2480                        'keydown .attachment-preview':    'keydown',
    24202481                        'change [data-setting]':          'updateSetting',
    24212482                        'change [data-setting] input':    'updateSetting',
    24222483                        'change [data-setting] select':   'updateSetting',
     
    24932554                                this.$bar.width( this.model.get('percent') + '%' );
    24942555                },
    24952556
    2496                 toggleSelection: function( event ) {
     2557                keydown: function( event ) {
     2558                        if ( $.ui.keyCode.ENTER === event.keyCode )
     2559                                this.toggleSelection();
     2560                },
     2561
     2562                toggleSelection: function() {
    24972563                        var selection = this.options.selection,
    24982564                                model = this.model;
    24992565
  • wp-includes/media.php

     
    16031603        </script>
    16041604
    16051605        <script type="text/html" id="tmpl-attachment">
    1606                 <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
     1606                <div class="attachment-preview type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}" tabindex="0">
    16071607                        <# if ( data.uploading ) { #>
    16081608                                <div class="media-progress-bar"><div></div></div>
    16091609                        <# } else if ( 'image' === data.type ) { #>
     
    16241624                        <# } #>
    16251625
    16261626                        <# if ( data.buttons.check ) { #>
    1627                                 <a class="check" href="#"><span>&#10003;</span><span class="dash">&ndash;</span></a>
     1627                                <a class="check" href="#" tabindex="-1"><span>&#10003;</span><span class="dash">&ndash;</span></a>
    16281628                        <# } #>
    16291629                </div>
    16301630                <# if ( data.describe ) { #>