Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/js/_enqueues/wp/revisions.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,13 @@ window.wp = window.wp || {};
initialize: function() {
_.bindAll( this, 'setWidth' );

// Add the button view.
this.views.add( new revisions.view.Buttons({
// Add the checkbox view.
this.views.add( new revisions.view.Checkbox({
model: this.model
}) );

// Add the checkbox view.
this.views.add( new revisions.view.Checkbox({
// Add the button view.
this.views.add( new revisions.view.Buttons({
model: this.model
}) );

Expand All @@ -628,6 +628,9 @@ window.wp = window.wp || {};
model: tooltip
}) );

// Add the visually hidden slider help view.
this.views.add( new revisions.view.SliderHelp() );

// Add the slider view.
this.views.add( new revisions.view.Slider({
model: slider
Expand Down Expand Up @@ -804,6 +807,12 @@ window.wp = window.wp || {};
}
});

// The slider visually hidden help view.
revisions.view.SliderHelp = wp.Backbone.View.extend({
className: 'revisions-slider-hidden-help',
template: wp.template( 'revisions-slider-hidden-help' )
});

// The tooltip view.
// Encapsulates the tooltip.
revisions.view.Tooltip = wp.Backbone.View.extend({
Expand Down Expand Up @@ -957,6 +966,20 @@ window.wp = window.wp || {};
this.applySliderSettings();
},

accessibilityHelper: function() {
var handles = $( '.ui-slider-handle' );
handles.first().attr( {
role: 'button',
'aria-labelledby': 'diff-title-from diff-title-author',
'aria-describedby': 'revisions-slider-hidden-help',
} );
handles.last().attr( {
role: 'button',
'aria-labelledby': 'diff-title-to diff-title-author',
'aria-describedby': 'revisions-slider-hidden-help',
} );
},

mouseMove: function( e ) {
var zoneCount = this.model.revisions.length - 1, // One fewer zone than models.
sliderFrom = this.$el.allOffsets()[this.direction], // "From" edge of slider.
Expand Down Expand Up @@ -996,9 +1019,12 @@ window.wp = window.wp || {};
handles.last()
.toggleClass( 'from-handle', !! isRtl )
.toggleClass( 'to-handle', ! isRtl );
this.accessibilityHelper();
} else {
handles.removeClass('from-handle to-handle');
this.accessibilityHelper();
}

},

start: function( event, ui ) {
Expand Down
12 changes: 10 additions & 2 deletions src/wp-admin/css/revisions.css
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
touch-action: none;
}

.wp-slider .ui-slider-handle,
.wp-slider .ui-slider-handle.focus {
.wp-slider .ui-slider-handle {
background: #f6f7f7;
border: 1px solid #c3c4c7;
box-shadow: 0 1px 0 #c3c4c7;
Expand All @@ -479,6 +478,15 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
transform: translateY(1px);
}

.wp-slider .ui-slider-handle:focus,
.wp-slider .ui-slider-handle.ui-state-focus {
background: #f0f0f1;
border-color: #8c8f94;
box-shadow: 0 0 0 2px #2271b1;
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
}

.wp-slider .ui-slider-handle:before {
background: none;
position: absolute;
Expand Down
13 changes: 9 additions & 4 deletions src/wp-admin/includes/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ function wp_print_revision_templates() {
</div>
</script>

<script id="tmpl-revisions-slider-hidden-help" type="text/html">
<h2 class="screen-reader-text"><?php esc_html_e( 'Select a revision' ); ?></h2>
<p id="revisions-slider-hidden-help" hidden><?php esc_html_e( 'Change revision by using the left and arrow keys' ); ?></p>
</script>

<script id="tmpl-revisions-checkbox" type="text/html">
<div class="revision-toggle-compare-mode">
<label>
Expand All @@ -397,13 +402,13 @@ function wp_print_revision_templates() {
<# if ( ! _.isUndefined( data.attributes ) ) { #>
<div class="diff-title">
<# if ( 'from' === data.type ) { #>
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
<strong id="diff-title-from"><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
<# } else if ( 'to' === data.type ) { #>
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
<strong id="diff-title-to"><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
<# } #>
<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
{{{ data.attributes.author.avatar }}}
<div class="author-info">
<div class="author-info" id="diff-title-author">
<# if ( data.attributes.autosave ) { #>
<span class="byline">
<?php
Expand Down Expand Up @@ -464,7 +469,7 @@ function wp_print_revision_templates() {
<div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
<div class="diff">
<# _.each( data.fields, function( field ) { #>
<h3>{{ field.name }}</h3>
<h2>{{ field.name }}</h2>
{{{ field.diff }}}
<# }); #>
</div>
Expand Down