Make WordPress Core

Changeset 36777


Ignore:
Timestamp:
02/29/2016 07:37:42 PM (11 years ago)
Author:
azaozz
Message:

TinyMCE, inline link:

  • Fix running wpLink without tinymce.js and the TinyMCE plugin without wplink.js.
  • Do not show the Advanced button in the inline link dialog when wpLink is not loaded.

See #33301.

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

Legend:

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

    r36747 r36777  
    145145                                ], true );
    146146
    147                                 editToolbar = editor.wp._createToolbar( [
     147                                var editButtons = [
    148148                                        'wp_link_input',
    149                                         'wp_link_apply',
    150                                         'wp_link_advanced'
    151                                 ], true );
     149                                        'wp_link_apply'
     150                                ];
     151
     152                                if ( typeof window.wpLink !== 'undefined' ) {
     153                                        editButtons.push( 'wp_link_advanced' );
     154                                }
     155
     156                                editToolbar = editor.wp._createToolbar( editButtons, true );
    152157
    153158                                editToolbar.on( 'show', function() {
     
    178183
    179184                editor.addCommand( 'WP_Link', function() {
    180                         if ( tinymce.Env.ie && tinymce.Env.ie < 10 ) {
    181                                 if ( typeof window.wpLink !== 'undefined' ) {
    182                                         window.wpLink.open( editor.id );
    183                                 }
    184 
     185                        if ( tinymce.Env.ie && tinymce.Env.ie < 10 && typeof window.wpLink !== 'undefined' ) {
     186                                window.wpLink.open( editor.id );
    185187                                return;
    186188                        }
  • trunk/src/wp-includes/js/wplink.js

    r36751 r36777  
    1 /* global tinymce, wpLinkL10n, wpActiveEditor */
     1
    22var wpLink;
    33
    4 ( function( $ ) {
     4( function( $, wpLinkL10n ) {
    55        var editor, correctedURL, linkNode,
    66                inputs = {},
     
    8181                                        $input.val( ui.item.permalink );
    8282
    83                                         if ( inputs.wrap.hasClass( 'has-text-field' ) && tinymce.trim( inputs.text.val() ) === '' ) {
     83                                        if ( inputs.wrap.hasClass( 'has-text-field' ) && $.trim( inputs.text.val() ) === '' ) {
    8484                                                inputs.text.val( ui.item.title );
    8585                                        }
     
    145145                        this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
    146146
    147                         if ( typeof tinymce !== 'undefined' ) {
     147                        if ( typeof window.tinymce !== 'undefined' ) {
    148148                                // Make sure the link wrapper is the last element in the body,
    149149                                // or the inline editor toolbar may show above the backdrop.
    150150                                $body.append( inputs.backdrop, inputs.wrap );
    151151
    152                                 ed = tinymce.get( wpActiveEditor );
     152                                ed = window.tinymce.get( window.wpActiveEditor );
    153153
    154154                                if ( ed && ! ed.isHidden() ) {
     
    158158                                }
    159159
    160                                 if ( editor && tinymce.isIE && ! editor.windowManager.wplinkBookmark ) {
     160                                if ( editor && window.tinymce.isIE && ! editor.windowManager.wplinkBookmark ) {
    161161                                        editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
    162162                                }
     
    237237                                        node = nodes[i];
    238238
    239                                         if ( node.nodeType != 3 && ! tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) {
     239                                        if ( node.nodeType != 3 && ! window.tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) {
    240240                                                return false;
    241241                                        }
     
    254254                                linkText = linkNode.innerText || linkNode.textContent;
    255255
    256                                 if ( ! tinymce.trim( linkText ) ) {
     256                                if ( ! $.trim( linkText ) ) {
    257257                                        linkText = text || '';
    258258                                }
     
    398398                        editor.focus();
    399399
    400                         if ( tinymce.isIE && editor.windowManager.wplinkBookmark ) {
     400                        if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) {
    401401                                editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
    402402                                editor.windowManager.wplinkBookmark = null;
     
    475475                        }
    476476
    477                         selection = tinymce.trim( selection );
     477                        selection = $.trim( selection );
    478478
    479479                        if ( selection && emailRegexp.test( selection ) ) {
     
    497497
    498498        $( document ).ready( wpLink.init );
    499 })( jQuery );
     499})( jQuery, window.wpLinkL10n );
Note: See TracChangeset for help on using the changeset viewer.