Make WordPress Core

Changeset 25031


Ignore:
Timestamp:
08/15/2013 09:43:29 PM (12 years ago)
Author:
helen
Message:

Only set and run internal search for linking selected text if the panel is open. Make sure the focus is in the URL field whenever opening the linking modal to preserve previous behavior. props greuben. fixes #16276.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/wplink.js

    r24841 r25031  
    280280        },
    281281        setDefaultValues : function() {
    282             var selectedText,
    283                 textarea = wpLink.textarea;
    284 
    285282            // Set URL and description to defaults.
    286283            // Leave the new tab setting as-is.
    287284            inputs.url.val('http://');
    288285            inputs.title.val('');
    289             if ( wpLink.isMCE() ) {
    290                 selectedText = tinyMCEPopup.editor.selection.getContent( { format: 'text' } );
    291             } else {
    292                 if ( document.selection && wpLink.range ) {
    293                     selectedText = wpLink.range.text;
    294                 } else if ( typeof textarea.selectionStart !== 'undefined' ) {
    295                     selectedText = textarea.value.substring( textarea.selectionStart, textarea.selectionEnd );
     286
     287            if ( $('#search-panel').is(':visible') ) {
     288                var selectedText,
     289                    textarea = wpLink.textarea;
     290
     291                if ( wpLink.isMCE() ) {
     292                    selectedText = tinyMCEPopup.editor.selection.getContent( { format: 'text' } );
     293                } else {
     294                    if ( document.selection && wpLink.range ) {
     295                        selectedText = wpLink.range.text;
     296                    } else if ( 'undefined' !== typeof textarea.selectionStart ) {
     297                        selectedText = textarea.value.substring( textarea.selectionStart, textarea.selectionEnd );
     298                    }
    296299                }
    297             }
    298             if ( selectedText && ( selectedText = selectedText.replace( /^\s+|\s+$/g, '' ) ) ) {
    299                 if ( ! $('#search-panel').is(':visible') )
    300                     $('#internal-toggle').trigger('click');
    301                 inputs.search.val( selectedText ).trigger('keyup');
     300
     301                if ( selectedText && ( selectedText = selectedText.replace( /^\s+|\s+$/g, '' ) ) ) {
     302                    inputs.search.val( selectedText ).trigger('keyup');
     303                }
    302304            }
    303305
Note: See TracChangeset for help on using the changeset viewer.