mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
wpLink:
- 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. git-svn-id: https://develop.svn.wordpress.org/trunk@29333 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cba848581b
commit
0ef495da6a
@ -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">
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user