Make WordPress Core

Ticket #21785: a11y-ui-improvements.diff

File a11y-ui-improvements.diff, 11.0 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..e0c9974 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}
     478
    468479/* Header control: current image container */
    469480
    470481#customize-control-header_image .current .container {
    471482        overflow: hidden;
    472483        -webkit-border-radius: 2px;
     484        border: 1px solid #eee;
    473485        border-radius: 2px;
    474486}
    475487
    476488#customize-control-header_image .placeholder {
    477489        width: 100%;
    478490        position: relative;
    479         background: #262626;
    480491        text-align: center;
    481492        cursor: default;
    482493}
    body { 
    485496        display: none;
    486497        position: absolute;
    487498        width: 100%;
    488         height: 18px;
    489         margin-top: -9px;
    490         top: 50%;
    491         color: #eee;
     499        color: #555;
     500        white-space: nowrap;
     501        text-overflow: ellipsis;
     502        overflow: hidden;
     503}
     504
     505#customize-control-header_image .inner,
     506#customize-control-header_image .inner .dashicons {
     507        line-height: 20px;
     508        top: 10px;
     509}
     510#customize-control-header_image .list .inner,
     511#customize-control-header_image .list .inner .dashicons {
     512        top: 8px;
     513}
     514#customize-control-header_image .selected .inner,
     515#customize-control-header_image .selected .inner .dashicons {
     516        top: 6px;
    492517}
    493518
    494519/* Header control: overlay "close" button */
    495520
    496521#customize-control-header_image .header-view {
    497522        position: relative;
     523        width: 100%;
     524}
     525
     526#customize-control-header_image .header-view.selected img,
     527#customize-control-header_image .header-view.button.selected {
     528        border: 4px solid #2ea2cc;
     529        box-sizing: border-box;
    498530}
    499531
    500532#customize-control-header_image .uploaded .header-view .close {
    body { 
    575607        margin-bottom: 9px;
    576608}
    577609
    578 #customize-control-header_image .choice.random:before {
    579         position: absolute;
    580         content: attr(data-label);
    581         left: 0;
    582         top: 0;
    583 }
    584 
    585610#customize-control-header_image .uploaded div:last-child > .choice {
    586611        margin-bottom: 0;
    587612}
    588613
    589 #customize-control-header_image .choices hr {
    590         visibility: hidden;
    591 }
    592 
    593614#customize-control-header_image img {
    594615        width: 100%;
    595616        -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..0b732c6 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 
    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">
  • 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..cc7ebd6 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);
     216                                model.set('selected', true);
    213217                                // Bump images to top except for special "Randomize" images
    214218                                if (!model.get('random')) {
    215219                                        model.get('header').timestamp = _.now();
     
    220224
    221225                removeImage: function() {
    222226                        this.each(function(m) {
    223                                 m.set('hidden', false);
     227                                m.set('selected', false);
    224228                        });
    225                 },
    226 
    227                 shown: function() {
    228                         var filtered = this.where({ hidden: false });
    229                         return new api.HeaderTool.ChoiceList( filtered );
    230229                }
    231230        });
    232231
  • 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        });
  • src/wp-includes/theme.php

    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index f66fd95..10bc026 100644
    a b function wp_customize_support_script() { 
    19181918                }());
    19191919        </script>
    19201920        <?php
    1921 }
    1922  No newline at end of file
     1921}