Make WordPress Core

Ticket #21785: a11y-ui-improvements-3.diff

File a11y-ui-improvements-3.diff, 13.1 KB (added by mcsf, 11 years ago)
  • src/wp-admin/css/customize-controls.css

    diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
    index f9ca1d7..9a95eb1 100644
    a b body { 
    465465        margin-bottom: 18px;
    466466}
    467467
     468#customize-control-header_image .uploaded button,
     469#customize-control-header_image .default button {
     470        width: 100%;
     471        padding: 0;
     472        margin: 0;
     473        background: none;
     474        border: none;
     475        color: inherit;
     476        cursor: pointer;
     477        outline: none;
     478}
     479
     480#customize-control-header_image button img {
     481        display: block;
     482}
     483
    468484/* Header control: current image container */
    469485
    470486#customize-control-header_image .current .container {
    471487        overflow: hidden;
    472488        -webkit-border-radius: 2px;
     489        border: 1px solid #eee;
    473490        border-radius: 2px;
    474491}
    475492
    476493#customize-control-header_image .placeholder {
    477494        width: 100%;
    478495        position: relative;
    479         background: #262626;
    480496        text-align: center;
    481497        cursor: default;
    482498}
    body { 
    485501        display: none;
    486502        position: absolute;
    487503        width: 100%;
    488         height: 18px;
    489         margin-top: -9px;
    490         top: 50%;
    491         color: #eee;
     504        color: #555;
     505        white-space: nowrap;
     506        text-overflow: ellipsis;
     507        overflow: hidden;
    492508}
    493509
    494 /* Header control: overlay "close" button */
     510#customize-control-header_image .inner,
     511#customize-control-header_image .inner .dashicons {
     512        line-height: 20px;
     513        top: 10px;
     514}
     515#customize-control-header_image .list .inner,
     516#customize-control-header_image .list .inner .dashicons {
     517        top: 9px;
     518}
    495519
    496520#customize-control-header_image .header-view {
    497521        position: relative;
     522        width: 100%;
     523        margin-bottom: 5px;
    498524}
    499525
     526#customize-control-header_image .header-view:last-child {
     527        margin-bottom: 0px;
     528}
     529
     530/* Convoluted, but 'outline' support isn't good enough yet */
     531#customize-control-header_image .header-view:after {
     532        border: 0;
     533}
     534#customize-control-header_image .header-view.selected:after {
     535        content: '';
     536        position: absolute;
     537        top: 0; left: 0; bottom: 0; right: 0;
     538        border: 4px solid #2ea2cc;
     539        border-radius: 2px;
     540}
     541#customize-control-header_image .header-view.button.selected {
     542        border: 0;
     543}
     544
     545/* Header control: overlay "close" button */
     546
    500547#customize-control-header_image .uploaded .header-view .close {
    501548        font-size: 2em;
    502549        color: grey;
    body { 
    575622        margin-bottom: 9px;
    576623}
    577624
    578 #customize-control-header_image .choice.random:before {
    579         position: absolute;
    580         content: attr(data-label);
    581         left: 0;
    582         top: 0;
    583 }
    584 
    585625#customize-control-header_image .uploaded div:last-child > .choice {
    586626        margin-bottom: 0;
    587627}
    588628
    589 #customize-control-header_image .choices hr {
    590         visibility: hidden;
    591 }
    592 
    593629#customize-control-header_image img {
    594630        width: 100%;
    595631        -webkit-border-radius: 2px;
  • src/wp-admin/custom-header.php

    diff --git a/src/wp-admin/custom-header.php b/src/wp-admin/custom-header.php
    index 4a2d44c..2a6a2f3 100644
    a b wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 
    12721272        public function get_uploaded_header_images() {
    12731273                $header_images = get_uploaded_header_images();
    12741274                $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
     1275                $alt_text_key = '_wp_attachment_image_alt';
    12751276
    12761277                foreach ( $header_images as &$header_image ) {
    1277                         $header_image['timestamp'] = get_post_meta( $header_image['attachment_id'], $timestamp_key, true );
     1278                        $header_meta = get_post_meta( $header_image['attachment_id'] );
     1279                        $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : '';
     1280                        $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : '';
    12781281                }
    12791282
    12801283                return $header_images;
  • src/wp-includes/class-wp-customize-control.php

    diff --git a/src/wp-includes/class-wp-customize-control.php b/src/wp-includes/class-wp-customize-control.php
    index e55a759..478a706 100644
    a b final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    774774
    775775                        <div class="placeholder random">
    776776                                <div class="inner">
    777                                         <span><span class="dashicons dashicons-randomize dice"></span>
     777                                        <button type="button"><span class="dashicons dashicons-randomize dice"></span>
    778778                                        <# if ( data.type === 'uploaded' ) { #>
    779779                                                <?php _e( 'Randomize uploaded headers' ); ?>
    780780                                        <# } else if ( data.type === 'default' ) { #>
    781781                                                <?php _e( 'Randomize suggested headers' ); ?>
    782782                                        <# } #>
    783                                         </span>
     783                                        </button>
    784784                                </div>
    785785                        </div>
    786786
    787787                        <# } else { #>
    788788
    789789                        <# if (data.type === 'uploaded') { #>
    790                         <div class="dashicons dashicons-no close"></div>
     790                                <div class="dashicons dashicons-no close"></div>
    791791                        <# } #>
    792792
    793                         <a href="#" class="choice thumbnail #>"
     793                        <button type="button" class="choice thumbnail"
    794794                                data-customize-image-value="{{{data.header.url}}}"
    795795                                data-customize-header-image-data="{{JSON.stringify(data.header)}}">
    796                                 <img src="{{{data.header.thumbnail_url}}}">
    797                         </a>
     796                                <span class="screen-reader-text"><?php _e( 'Set image' ); ?></span>
     797                                <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}">
     798                        </button>
    798799
    799800                        <# } #>
    800801                </script>
    final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    803804                        <# if (data.choice) { #>
    804805                                <# if (data.random) { #>
    805806
    806                         <div class="placeholder">
     807                        <div class="placeholder" tabindex="0">
    807808                                <div class="inner">
    808809                                        <span><span class="dashicons dashicons-randomize dice"></span>
    809810                                        <# if ( data.type === 'uploaded' ) { #>
    final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    817818
    818819                                <# } else { #>
    819820
    820                         <img src="{{{data.header.thumbnail_url}}}" />
     821                        <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" tabindex="0"/>
    821822
    822823                                <# } #>
    823824                        <# } else { #>
    824825
    825                         <div class="placeholder">
     826                        <div class="placeholder" tabindex="0">
    826827                                <div class="inner">
    827828                                        <span>
    828829                                                <?php _e( 'No image set' ); ?>
    final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    853854
    854855
    855856                <div class="customize-control-content">
    856                         <p class="customizer-section-intro">
     857                        <p class="customizer-section-intro" tabindex="0">
    857858                                <?php
    858859                                // @todo translate (and look to custom-header.php for inspiration)
    859860                                echo ( 'Personalize your site with your own header image.' );
    final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    867868                                ?>
    868869                        </p>
    869870                        <div class="current">
    870                                 <span class="customize-control-title">
     871                                <span class="customize-control-title" tabindex="0">
    871872                                        <?php _e( 'Current header' ); ?>
    872873                                </span>
    873874                                <div class="container">
    final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control 
    875876                        </div>
    876877                        <div class="actions">
    877878                                <?php /* translators: Hide as in hide header image via the Customizer */ ?>
    878                                 <a href="#" <?php echo $visibility ?> class="button remove"><?php _ex( 'Hide', 'custom header' ); ?></a>
     879                                <button type="button"<?php echo $visibility ?> class="button remove"><?php _ex( 'Hide image', 'custom header' ); ?></button>
    879880                                <?php /* translators: New as in add new header image via the Customizer */ ?>
    880                                 <a href="#" class="button new"><?php _ex( 'Add new', 'header image' ); ?></a>
     881                                <button type="button" class="button new"><?php _ex( 'Add new image', 'header image' ); ?></button>
    881882                                <div style="clear:both"></div>
    882883                        </div>
    883884                        <div class="choices">
    884                                 <span class="customize-control-title header-previously-uploaded">
     885                                <span class="customize-control-title header-previously-uploaded" tabindex="0">
    885886                                        <?php _ex( 'Previously uploaded', 'custom headers' ); ?>
    886887                                </span>
    887888                                <div class="uploaded">
    888889                                        <div class="list">
    889890                                        </div>
    890891                                </div>
    891                                 <span class="customize-control-title header-default">
     892                                <span class="customize-control-title header-default" tabindex="0">
    892893                                        <?php _ex( 'Suggested', 'custom headers' ); ?>
    893894                                </span>
    894895                                <div class="default">
  • src/wp-includes/js/customize-models.js

    diff --git a/src/wp-includes/js/customize-models.js b/src/wp-includes/js/customize-models.js
    index f97750b..3c8001c 100644
    a b  
    2626                                        thumbnail_url: ''
    2727                                },
    2828                                choice: '',
    29                                 hidden: false,
     29                                selected: false,
    3030                                random: false
    3131                        };
    3232                },
     
    160160                                        elt.defaultName = index;
    161161                                }
    162162
     163                                if (typeof elt.timestamp === 'undefined') {
     164                                        elt.timestamp = 0;
     165                                }
     166
    163167                                this.add({
    164168                                        header: elt,
    165169                                        choice: elt.url.split('/').pop(),
    166                                         hidden: current === elt.url.replace(/^https?:\/\//, '')
     170                                        selected: current === elt.url.replace(/^https?:\/\//, '')
    167171                                }, { silent: true });
    168172                        }, this);
    169173
     
    191195                                },
    192196                                choice: randomChoice,
    193197                                random: true,
    194                                 hidden: isRandomSameType
     198                                selected: isRandomSameType
    195199                        });
    196200                },
    197201
     
    200204                },
    201205
    202206                shouldHideTitle: function() {
    203                         return _.every(this.pluck('hidden'));
     207                        return this.size() < 2;
    204208                },
    205209
    206210                setImage: function(model) {
    207211                        this.each(function(m) {
    208                                 m.set('hidden', false);
     212                                m.set('selected', false);
    209213                        });
    210214
    211215                        if (model) {
    212                                 model.set('hidden', true);
    213                                 // Bump images to top except for special "Randomize" images
    214                                 if (!model.get('random')) {
    215                                         model.get('header').timestamp = _.now();
    216                                         this.sort();
    217                                 }
     216                                model.set('selected', true);
    218217                        }
    219218                },
    220219
    221220                removeImage: function() {
    222221                        this.each(function(m) {
    223                                 m.set('hidden', false);
     222                                m.set('selected', false);
    224223                        });
    225                 },
    226 
    227                 shown: function() {
    228                         var filtered = this.where({ hidden: false });
    229                         return new api.HeaderTool.ChoiceList( filtered );
    230224                }
    231225        });
    232226
  • src/wp-includes/js/customize-views.js

    diff --git a/src/wp-includes/js/customize-views.js b/src/wp-includes/js/customize-views.js
    index eb3d4aa..39ad65b 100644
    a b  
    3232
    3333                getHeight: function() {
    3434                        var image = this.$el.find('img'),
    35                                 saved = this.model.get('savedHeight'),
    36                                 height = image.height() || saved,
    37                                 headerImageData;
     35                                saved, height, headerImageData;
    3836
    3937                        if (image.length) {
    4038                                this.$el.find('.inner').hide();
    4139                        } else {
    4240                                this.$el.find('.inner').show();
     41                                return 40;
    4342                        }
    4443
     44                        saved = this.model.get('savedHeight');
     45                        height = image.height() || saved;
     46
    4547                        // happens at ready
    4648                        if (!height) {
    4749                                headerImageData = api.get().header_image_data;
     
    9294         * @constructor
    9395         * @augments wp.Backbone.View
    9496         */
    95         (function () { // closures FTW
    96         var lastHeight = 0;
    9797        api.HeaderTool.ChoiceView = wp.Backbone.View.extend({
    9898                template: wp.template('header-choice'),
    9999
     
    110110                                this.model.get('choice')
    111111                        ];
    112112
    113                         this.listenTo(this.model, 'change', this.render);
     113                        this.listenTo(this.model, 'change:selected', this.toggleSelected);
    114114
    115115                        if (_.contains(properties, api.get().header_image)) {
    116116                                api.HeaderTool.currentHeader.set(this.extendedModel());
     
    118118                },
    119119
    120120                render: function() {
    121                         var model = this.model;
    122 
    123121                        this.$el.html(this.template(this.extendedModel()));
    124122
    125                         if (model.get('random')) {
     123                        if (this.model.get('random')) {
     124                                this.$el.addClass('button display-options');
    126125                                this.setPlaceholder(40);
    127126                        }
    128                         else {
    129                                 lastHeight = this.getHeight();
    130                         }
    131127
    132                         this.$el.toggleClass('hidden', model.get('hidden'));
     128                        this.toggleSelected();
    133129                        return this;
    134130                },
    135131
     132                toggleSelected: function() {
     133                        this.$el.toggleClass('selected', this.model.get('selected'));
     134                },
     135
    136136                extendedModel: function() {
    137137                        var c = this.model.get('collection');
    138138                        return _.extend(this.model.toJSON(), {
     
    145145                setPlaceholder: api.HeaderTool.CurrentView.prototype.setPlaceholder,
    146146
    147147                select: function() {
     148                        this.preventJump();
    148149                        this.model.save();
    149150                        api.HeaderTool.currentHeader.set(this.extendedModel());
    150151                },
    151152
     153                preventJump: function() {
     154                        var container = $('.wp-full-overlay-sidebar-content'),
     155                                scroll = container.scrollTop();
     156
     157                        _.defer(function() {
     158                                container.scrollTop(scroll);
     159                        });
     160                },
     161
    152162                removeImage: function(e) {
    153163                        e.stopPropagation();
    154164                        this.model.destroy();
    155165                        this.remove();
    156166                }
    157167        });
    158         })();
    159168
    160169
    161170        /**
     
    174183                        this.listenTo(this.collection, 'add', this.addOne);
    175184                        this.listenTo(this.collection, 'remove', this.render);
    176185                        this.listenTo(this.collection, 'sort', this.render);
    177                         this.listenTo(this.collection, 'change:hidden', this.toggleTitle);
    178                         this.listenTo(this.collection, 'change:hidden', this.setMaxListHeight);
     186                        this.listenTo(this.collection, 'change', this.toggleList);
    179187                        this.render();
    180188                },
    181189
    182190                render: function() {
    183191                        this.$el.empty();
    184192                        this.collection.each(this.addOne, this);
    185                         this.toggleTitle();
     193                        this.toggleList();
    186194                },
    187195
    188196                addOne: function(choice) {
     
    192200                        this.$el.append(view.render().el);
    193201                },
    194202
    195                 toggleTitle: function() {
    196                         var title = this.$el.parents().prev('.customize-control-title');
     203                toggleList: function() {
     204                        var title = this.$el.parents().prev('.customize-control-title'),
     205                                randomButton = this.$el.find('.random').parent();
    197206                        if (this.collection.shouldHideTitle()) {
    198                                 title.hide();
     207                                title.add(randomButton).hide();
    199208                        } else {
    200                                 title.show();
     209                                title.add(randomButton).show();
    201210                        }
    202211                }
    203212        });