diff --git a/js/util.js b/js/util.js index 6a67da4bcd..ad8a44c82a 100644 --- a/js/util.js +++ b/js/util.js @@ -110,7 +110,7 @@ var SN = { // StatusNet return; } - var remaining = MaxLength - form.find('#'+SN.C.S.NoticeDataText).val().length; + var remaining = MaxLength - SN.U.CharacterCount(form); var counter = form.find('#'+SN.C.S.NoticeTextCount); if (remaining.toString() != counter.text()) { @@ -134,6 +134,10 @@ var SN = { // StatusNet } }, + CharacterCount: function(form) { + return form.find('#'+SN.C.S.NoticeDataText).val().length; + }, + ClearCounterBlackout: function(form) { // Allow keyup events to poke the counter again SN.C.I.CounterBlackout = false; diff --git a/plugins/TinyMCE/TinyMCEPlugin.php b/plugins/TinyMCE/TinyMCEPlugin.php index 47d3d059f2..ca16f60591 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(); + 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); + }); } }); - $('#'+SN.C.S.NoticeDataAttach).change(function() { - /* - S = '
'+$(this).val()+'
'; - NDAS = $('#'+SN.C.S.NoticeDataAttachSelected); - if (NDAS.length > 0) { - NDAS.replaceWith(S); - } - */ - //alert('yay'); - var img = ''; - var html = tinyMCE.activeEditor.getContent(); - tinyMCE.activeEditor.setContent(html + img); - }); }); END_OF_SCRIPT; @@ -319,4 +323,3 @@ END_OF_SCRIPT; } } -