WordPress.org

Make WordPress Core

Changeset 27934


Ignore:
Timestamp:
04/03/2014 08:04:44 PM (8 years ago)
Author:
azaozz
Message:

TinyMCE: improve setting disabled/enabled/activated states on the Unlink button, fixes #27309

File:
1 edited

Legend:

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

    r27449 r27934  
    1515    editor.addShortcut( 'ctrl+k', '', 'WP_Link' );
    1616
     17    function setState( button, node ) {
     18        button.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
     19        button.active( node.nodeName === 'A' && ! node.name );
     20    }
     21
    1722    editor.addButton( 'link', {
    1823        icon: 'link',
     
    2530
    2631            editor.on( 'nodechange', function( event ) {
    27                 var node = event.element;
    28 
    29                 linkButton.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
    30                 linkButton.active( node.nodeName === 'A' && ! node.name );
     32                setState( linkButton, event.element );
    3133            });
    3234        }
     
    3739        tooltip: 'Remove link',
    3840        cmd: 'unlink',
    39         stateSelector: 'a[href]'
     41
     42        onPostRender: function() {
     43            var unlinkButton = this;
     44
     45            editor.on( 'nodechange', function( event ) {
     46                setState( unlinkButton, event.element );
     47            });
     48        }
    4049    });
    4150
Note: See TracChangeset for help on using the changeset viewer.