<!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"> &lt;body class=&quot;&lt;?php echo esc_attr( $body_class ); ?&gt;&quot;&gt;
</span><span class="cx"> &lt;div class=&quot;wp-full-overlay expanded&quot;&gt;
</span><span class="cx">         &lt;form id=&quot;customize-controls&quot; class=&quot;wrap wp-full-overlay-sidebar&quot;&gt;
</span><ins>+                
</ins><span class="cx">                 &lt;div id=&quot;customize-header-actions&quot; class=&quot;wp-full-overlay-header&quot;&gt;
</span><span class="cx">                         &lt;?php
</span><span class="cx">                                 $save_text = $wp_customize-&gt;is_theme_active() ? __( 'Save &amp;amp; Publish' ) : __( 'Save &amp;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">                         ?&gt;
</span><span class="cx">                         &lt;span class=&quot;spinner&quot;&gt;&lt;/span&gt;
</span><span class="cx">                         &lt;a class=&quot;back button&quot; href=&quot;&lt;?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?&gt;&quot;&gt;
</span><span class="cx">                                 &lt;?php _e( 'Cancel' ); ?&gt;
</span><span class="cx">                         &lt;/a&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><del>-
</del><ins>+                
</ins><span class="cx">                 &lt;?php
</span><span class="cx">                         $screenshot = $wp_customize-&gt;theme()-&gt;get_screenshot();
</span><span class="cx">                         $cannot_expand = ! ( $screenshot || $wp_customize-&gt;theme()-&gt;get('Description') );
</span><span class="cx">                 ?&gt;
</span><span class="cx"> 
</span><del>-                &lt;div class=&quot;wp-full-overlay-sidebar-content&quot;&gt;
</del><ins>+                &lt;div class=&quot;wp-full-overlay-sidebar-content&quot; tabindex=&quot;-1&quot;&gt;
</ins><span class="cx">                         &lt;div id=&quot;customize-info&quot; class=&quot;customize-section&lt;?php if ( $cannot_expand ) echo ' cannot-expand'; ?&gt;&quot;&gt;
</span><del>-                                &lt;div class=&quot;customize-section-title&quot;&gt;
</del><ins>+                                &lt;div class=&quot;customize-section-title&quot; aria-label=&quot;&lt;?php esc_attr_e( 'Theme Customizer Options' ); ?&gt;&quot; tabindex=&quot;0&quot;&gt;
</ins><span class="cx">                                         &lt;span class=&quot;preview-notice&quot;&gt;&lt;?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' ), '&lt;strong class=&quot;theme-name&quot;&gt;' . $wp_customize-&gt;theme()-&gt;display('Name') . '&lt;/strong&gt;' );
</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' &amp;&amp;  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' &amp;&amp;  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' &amp;&amp;  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">                         &lt;span class=&quot;customize-control-title&quot;&gt;&lt;?php echo esc_html( $this-&gt;label ); ?&gt;&lt;/span&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;div class=&quot;customize-control-content&quot;&gt;
</span><del>-                                &lt;div class=&quot;dropdown preview-thumbnail&quot;&gt;
</del><ins>+                                &lt;div class=&quot;dropdown preview-thumbnail&quot; tabindex=&quot;0&quot;&gt;
</ins><span class="cx">                                         &lt;div class=&quot;dropdown-content&quot;&gt;
</span><span class="cx">                                                 &lt;?php if ( empty( $src ) ): ?&gt;
</span><span class="cx">                                                         &lt;img style=&quot;display:none;&quot; /&gt;
</span><span class="lines">@@ -537,7 +537,7 @@
</span><span class="cx">                         &lt;div class=&quot;library&quot;&gt;
</span><span class="cx">                                 &lt;ul&gt;
</span><span class="cx">                                         &lt;?php foreach ( $this-&gt;tabs as $id =&gt; $tab ): ?&gt;
</span><del>-                                                &lt;li data-customize-tab='&lt;?php echo esc_attr( $id ); ?&gt;'&gt;
</del><ins>+                                                &lt;li data-customize-tab='&lt;?php echo esc_attr( $id ); ?&gt;' tabindex='0'&gt;
</ins><span class="cx">                                                         &lt;?php echo esc_html( $tab['label'] ); ?&gt;
</span><span class="cx">                                                 &lt;/li&gt;
</span><span class="cx">                                         &lt;?php endforeach; ?&gt;
</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">                 ?&gt;
</span><span class="cx">                 &lt;li id=&quot;customize-section-&lt;?php echo esc_attr( $this-&gt;id ); ?&gt;&quot; class=&quot;control-section customize-section&quot;&gt;
</span><del>-                        &lt;h3 class=&quot;customize-section-title&quot; title=&quot;&lt;?php echo esc_attr( $this-&gt;description ); ?&gt;&quot;&gt;&lt;?php echo esc_html( $this-&gt;title ); ?&gt;&lt;/h3&gt;
</del><ins>+                        &lt;h3 class=&quot;customize-section-title&quot; tabindex=&quot;0&quot; title=&quot;&lt;?php echo esc_attr( $this-&gt;description ); ?&gt;&quot;&gt;&lt;?php echo esc_html( $this-&gt;title ); ?&gt;&lt;/h3&gt;
</ins><span class="cx">                         &lt;ul class=&quot;customize-section-content&quot;&gt;
</span><span class="cx">                                 &lt;?php
</span><span class="cx">                                 foreach ( $this-&gt;controls as $control )
</span></span></pre>
</div>
</div>

</body>
</html>