<!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>[29321] trunk/src/wp-includes: wpLink: add keyboard navigation, improve accessibility.</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/29321">29321</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2014-07-29 03:15:34 +0000 (Tue, 29 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>wpLink: add keyboard navigation, improve accessibility. Props afercia, fixes <a href="http://core.trac.wordpress.org/ticket/28897">#28897</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpeditorphp">trunk/src/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunksrcwpincludescsseditorcss">trunk/src/wp-includes/css/editor.css</a></li>
<li><a href="#trunksrcwpincludesjswplinkjs">trunk/src/wp-includes/js/wplink.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/class-wp-editor.php (29320 => 29321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/class-wp-editor.php        2014-07-29 01:40:24 UTC (rev 29320)
+++ trunk/src/wp-includes/class-wp-editor.php   2014-07-29 03:15:34 UTC (rev 29321)
</span><span class="lines">@@ -1376,7 +1376,7 @@
</span><span class="cx">          <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
</span><span class="cx">          <div id="link-modal-title">
</span><span class="cx">                  <?php _e( 'Insert/edit link' ) ?>
</span><del>-                       <div id="wp-link-close" tabindex="0"></div>
</del><ins>+                        <button id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
</ins><span class="cx">           </div>
</span><span class="cx">          <div id="link-selector">
</span><span class="cx">                  <div id="link-options">
</span><span class="lines">@@ -1391,7 +1391,7 @@
</span><span class="cx">                                  <label><span>&nbsp;</span><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
</span><span class="cx">                          </div>
</span><span class="cx">                  </div>
</span><del>-                       <p class="howto" id="wp-link-search-toggle"><?php _e( 'Or link to existing content' ); ?></p>
</del><ins>+                        <p class="howto"><a href="#" id="wp-link-search-toggle"><?php _e( 'Or link to existing content' ); ?></a></p>
</ins><span class="cx">                   <div id="search-panel">
</span><span class="cx">                          <div class="link-search-wrapper">
</span><span class="cx">                                  <label>
</span><span class="lines">@@ -1400,14 +1400,17 @@
</span><span class="cx">                                          <span class="spinner"></span>
</span><span class="cx">                                  </label>
</span><span class="cx">                          </div>
</span><del>-                               <div id="search-results" class="query-results">
</del><ins>+                                <div id="search-results" class="query-results" tabindex="0">
</ins><span class="cx">                                   <ul></ul>
</span><span class="cx">                                  <div class="river-waiting">
</span><span class="cx">                                          <span class="spinner"></span>
</span><span class="cx">                                  </div>
</span><span class="cx">                          </div>
</span><del>-                               <div id="most-recent-results" class="query-results">
-                                       <div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div>
</del><ins>+                                <div id="most-recent-results" class="query-results" tabindex="0">
+                                       <div class="query-notice" id="query-notice-message">
+                                               <em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em>
+                                               <em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em>
+                                       </div>
</ins><span class="cx">                                   <ul></ul>
</span><span class="cx">                                  <div class="river-waiting">
</span><span class="cx">                                          <span class="spinner"></span>
</span><span class="lines">@@ -1416,12 +1419,12 @@
</span><span class="cx">                  </div>
</span><span class="cx">          </div>
</span><span class="cx">          <div class="submitbox">
</span><ins>+                       <div id="wp-link-cancel">
+                               <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
+                       </div>
</ins><span class="cx">                   <div id="wp-link-update">
</span><span class="cx">                          <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit">
</span><span class="cx">                  </div>
</span><del>-                       <div id="wp-link-cancel">
-                               <a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
-                       </div>
</del><span class="cx">           </div>
</span><span class="cx">          </form>
</span><span class="cx">          </div>
</span></span></pre></div>
<a id="trunksrcwpincludescsseditorcss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/css/editor.css (29320 => 29321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/css/editor.css     2014-07-29 01:40:24 UTC (rev 29320)
+++ trunk/src/wp-includes/css/editor.css        2014-07-29 03:15:34 UTC (rev 29321)
</span><span class="lines">@@ -79,19 +79,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .mce-textbox,
</span><del>-.mce-checkbox i.mce-i-checkbox {
</del><ins>+.mce-checkbox i.mce-i-checkbox,
+#wp-link .query-results {
</ins><span class="cx">   border: 1px solid #ddd;
</span><span class="cx">  -webkit-border-radius: 0;
</span><span class="cx">  border-radius: 0;
</span><span class="cx">  -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
</span><span class="cx">  box-shadow: inset 0 1px 2px rgba(0,0,0,0.07);
</span><del>-       -webkit-transition: .05s border-color ease-in-out;
-       transition: .05s border-color ease-in-out;
</del><ins>+        -webkit-transition: .05s all ease-in-out;
+       transition: .05s all ease-in-out;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .mce-textbox:focus,
</span><span class="cx"> .mce-textbox.mce-focus,
</span><del>-.mce-checkbox:focus i.mce-i-checkbox {
</del><ins>+.mce-checkbox:focus i.mce-i-checkbox,
+#wp-link .query-results:focus {
</ins><span class="cx">   border-color: #5b9dd9;
</span><span class="cx">  -webkit-box-shadow: 0 0 2px rgba(30,140,190,0.8);
</span><span class="cx">  box-shadow: 0 0 2px rgba(30,140,190,0.8);
</span><span class="lines">@@ -1061,7 +1063,6 @@
</span><span class="cx"> 
</span><span class="cx"> #wp-link-close {
</span><span class="cx">  color: #666;
</span><del>-       cursor: pointer;
</del><span class="cx">   padding: 0;
</span><span class="cx">  position: absolute;
</span><span class="cx">  top: 0;
</span><span class="lines">@@ -1069,6 +1070,9 @@
</span><span class="cx">  width: 36px;
</span><span class="cx">  height: 36px;
</span><span class="cx">  text-align: center;
</span><ins>+       background: none;
+       border: none;
+       cursor: pointer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #wp-link-close:before {
</span><span class="lines">@@ -1087,6 +1091,16 @@
</span><span class="cx">  color: #2ea2cc;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#wp-link-close:focus {
+       outline: none;
+       -webkit-box-shadow:
+               0 0 0 1px #5b9dd9,
+               0 0 2px 1px rgba(30, 140, 190, .8);
+       box-shadow:
+               0 0 0 1px #5b9dd9,
+               0 0 2px 1px rgba(30, 140, 190, .8);
+}
+
</ins><span class="cx"> #link-selector {
</span><span class="cx">  padding: 0 16px 50px;
</span><span class="cx"> }
</span><span class="lines">@@ -1135,6 +1149,11 @@
</span><span class="cx">  margin: 3px 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#wp-link p.howto a {
+       text-decoration: none;
+       color: inherit;
+}
+
</ins><span class="cx"> #wp-link-search-toggle {
</span><span class="cx">  cursor: pointer;
</span><span class="cx"> }
</span><span class="lines">@@ -1198,17 +1217,46 @@
</span><span class="cx">  top: 205px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#wp-link li,
-#wp-link .query-notice {
</del><ins>+#wp-link li {
</ins><span class="cx">   clear: both;
</span><span class="cx">  margin-bottom: 0;
</span><span class="cx">  border-bottom: 1px solid #f1f1f1;
</span><span class="cx">  color: #333;
</span><del>-       padding: 4px 6px;
</del><ins>+        padding: 4px 6px 4px 10px;
</ins><span class="cx">   cursor: pointer;
</span><span class="cx">  position: relative;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#wp-link .query-notice {
+       padding: 0;
+       border-bottom: 1px solid #dfdfdf;
+       background-color: #f7fcfe;
+       color: #000;
+}
+
+#wp-link .query-notice .query-notice-default,
+#wp-link .query-notice .query-notice-hint {
+       display: block;
+       padding: 6px;
+       border-left: 4px solid #2ea2cc;
+}
+
+#wp-link .unselectable.no-matches-found {
+       padding: 0;
+       border-bottom: 1px solid #dfdfdf;
+       background-color: #fef7f1;
+}
+
+#wp-link .no-matches-found .item-title {
+       display: block;
+       padding: 6px;
+       border-left: 4px solid #d54e21;
+}
+
+#wp-link .query-results em {
+       font-style: normal;
+}
+
</ins><span class="cx"> #wp-link li:hover {
</span><span class="cx">  background: #eaf2fa;
</span><span class="cx">  color: #151515;
</span><span class="lines">@@ -1285,6 +1333,7 @@
</span><span class="cx"> 
</span><span class="cx"> #wp-link-cancel {
</span><span class="cx">  line-height: 25px;
</span><ins>+       float: left;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #wp-link-update {
</span></span></pre></div>
<a id="trunksrcwpincludesjswplinkjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/wplink.js (29320 => 29321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/wplink.js       2014-07-29 01:40:24 UTC (rev 29320)
+++ trunk/src/wp-includes/js/wplink.js  2014-07-29 03:15:34 UTC (rev 29321)
</span><span class="lines">@@ -31,6 +31,11 @@
</span><span class="cx">                  rivers.recent = new River( $( '#most-recent-results' ) );
</span><span class="cx">                  rivers.elements = inputs.dialog.find( '.query-results' );
</span><span class="cx"> 
</span><ins>+                       // Get search notice text
+                       inputs.queryNotice = $( '#query-notice-message' );
+                       inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
+                       inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
+
</ins><span class="cx">                   // Bind event handlers
</span><span class="cx">                  inputs.dialog.keydown( wpLink.keydown );
</span><span class="cx">                  inputs.dialog.keyup( wpLink.keyup );
</span><span class="lines">@@ -43,10 +48,19 @@
</span><span class="cx">                          wpLink.close();
</span><span class="cx">                  });
</span><span class="cx"> 
</span><del>-                       $( '#wp-link-search-toggle' ).click( wpLink.toggleInternalLinking );
</del><ins>+                        $( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );
</ins><span class="cx"> 
</span><span class="cx">                  rivers.elements.on( 'river-select', wpLink.updateFields );
</span><span class="cx"> 
</span><ins>+                       // Display 'hint' message when search field or 'query-results' box are focused
+                       inputs.search.add( rivers.elements ).on( 'focus.wplink', function() {
+                               inputs.queryNoticeTextDefault.hide();
+                               inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
+                       } ).on( 'blur.wplink', function() {
+                               inputs.queryNoticeTextDefault.show();
+                               inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
+                       } );
+
</ins><span class="cx">                   inputs.search.keyup( function() {
</span><span class="cx">                          var self = this;
</span><span class="cx"> 
</span><span class="lines">@@ -335,6 +349,8 @@
</span><span class="cx">                  } else if ( key.TAB === event.keyCode ) {
</span><span class="cx">                          id = event.target.id;
</span><span class="cx"> 
</span><ins>+                               // wp-link-submit must always be the last focusable element in the dialog.
+                               // following focusable elements will be skipped on keyboard navigation.
</ins><span class="cx">                           if ( id === 'wp-link-submit' && ! event.shiftKey ) {
</span><span class="cx">                                  inputs.close.focus();
</span><span class="cx">                                  event.preventDefault();
</span><span class="lines">@@ -391,12 +407,13 @@
</span><span class="cx">                  };
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               toggleInternalLinking: function() {
</del><ins>+                toggleInternalLinking: function( event ) {
</ins><span class="cx">                   var visible = inputs.wrap.hasClass( 'search-panel-visible' );
</span><span class="cx"> 
</span><span class="cx">                  inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
</span><span class="cx">                  setUserSetting( 'wplink', visible ? '0' : '1' );
</span><span class="cx">                  inputs[ ! visible ? 'search' : 'url' ].focus();
</span><ins>+                       event.preventDefault();
</ins><span class="cx">           }
</span><span class="cx">  };
</span><span class="cx"> 
</span><span class="lines">@@ -506,7 +523,7 @@
</span><span class="cx"> 
</span><span class="cx">                  if ( ! results ) {
</span><span class="cx">                          if ( firstPage ) {
</span><del>-                                       list += '<li class="unselectable"><span class="item-title"><em>' +
</del><ins>+                                        list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
</ins><span class="cx">                                           wpLinkL10n.noMatchesFound + '</em></span></li>';
</span><span class="cx">                          }
</span><span class="cx">                  } else {
</span></span></pre>
</div>
</div>

</body>
</html>