From 34995df879457f03ad6f78e617294dc2dd040b7d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 12 Aug 2010 12:47:07 -0700 Subject: TinyMCE: counter support (may not be 100% exact match to server-side count, but there's already discrepencies due to URL shortening) Fix for bad char conversions also, caused short text to not be saved in some cases. --- plugins/TinyMCE/TinyMCEPlugin.php | 45 +++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'plugins/TinyMCE') diff --git a/plugins/TinyMCE/TinyMCEPlugin.php b/plugins/TinyMCE/TinyMCEPlugin.php index 47d3d059f..ca16f6059 100644 --- a/plugins/TinyMCE/TinyMCEPlugin.php +++ b/plugins/TinyMCE/TinyMCEPlugin.php @@ -102,7 +102,7 @@ class TinyMCEPlugin extends Plugin */ private function stripHtml($html) { - return str_replace("\n", " ", html_entity_decode(strip_tags($html))); + return str_replace("\n", " ", html_entity_decode(strip_tags($html), ENT_QUOTES, 'UTF-8')); } /** @@ -281,6 +281,7 @@ class TinyMCEPlugin extends Plugin // on our send button click. $scr = <<'); - $('#notice_action-submit').click(function() { - if (typeof tinymce != "undefined") { - tinymce.triggerSave(); - } - }); - $('#'+SN.C.S.NoticeDataAttach).change(function() { - /* - S = '
'+$(this).val()+'
'; - NDAS = $('#'+SN.C.S.NoticeDataAttachSelected); - if (NDAS.length > 0) { - NDAS.replaceWith(S); + tabfocus_elements: ":prev,:next", + setup: function(ed) { + noticeForm.append(''); + + $('#notice_action-submit').click(function() { + tinymce.triggerSave(); + }); + + var origCounter = SN.U.CharacterCount; + SN.U.CharacterCount = function(form) { + var text = $(ed.getDoc()).text(); + return text.length; + }; + ed.onKeyUp.add(function (ed, e) { + SN.U.Counter(noticeForm); + }); + + $('#'+SN.C.S.NoticeDataAttach).change(function() { + var img = ''; + var html = tinyMCE.activeEditor.getContent(); + ed.setContent(html + img); + }); } - */ - //alert('yay'); - var img = ''; - var html = tinyMCE.activeEditor.getContent(); - tinyMCE.activeEditor.setContent(html + img); }); }); END_OF_SCRIPT; @@ -319,4 +323,3 @@ END_OF_SCRIPT; } } - -- cgit v1.2.3-54-g00ecf