From 4cdc70941d5d25f47f920c6ba62035d2e6978454 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 31 Mar 2010 07:37:43 +0000 Subject: - Fix js error when switching editor mode (#1486593) --- program/js/editor.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'program') diff --git a/program/js/editor.js b/program/js/editor.js index b1ef31bde..2c86d8ec7 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -55,7 +55,7 @@ function rcmail_editor_init(skin_path, editor_lang, spellcheck, mode) gecko_spellcheck : true, relative_urls : false, remove_script_host : false, - rc_client: rcmail, + rc_client : rcmail, oninit : 'rcmail_editor_callback' }); } @@ -75,10 +75,12 @@ function rcmail_editor_tabindex() { if (rcmail.env.task == 'mail') { var editor = tinyMCE.get(rcmail.env.composebody); - var textarea = editor.getElement(); - var node = editor.getContentAreaContainer().childNodes[0]; - if (textarea && node) - node.tabIndex = textarea.tabIndex; + if (editor) { + var textarea = editor.getElement(); + var node = editor.getContentAreaContainer().childNodes[0]; + if (textarea && node) + node.tabIndex = textarea.tabIndex; + } } } @@ -98,8 +100,9 @@ function rcmail_toggle_editor(select, textAreaId, flagElement) rcmail.display_spellcheck_controls(false); rcmail.plain2html(composeElement.value, textAreaId); - tinyMCE.execCommand('mceAddControl', true, textAreaId); - rcmail_editor_tabindex(); + tinyMCE.execCommand('mceToggleEditor', false, textAreaId); + // #1486593 + setTimeout("rcmail_editor_tabindex();", 500); if (flagElement && (flag = rcube_find_object(flagElement))) flag.value = '1'; } @@ -118,7 +121,7 @@ function rcmail_toggle_editor(select, textAreaId, flagElement) rcmail.html2plain(existingHtml, textAreaId); } - tinyMCE.execCommand('mceRemoveControl', true, textAreaId); + tinyMCE.execCommand('mceToggleEditor', false, textAreaId); rcmail.display_spellcheck_controls(true); if (flagElement && (flag = rcube_find_object(flagElement))) flag.value = '0'; -- cgit v1.2.3