From 35be18083c4262c94d58f85609aabfff5a0f9412 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Tue, 1 Mar 2011 08:00:53 +0000 Subject: Refs #2538: Cleaned up custom tinymce code into elgg.tinymce.*. Refs #2895: TinyMCE makes use of longtext menu git-svn-id: http://code.elgg.org/elgg/trunk@8533 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/tinymce/views/default/input/longtext.php | 32 -------------- mod/tinymce/views/default/js/tinymce.php | 59 ++++++++++++++++++++++++++ mod/tinymce/views/default/tinymce/init.php | 62 +--------------------------- 3 files changed, 61 insertions(+), 92 deletions(-) delete mode 100644 mod/tinymce/views/default/input/longtext.php create mode 100644 mod/tinymce/views/default/js/tinymce.php (limited to 'mod/tinymce/views/default') diff --git a/mod/tinymce/views/default/input/longtext.php b/mod/tinymce/views/default/input/longtext.php deleted file mode 100644 index 9124a89b5..000000000 --- a/mod/tinymce/views/default/input/longtext.php +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/mod/tinymce/views/default/js/tinymce.php b/mod/tinymce/views/default/js/tinymce.php new file mode 100644 index 000000000..adff52129 --- /dev/null +++ b/mod/tinymce/views/default/js/tinymce.php @@ -0,0 +1,59 @@ +elgg.tinymce.toggleEditor = function(id) { + if (!tinyMCE.get(id)) { + tinyMCE.execCommand('mceAddControl', false, id); + + $("a.tinymce-toggle-editor").html(elgg.echo('tinymce:remove')); + } else { + tinyMCE.execCommand('mceRemoveControl', false, id); + $("a.tinymce-toggle-editor").html(elgg.echo('tinymce:add')); + } +} + +/** + * TinyMCE initialization script + * + * You can find configuration information here: + * http://tinymce.moxiecode.com/wiki.php/Configuration + */ +elgg.tinymce.init = function() { + tinyMCE.init({ + mode : "specific_textareas", + editor_selector : "elgg-input-longtext", + theme : "advanced", + plugins : "spellchecker,autosave,fullscreen,paste", + relative_urls : false, + remove_script_host : false, + document_base_url : elgg.config.wwwroot, + theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,bullist,numlist,undo,redo,link,unlink,image,blockquote,code,pastetext,pasteword,more,fullscreen", + theme_advanced_buttons2 : "", + theme_advanced_buttons3 : "", + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : true, + theme_advanced_path : true, + extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", + setup : function(ed) { + //show the number of words + ed.onLoadContent.add(function(ed, o) { + var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,""); + var text = " " + strip.split(' ').length + ' '; + tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text); + }); + + ed.onKeyUp.add(function(ed, e) { + var strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,""); + var text = " " + strip.split(' ').length + ' '; + tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text); + }); + }, + content_css: elgg.config.wwwroot + 'mod/tinymce/tinymce_content.css' + }); + + $('.elgg-input-longtext').parents('form').submit(function() { + tinyMCE.triggerSave(); + }); + +}); + +elgg.register_event_handler('init', 'system', elgg.tinymce.init); \ No newline at end of file diff --git a/mod/tinymce/views/default/tinymce/init.php b/mod/tinymce/views/default/tinymce/init.php index 7064709d6..100a1a987 100644 --- a/mod/tinymce/views/default/tinymce/init.php +++ b/mod/tinymce/views/default/tinymce/init.php @@ -1,62 +1,4 @@ - - +elgg_register_js('mod/tinymce/vendor/tinymce/jscripts/tiny_mce/tiny_mce.js', 'tinymce'); +elgg_register_js(elgg_get_simplecache_url('js', 'tinymce'), 'elgg.tinymce'); \ No newline at end of file -- cgit v1.2.3