<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[26956] branches/3.8: Keyboard navigation friendliness for themes.php.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/26956">26956</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-01-15 08:28:04 +0000 (Wed, 15 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Keyboard navigation friendliness for themes.php.
Merges <a href="http://core.trac.wordpress.org/changeset/26922">[26922]</a> to the 3.8 branch.
props matveb, azaozz, jorbin.
fixes <a href="http://core.trac.wordpress.org/ticket/26527">#26527</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches38srcwpadmincsswpadmincss">branches/3.8/src/wp-admin/css/wp-admin.css</a></li>
<li><a href="#branches38srcwpadminjsthemejs">branches/3.8/src/wp-admin/js/theme.js</a></li>
<li><a href="#branches38srcwpadminthemesphp">branches/3.8/src/wp-admin/themes.php</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches38">branches/3.8/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx">Index: branches/3.8
</span><span class="cx">===================================================================
</span><del>--- branches/3.8 2014-01-15 08:23:39 UTC (rev 26955)
</del><ins>+++ branches/3.8 2014-01-15 08:28:04 UTC (rev 26956)
</ins><a id="branches38"></a>
<div class="propset"><h4>Property changes: branches/3.8</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx"> /branches/3.1:18031
</span><span class="cx"> /branches/3.3:20543
</span><span class="cx"> /branches/3.4:21757
</span><del>-/trunk:18512,26864,26874-26875,26885,26887-26888,26905,26919-26920,26923-26924,26928,26932,26935,26952
</del><ins>+/trunk:18512,26864,26874-26875,26885,26887-26888,26905,26919-26920,26922-26924,26928,26932,26935,26952
</ins><span class="cx">\ No newline at end of property
</span><a id="branches38srcwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: branches/3.8/src/wp-admin/css/wp-admin.css (26955 => 26956)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.8/src/wp-admin/css/wp-admin.css 2014-01-15 08:23:39 UTC (rev 26955)
+++ branches/3.8/src/wp-admin/css/wp-admin.css 2014-01-15 08:28:04 UTC (rev 26956)
</span><span class="lines">@@ -6494,6 +6494,24 @@
</span><span class="cx"> -webkit-transition: opacity 0.1s ease-in-out;
</span><span class="cx"> transition: opacity 0.1s ease-in-out;
</span><span class="cx"> }
</span><ins>+.theme-browser .theme:focus {
+ outline: 1px dotted #222;
+}
+/* Hide shortcut actions and hover feedback when using tab navigation */
+.theme-browser .theme:focus .theme-actions {
+ display: none;
+}
+/* Restore display of theme controls if you hover a focused theme */
+.theme-browser .theme:focus:hover .theme-actions {
+ display: block;
+}
+.theme-browser .theme:focus .more-details {
+ opacity: 1;
+}
+/* Current theme needs to have its action always on view */
+.theme-browser .theme.active:focus .theme-actions {
+ display: block;
+}
</ins><span class="cx">
</span><span class="cx"> .theme-browser.rendered .theme:hover .more-details {
</span><span class="cx"> opacity: 1;
</span><span class="lines">@@ -6719,10 +6737,13 @@
</span><span class="cx"> width: 50px;
</span><span class="cx"> text-align: center;
</span><span class="cx"> float: right;
</span><ins>+ border: 0;
</ins><span class="cx"> border-left: 1px solid #ddd;
</span><ins>+ background-color: transparent;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-.theme-overlay .theme-header .close:hover:before {
</del><ins>+.theme-overlay .theme-header .close:hover:before,
+.theme-overlay .theme-header .close:focus:before {
</ins><span class="cx"> color: #fff;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -6739,20 +6760,21 @@
</span><span class="cx"> .theme-overlay .theme-header .left {
</span><span class="cx"> cursor: pointer;
</span><span class="cx"> color: #777;
</span><ins>+ background-color: transparent;
</ins><span class="cx"> height: 48px;
</span><span class="cx"> width: 54px;
</span><span class="cx"> float: left;
</span><span class="cx"> text-align: center;
</span><ins>+ border: 0;
</ins><span class="cx"> border-right: 1px solid #ddd;
</span><del>- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .theme-overlay .theme-header .close:hover,
</span><span class="cx"> .theme-overlay .theme-header .right:hover,
</span><del>-.theme-overlay .theme-header .left:hover {
</del><ins>+.theme-overlay .theme-header .left:hover,
+.theme-overlay .theme-header .close:focus,
+.theme-overlay .theme-header .right:focus,
+.theme-overlay .theme-header .left:focus {
</ins><span class="cx"> background: #0074a2;
</span><span class="cx"> color: #fff;
</span><span class="cx"> }
</span><span class="lines">@@ -6861,7 +6883,8 @@
</span><span class="cx"> background: transparent;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-.theme-overlay .theme-actions .delete-theme:hover {
</del><ins>+.theme-overlay .theme-actions .delete-theme:hover,
+.theme-overlay .theme-actions .delete-theme:focus {
</ins><span class="cx"> background: #d54e21;
</span><span class="cx"> color: #fff;
</span><span class="cx"> border-color: #d54e21;
</span></span></pre></div>
<a id="branches38srcwpadminjsthemejs"></a>
<div class="modfile"><h4>Modified: branches/3.8/src/wp-admin/js/theme.js (26955 => 26956)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.8/src/wp-admin/js/theme.js 2014-01-15 08:23:39 UTC (rev 26955)
+++ branches/3.8/src/wp-admin/js/theme.js 2014-01-15 08:28:04 UTC (rev 26956)
</span><span class="lines">@@ -188,6 +188,7 @@
</span><span class="cx">
</span><span class="cx"> events: {
</span><span class="cx"> 'click': 'expand',
</span><ins>+ 'keydown': 'expand',
</ins><span class="cx"> 'touchend': 'expand',
</span><span class="cx"> 'touchmove': 'preventExpand'
</span><span class="cx"> },
</span><span class="lines">@@ -197,7 +198,8 @@
</span><span class="cx"> render: function() {
</span><span class="cx"> var data = this.model.toJSON();
</span><span class="cx"> // Render themes using the html template
</span><del>- this.$el.html( this.html( data ) );
</del><ins>+ this.$el.html( this.html( data ) ).attr( 'tabindex', 0 );
+
</ins><span class="cx"> // Renders active theme styles
</span><span class="cx"> this.activeTheme();
</span><span class="cx">
</span><span class="lines">@@ -219,19 +221,27 @@
</span><span class="cx"> expand: function( event ) {
</span><span class="cx"> var self = this;
</span><span class="cx">
</span><ins>+ event = event || window.event;
+
+ // 'enter' and 'space' keys expand the details view when a theme is :focused
+ if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) {
+ return;
+ }
+
</ins><span class="cx"> // Bail if the user scrolled on a touch device
</span><span class="cx"> if ( this.touchDrag === true ) {
</span><span class="cx"> return this.touchDrag = false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- event = event || window.event;
-
</del><span class="cx"> // Prevent the modal from showing when the user clicks
</span><span class="cx"> // one of the direct action buttons
</span><span class="cx"> if ( $( event.target ).is( '.theme-actions a' ) ) {
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // Set focused theme to current element
+ themes.focusedTheme = this.$el;
+
</ins><span class="cx"> this.trigger( 'theme:expand', self.model.cid );
</span><span class="cx"> },
</span><span class="cx">
</span><span class="lines">@@ -266,6 +276,8 @@
</span><span class="cx"> this.navigation();
</span><span class="cx"> // Checks screenshot size
</span><span class="cx"> this.screenshotCheck( this.$el );
</span><ins>+ // Contain "tabbing" inside the overlay
+ this.containFocus( this.$el );
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> // Adds a class to the currently active theme
</span><span class="lines">@@ -275,6 +287,34 @@
</span><span class="cx"> this.$el.toggleClass( 'active', this.model.get( 'active' ) );
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ // Keeps :focus within the theme details elements
+ containFocus: function( $el ) {
+ var $target;
+
+ // Move focus to the primary action
+ _.delay( function() {
+ $( '.theme-wrap a.button-primary:visible' ).focus();
+ }, 500 );
+
+ $el.on( 'keydown.wp-themes', function( event ) {
+
+ // Tab key
+ if ( event.which === 9 ) {
+ $target = $( event.target );
+
+ // Keep focus within the overlay by making the last link on theme actions
+ // switch focus to button.left on tabbing and vice versa
+ if ( $target.is( 'button.left' ) && event.shiftKey ) {
+ $el.find( '.theme-actions a:last-child' ).focus();
+ event.preventDefault();
+ } else if ( $target.is( '.theme-actions a:last-child' ) ) {
+ $el.find( 'button.left' ).focus();
+ event.preventDefault();
+ }
+ }
+ });
+ },
+
</ins><span class="cx"> // Single theme overlay screen
</span><span class="cx"> // It's shown when clicking a theme
</span><span class="cx"> collapse: function( event ) {
</span><span class="lines">@@ -291,7 +331,7 @@
</span><span class="cx"> // Detect if the click is inside the overlay
</span><span class="cx"> // and don't close it unless the target was
</span><span class="cx"> // the div.back button
</span><del>- if ( $( event.target ).is( '.theme-backdrop' ) || $( event.target ).is( 'div.close' ) || event.keyCode === 27 ) {
</del><ins>+ if ( $( event.target ).is( '.theme-backdrop' ) || $( event.target ).is( '.close' ) || event.keyCode === 27 ) {
</ins><span class="cx">
</span><span class="cx"> // Add a temporary closing class while overlay fades out
</span><span class="cx"> $( 'body' ).addClass( 'closing-overlay' );
</span><span class="lines">@@ -311,6 +351,11 @@
</span><span class="cx">
</span><span class="cx"> // Restore scroll position
</span><span class="cx"> document.body.scrollTop = scroll;
</span><ins>+
+ // Return focus to the theme div
+ if ( themes.focusedTheme ) {
+ themes.focusedTheme.focus();
+ }
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx"> },
</span></span></pre></div>
<a id="branches38srcwpadminthemesphp"></a>
<div class="modfile"><h4>Modified: branches/3.8/src/wp-admin/themes.php (26955 => 26956)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.8/src/wp-admin/themes.php 2014-01-15 08:23:39 UTC (rev 26955)
+++ branches/3.8/src/wp-admin/themes.php 2014-01-15 08:28:04 UTC (rev 26956)
</span><span class="lines">@@ -192,7 +192,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> foreach ( $themes as $theme ) : ?>
</span><del>-<div class="theme<?php if ( $theme['active'] ) echo ' active'; ?>">
</del><ins>+<div class="theme<?php if ( $theme['active'] ) echo ' active'; ?>" tabindex="0">
</ins><span class="cx"> <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
</span><span class="cx"> <div class="theme-screenshot">
</span><span class="cx"> <img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
</span><span class="lines">@@ -309,9 +309,9 @@
</span><span class="cx"> <div class="theme-backdrop"></div>
</span><span class="cx"> <div class="theme-wrap">
</span><span class="cx"> <div class="theme-header">
</span><del>- <div alt="<?php _e( 'Close overlay' ); ?>" class="close dashicons dashicons-no"></div>
- <div alt="<?php _e( 'Show previous theme' ); ?>" class="left dashicons dashicons-no"></div>
- <div alt="<?php _e( 'Show next theme' ); ?>" class="right dashicons dashicons-no"></div>
</del><ins>+ <button alt="<?php _e( 'Show previous theme' ); ?>" class="left dashicons dashicons-no"></button>
+ <button alt="<?php _e( 'Show next theme' ); ?>" class="right dashicons dashicons-no"></button>
+ <button alt="<?php _e( 'Close overlay' ); ?>" class="close dashicons dashicons-no"></button>
</ins><span class="cx"> </div>
</span><span class="cx"> <div class="theme-about">
</span><span class="cx"> <div class="theme-screenshots">
</span></span></pre>
</div>
</div>
</body>
</html>