Make WordPress Core

Changeset 29333


Ignore:
Timestamp:
07/31/2014 11:27:14 PM (11 years ago)
Author:
azaozz
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-editor.php

    r29321 r29333  
    13771377        <div id="link-modal-title">
    13781378            <?php _e( 'Insert/edit link' ) ?>
    1379             <button id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
     1379            <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
    13801380        </div>
    13811381        <div id="link-selector">
  • trunk/src/wp-includes/js/wplink.js

    r29321 r29333  
    33
    44( function( $ ) {
    5     var inputs = {}, rivers = {}, editor, searchTimer, River, Query;
     5    var editor, searchTimer, River, Query,
     6        inputs = {},
     7        rivers = {},
     8        isTouch = ( 'ontouchend' in document );
    69
    710    wpLink = {
     
    5457
    5558            // Display 'hint' message when search field or 'query-results' box are focused
    56             inputs.search.add( rivers.elements ).on( 'focus.wplink', function() {
     59            inputs.search.on( 'focus.wplink', function() {
    5760                inputs.queryNoticeTextDefault.hide();
    5861                inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
     
    121124            rivers.recent.refresh();
    122125
    123             if ( wpLink.isMCE() )
     126            if ( wpLink.isMCE() ) {
    124127                wpLink.mceRefresh();
    125             else
     128            } else {
    126129                wpLink.setDefaultValues();
    127 
    128             // Focus the URL field and highlight its contents.
    129             //     If this is moved above the selection changes,
    130             //     IE will show a flashing cursor over the dialog.
    131             inputs.url.focus()[0].select();
     130            }
     131
     132            if ( isTouch ) {
     133                // Close the onscreen keyboard
     134                inputs.url.focus().blur();
     135            } else {
     136                // Focus the URL field and highlight its contents.
     137                // If this is moved above the selection changes,
     138                // IE will show a flashing cursor over the dialog.
     139                inputs.url.focus()[0].select();
     140            }
     141
    132142            // Load the most recent results if this is the first time opening the panel.
    133             if ( ! rivers.recent.ul.children().length )
     143            if ( ! rivers.recent.ul.children().length ) {
    134144                rivers.recent.ajax();
     145            }
    135146        },
    136147
     
    275286        },
    276287
    277         updateFields: function( e, li, originalEvent ) {
     288        updateFields: function( e, li ) {
    278289            inputs.url.val( li.children( '.item-permalink' ).val() );
    279290            inputs.title.val( li.hasClass( 'no-title' ) ? '' : li.children( '.item-title' ).text() );
    280             if ( originalEvent && originalEvent.type == 'click' )
    281                 inputs.url.focus();
    282291        },
    283292
     
    365374            }
    366375
    367             if ( inputs.url.is( ':focus' ) || inputs.title.is( ':focus' ) ) {
     376            if ( document.activeElement &&
     377                ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
    368378                return;
    369379            }
Note: See TracChangeset for help on using the changeset viewer.