wpLink: add keyboard navigation, improve accessibility. Props afercia, fixes #28897.
Built from https://develop.svn.wordpress.org/trunk@29321 git-svn-id: http://core.svn.wordpress.org/trunk@29102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -31,6 +31,11 @@ var wpLink;
|
||||
rivers.recent = new River( $( '#most-recent-results' ) );
|
||||
rivers.elements = inputs.dialog.find( '.query-results' );
|
||||
|
||||
// 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' );
|
||||
|
||||
// Bind event handlers
|
||||
inputs.dialog.keydown( wpLink.keydown );
|
||||
inputs.dialog.keyup( wpLink.keyup );
|
||||
@@ -43,10 +48,19 @@ var wpLink;
|
||||
wpLink.close();
|
||||
});
|
||||
|
||||
$( '#wp-link-search-toggle' ).click( wpLink.toggleInternalLinking );
|
||||
$( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );
|
||||
|
||||
rivers.elements.on( 'river-select', wpLink.updateFields );
|
||||
|
||||
// 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();
|
||||
} );
|
||||
|
||||
inputs.search.keyup( function() {
|
||||
var self = this;
|
||||
|
||||
@@ -335,6 +349,8 @@ var wpLink;
|
||||
} else if ( key.TAB === event.keyCode ) {
|
||||
id = event.target.id;
|
||||
|
||||
// wp-link-submit must always be the last focusable element in the dialog.
|
||||
// following focusable elements will be skipped on keyboard navigation.
|
||||
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
|
||||
inputs.close.focus();
|
||||
event.preventDefault();
|
||||
@@ -391,12 +407,13 @@ var wpLink;
|
||||
};
|
||||
},
|
||||
|
||||
toggleInternalLinking: function() {
|
||||
toggleInternalLinking: function( event ) {
|
||||
var visible = inputs.wrap.hasClass( 'search-panel-visible' );
|
||||
|
||||
inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
|
||||
setUserSetting( 'wplink', visible ? '0' : '1' );
|
||||
inputs[ ! visible ? 'search' : 'url' ].focus();
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -506,7 +523,7 @@ var wpLink;
|
||||
|
||||
if ( ! results ) {
|
||||
if ( firstPage ) {
|
||||
list += '<li class="unselectable"><span class="item-title"><em>' +
|
||||
list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
|
||||
wpLinkL10n.noMatchesFound + '</em></span></li>';
|
||||
}
|
||||
} else {
|
||||
|
||||
2
wp-includes/js/wplink.min.js
vendored
2
wp-includes/js/wplink.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user