- Fix adding a link on pressing Enter.
- Don't auto-focus the URL field after selecting a local link.
- Don't auto-focus the URL field when opening on touch devices. Toggle focus/blur on it to close the onscreen keyboard so the modal is positioned properly.
See #28897.
Built from https://develop.svn.wordpress.org/trunk@29333


git-svn-id: http://core.svn.wordpress.org/trunk@29113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-07-31 23:28:19 +00:00
parent 4bff4ff2d6
commit d15f9617f9
4 changed files with 26 additions and 16 deletions

View File

@ -1376,7 +1376,7 @@ final class _WP_Editors {
<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
<div id="link-modal-title">
<?php _e( 'Insert/edit link' ) ?>
<button id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
<button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
</div>
<div id="link-selector">
<div id="link-options">

View File

@ -2,7 +2,10 @@
var wpLink;
( function( $ ) {
var inputs = {}, rivers = {}, editor, searchTimer, River, Query;
var editor, searchTimer, River, Query,
inputs = {},
rivers = {},
isTouch = ( 'ontouchend' in document );
wpLink = {
timeToTriggerRiver: 150,
@ -53,7 +56,7 @@ var wpLink;
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.search.on( 'focus.wplink', function() {
inputs.queryNoticeTextDefault.hide();
inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
} ).on( 'blur.wplink', function() {
@ -120,18 +123,26 @@ var wpLink;
rivers.search.refresh();
rivers.recent.refresh();
if ( wpLink.isMCE() )
if ( wpLink.isMCE() ) {
wpLink.mceRefresh();
else
} else {
wpLink.setDefaultValues();
}
if ( isTouch ) {
// Close the onscreen keyboard
inputs.url.focus().blur();
} else {
// Focus the URL field and highlight its contents.
// If this is moved above the selection changes,
// IE will show a flashing cursor over the dialog.
inputs.url.focus()[0].select();
}
// Load the most recent results if this is the first time opening the panel.
if ( ! rivers.recent.ul.children().length )
if ( ! rivers.recent.ul.children().length ) {
rivers.recent.ajax();
}
},
mceRefresh: function() {
@ -274,11 +285,9 @@ var wpLink;
editor.selection.collapse();
},
updateFields: function( e, li, originalEvent ) {
updateFields: function( e, li ) {
inputs.url.val( li.children( '.item-permalink' ).val() );
inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
if ( originalEvent && originalEvent.type == 'click' )
inputs.url.focus();
},
setDefaultValues: function() {
@ -364,7 +373,8 @@ var wpLink;
return;
}
if ( inputs.url.is( ':focus' ) || inputs.title.is( ':focus' ) ) {
if ( document.activeElement &&
( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
return;
}

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.0-beta2-20140730';
$wp_version = '4.0-beta2-20140731';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.