<!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>[22400] trunk: Keyboard accessibility for the theme customizer.</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, #logmsg > ol { margin-left: 0; 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/22400">22400</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-11-06 14:47:25 +0000 (Tue, 06 Nov 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Keyboard accessibility for the theme customizer. props lessbloat, jorbin, JustinSainton. fixes <a href="http://core.trac.wordpress.org/ticket/21283">#21283</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsscustomizecontrolscss">trunk/wp-admin/css/customize-controls.css</a></li>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadmincustomizephp">trunk/wp-admin/customize.php</a></li>
<li><a href="#trunkwpadminjscustomizecontrolsjs">trunk/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunkwpincludesclasswpcustomizecontrolphp">trunk/wp-includes/class-wp-customize-control.php</a></li>
<li><a href="#trunkwpincludesclasswpcustomizesectionphp">trunk/wp-includes/class-wp-customize-section.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsscustomizecontrolscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/customize-controls.css (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/customize-controls.css        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-admin/css/customize-controls.css        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -67,7 +67,8 @@
</span><span class="cx">
</span><span class="cx"> .control-section:hover .customize-section-title,
</span><span class="cx"> .control-section .customize-section-title:hover,
</span><del>-.control-section.open .customize-section-title {
</del><ins>+.control-section.open .customize-section-title,
+.customize-section-title:focus {
</ins><span class="cx">         color: #fff;
</span><span class="cx">         text-shadow: 0 -1px 0 #333;
</span><span class="cx">         background: #808080;
</span><span class="lines">@@ -126,6 +127,11 @@
</span><span class="cx">         color: #999;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#customize-info .customize-section-title:focus .preview-notice {
+        color: #ccc;
+        text-shadow: 0 -1px 0 #333;
+}
+
</ins><span class="cx"> #customize-info .theme-name {
</span><span class="cx">         font-size: 20px;
</span><span class="cx">         font-weight: 200;
</span><span class="lines">@@ -135,6 +141,11 @@
</span><span class="cx">         text-shadow: 0 1px 0 #fff;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#customize-info .customize-section-title:focus .theme-name {
+        color: #fff;
+        text-shadow: 0 -1px 0 #333;
+}
+
</ins><span class="cx"> #customize-info .theme-screenshot {
</span><span class="cx">         width: 258px;
</span><span class="cx">         border: 1px solid #ccc;
</span><span class="lines">@@ -155,16 +166,19 @@
</span><span class="cx">         margin: 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#customize-footer-actions .button-primary,
</ins><span class="cx"> #customize-header-actions .button-primary {
</span><span class="cx">         float: right;
</span><span class="cx">         margin-top: 10px;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#customize-footer-actions .spinner,
</ins><span class="cx"> #customize-header-actions .spinner {
</span><span class="cx">         margin-top: 16px;
</span><span class="cx">         margin-right: 4px;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+.saving #customize-footer-actions .spinner,
</ins><span class="cx"> .saving #customize-header-actions .spinner {
</span><span class="cx">         display: block;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-admin/css/wp-admin.css        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -5571,8 +5571,7 @@
</span><span class="cx">         height: 100%;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-.wp-full-overlay-sidebar .wp-full-overlay-header,
-.wp-full-overlay-sidebar .wp-full-overlay-footer {
</del><ins>+.wp-full-overlay-sidebar .wp-full-overlay-header {
</ins><span class="cx">         position: absolute;
</span><span class="cx">         left: 0;
</span><span class="cx">         right: 0;
</span><span class="lines">@@ -5583,13 +5582,6 @@
</span><span class="cx">         margin: 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-.wp-full-overlay-sidebar .wp-full-overlay-header {
-        top: 0;
-        border-top: 0;
-        border-bottom: 1px solid #fff;
-        box-shadow: inset 0 -1px 0 0px #dfdfdf;
-}
-
</del><span class="cx"> .wp-full-overlay-sidebar .wp-full-overlay-footer {
</span><span class="cx">         bottom: 0;
</span><span class="cx">         border-bottom: 0;
</span><span class="lines">@@ -5638,11 +5630,11 @@
</span><span class="cx">         display: block;
</span><span class="cx">         width: 15px;
</span><span class="cx">         height: 15px;
</span><del>-        background: transparent url('../images/arrows.png') no-repeat 0 -72px;
</del><ins>+        background: transparent url('../images/arrows.png') no-repeat -1px -73px;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .wp-full-overlay.collapsed .collapse-sidebar-arrow {
</span><del>-        background-position: 0 -108px;
</del><ins>+        background-position: -1px -109px;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .wp-full-overlay .collapse-sidebar-label {
</span></span></pre></div>
<a id="trunkwpadmincustomizephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/customize.php (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/customize.php        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-admin/customize.php        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -67,25 +67,26 @@
</span><span class="cx"> <body class="<?php echo esc_attr( $body_class ); ?>">
</span><span class="cx"> <div class="wp-full-overlay expanded">
</span><span class="cx">         <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
</span><ins>+                
</ins><span class="cx">                 <div id="customize-header-actions" class="wp-full-overlay-header">
</span><span class="cx">                         <?php
</span><span class="cx">                                 $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
</span><del>-                                submit_button( $save_text, 'primary', 'save', false );
</del><ins>+                                submit_button( $save_text, 'primary save', 'save', false );
</ins><span class="cx">                         ?>
</span><span class="cx">                         <span class="spinner"></span>
</span><span class="cx">                         <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
</span><span class="cx">                                 <?php _e( 'Cancel' ); ?>
</span><span class="cx">                         </a>
</span><span class="cx">                 </div>
</span><del>-
</del><ins>+                
</ins><span class="cx">                 <?php
</span><span class="cx">                         $screenshot = $wp_customize->theme()->get_screenshot();
</span><span class="cx">                         $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
</span><span class="cx">                 ?>
</span><span class="cx">
</span><del>-                <div class="wp-full-overlay-sidebar-content">
</del><ins>+                <div class="wp-full-overlay-sidebar-content" tabindex="-1">
</ins><span class="cx">                         <div id="customize-info" class="customize-section<?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
</span><del>-                                <div class="customize-section-title">
</del><ins>+                                <div class="customize-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
</ins><span class="cx">                                         <span class="preview-notice"><?php
</span><span class="cx">                                                 /* translators: %s is the theme name in the Customize/Live Preview pane */
</span><span class="cx">                                                 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
</span></span></pre></div>
<a id="trunkwpadminjscustomizecontrolsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/customize-controls.js (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/customize-controls.js        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-admin/js/customize-controls.js        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -94,11 +94,21 @@
</span><span class="cx">                                         else
</span><span class="cx">                                                 statuses.hide();
</span><span class="cx">                                 };
</span><del>-
</del><ins>+                        
+                        var toggleFreeze = false;
+                        
</ins><span class="cx">                         // Support the .dropdown class to open/close complex elements
</span><del>-                        this.container.on( 'click', '.dropdown', function( event ) {
</del><ins>+                        this.container.on( 'click focus', '.dropdown', function( event ) {
</ins><span class="cx">                                 event.preventDefault();
</span><del>-                                control.container.toggleClass('open');
</del><ins>+                                
+                                if (!toggleFreeze)
+                                        control.container.toggleClass('open');
+                                
+                                // Don't want to fire focus and click at same time
+                                toggleFreeze = true;
+                                setTimeout(function () {
+                                        toggleFreeze = false;
+                                }, 400);
</ins><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         this.setting.bind( update );
</span><span class="lines">@@ -210,7 +220,11 @@
</span><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         // Bind tab switch events
</span><del>-                        this.library.children('ul').on( 'click', 'li', function( event ) {
</del><ins>+                        this.library.children('ul').on( 'click keydown', 'li', function( event ) {
+                                
+                                if ( event.type === 'keydown' && 13 !== event.which )
+                                        return;
+                                
</ins><span class="cx">                                 var id = $(this).data('customizeTab'),
</span><span class="cx">                                         tab = control.tabs[ id ];
</span><span class="cx">
</span><span class="lines">@@ -225,7 +239,10 @@
</span><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         // Bind events to switch image urls.
</span><del>-                        this.library.on( 'click', 'a', function( event ) {
</del><ins>+                        this.library.on( 'click keydown', 'a', function( event ) {
+                         if ( event.type === 'keydown' && 13 !== event.which ) // enter
+                                        return;
+
</ins><span class="cx">                                 var value = $(this).data('customizeImageValue');
</span><span class="cx">
</span><span class="cx">                                 if ( value ) {
</span><span class="lines">@@ -814,11 +831,26 @@
</span><span class="cx">                 }());
</span><span class="cx">
</span><span class="cx">                 // Temporary accordion code.
</span><del>-                $('.customize-section-title').click( function( event ) {
</del><ins>+                var accordionFrozen = false;
+                $('.customize-section-title').bind('click keydown', function( event ) {
+                        
+                        if ( event.type === 'keydown' && 13 !== event.which ) // enter
+                                        return;
+                        
</ins><span class="cx">                         var clicked = $( this ).parents( '.customize-section' );
</span><span class="cx">
</span><del>-                        if ( clicked.hasClass('cannot-expand') )
</del><ins>+                        if ( clicked.hasClass('cannot-expand') || accordionFrozen )
</ins><span class="cx">                                 return;
</span><ins>+                        
+                        // Don't want to fire focus and click at same time
+                        accordionFrozen = true;
+                        setTimeout(function () {
+                                accordionFrozen = false;
+                        }, 400);
+                        
+                        // Scroll up if on #customize-section-title_tagline
+                        if ('customize-section-title_tagline' === clicked.attr('id'))
+                                $('.wp-full-overlay-sidebar-content').scrollTop(0);
</ins><span class="cx">
</span><span class="cx">                         $( '.customize-section' ).not( clicked ).removeClass( 'open' );
</span><span class="cx">                         clicked.toggleClass( 'open' );
</span><span class="lines">@@ -829,7 +861,22 @@
</span><span class="cx">                 $('#save').click( function( event ) {
</span><span class="cx">                         previewer.save();
</span><span class="cx">                         event.preventDefault();
</span><ins>+                }).keydown( function( event ) {
+                        if ( 9 === event.which ) // tab
+                                return;
+                        if ( 13 === event.which ) // enter
+                                previewer.save();
+                        event.preventDefault();
</ins><span class="cx">                 });
</span><ins>+                
+                $('.back').keydown( function( event ) {
+                        if ( 9 === event.which ) // tab
+                                return;
+                        var thisHref = $(this).attr('href');
+                        if ( 13 === event.which ) // enter
+                                window.location = thisHref;
+                        event.preventDefault();
+                });
</ins><span class="cx">
</span><span class="cx">                 $('.collapse-sidebar').click( function( event ) {
</span><span class="cx">                         overlay.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
</span><span class="lines">@@ -948,6 +995,14 @@
</span><span class="cx">                 });
</span><span class="cx">
</span><span class="cx">                 api.trigger( 'ready' );
</span><ins>+
+                // Make sure left column gets focus
+                var topFocus = $('.back');
+                topFocus.focus();
+                setTimeout(function () {
+                        topFocus.focus();
+                }, 200);
+
</ins><span class="cx">         });
</span><span class="cx">
</span><del>-})( wp, jQuery );
</del><span class="cx">\ No newline at end of file
</span><ins>+})( wp, jQuery );
</ins></span></pre></div>
<a id="trunkwpincludesclasswpcustomizecontrolphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize-control.php (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize-control.php        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-includes/class-wp-customize-control.php        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -521,7 +521,7 @@
</span><span class="cx">                         <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
</span><span class="cx">
</span><span class="cx">                         <div class="customize-control-content">
</span><del>-                                <div class="dropdown preview-thumbnail">
</del><ins>+                                <div class="dropdown preview-thumbnail" tabindex="0">
</ins><span class="cx">                                         <div class="dropdown-content">
</span><span class="cx">                                                 <?php if ( empty( $src ) ): ?>
</span><span class="cx">                                                         <img style="display:none;" />
</span><span class="lines">@@ -537,7 +537,7 @@
</span><span class="cx">                         <div class="library">
</span><span class="cx">                                 <ul>
</span><span class="cx">                                         <?php foreach ( $this->tabs as $id => $tab ): ?>
</span><del>-                                                <li data-customize-tab='<?php echo esc_attr( $id ); ?>'>
</del><ins>+                                                <li data-customize-tab='<?php echo esc_attr( $id ); ?>' tabindex='0'>
</ins><span class="cx">                                                         <?php echo esc_html( $tab['label'] ); ?>
</span><span class="cx">                                                 </li>
</span><span class="cx">                                         <?php endforeach; ?>
</span></span></pre></div>
<a id="trunkwpincludesclasswpcustomizesectionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize-section.php (22399 => 22400)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize-section.php        2012-11-06 14:46:56 UTC (rev 22399)
+++ trunk/wp-includes/class-wp-customize-section.php        2012-11-06 14:47:25 UTC (rev 22400)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">         protected function render() {
</span><span class="cx">                 ?>
</span><span class="cx">                 <li id="customize-section-<?php echo esc_attr( $this->id ); ?>" class="control-section customize-section">
</span><del>-                        <h3 class="customize-section-title" title="<?php echo esc_attr( $this->description ); ?>"><?php echo esc_html( $this->title ); ?></h3>
</del><ins>+                        <h3 class="customize-section-title" tabindex="0" title="<?php echo esc_attr( $this->description ); ?>"><?php echo esc_html( $this->title ); ?></h3>
</ins><span class="cx">                         <ul class="customize-section-content">
</span><span class="cx">                                 <?php
</span><span class="cx">                                 foreach ( $this->controls as $control )
</span></span></pre>
</div>
</div>
</body>
</html>