From bb7edf8bfd749b421daba918b1a0037b55972ab8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 4 Jan 2012 23:33:12 +0100 Subject: [PATCH] ENHANCEMENT Marking "link" and "unlink" buttons in SilverStripe's TinyMCE as disabled if no link is selected (see 4646efe84 in sapphire for details) --- javascript/tinymce_ssbuttons/editor_plugin_src.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/tinymce_ssbuttons/editor_plugin_src.js b/javascript/tinymce_ssbuttons/editor_plugin_src.js index cfeeebd1..0b0892b1 100644 --- a/javascript/tinymce_ssbuttons/editor_plugin_src.js +++ b/javascript/tinymce_ssbuttons/editor_plugin_src.js @@ -37,8 +37,10 @@ jQuery('#Form_EditorToolbarFlashForm')[0].open(); }); - ed.onNodeChange.add(function(ed, o) { - jQuery('Form_EditorToolbarLinkForm').entwine('ss').updateSelection(); + ed.onNodeChange.add(function(ed, cm, n, co) { + cm.setDisabled('sslink', co && n.nodeName != 'A'); + cm.setActive('sslink', n.nodeName == 'A' && !n.name); + jQuery('Form_EditorToolbarLinkForm').entwine('ss').respondToNodeChange(); }); }