diff options
author | alecpl <alec@alec.pl> | 2008-11-03 14:26:23 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-11-03 14:26:23 +0000 |
commit | 79af0bb1ba370bd5f194afb692e7ed59a26b02af (patch) | |
tree | 3b070c6afaa03e0a9d26d6afdaff8bc9d767b678 /program/js | |
parent | 3d54e6e9b7f65dcb01688d3933f7c6e4aac25a18 (diff) |
- Add warning when switching editor mode from html to plain (#1485488)
- Unified editor switching functions
Diffstat (limited to 'program/js')
-rw-r--r-- | program/js/app.js | 18 | ||||
-rw-r--r-- | program/js/editor.js | 37 |
2 files changed, 14 insertions, 41 deletions
diff --git a/program/js/app.js b/program/js/app.js index d8a7eed4b..5c258f93b 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3622,24 +3622,34 @@ function rcube_webmail() this.enable_command('export', (this.contact_list.rowcount > 0)); }; - this.toggle_editor = function(checkbox, textAreaId) + this.toggle_editor = function(ishtml, textAreaId, flagElement) { - var ischecked = checkbox.checked; var composeElement = document.getElementById(textAreaId); - - if (ischecked) + var flag; + + if (ishtml) { var existingPlainText = composeElement.value; var htmlText = "<pre>" + existingPlainText + "</pre>"; + + this.display_spellcheck_controls(false); composeElement.value = htmlText; tinyMCE.execCommand('mceAddControl', true, textAreaId); + if (flagElement && (flag = rcube_find_object(flagElement))) + flag.value = '1'; } else { + if (!confirm(rcmail.get_label('editorwarning'))) + return false; + var thisMCE = tinyMCE.get(textAreaId); var existingHtml = thisMCE.getContent(); this.html2plain(existingHtml, textAreaId); tinyMCE.execCommand('mceRemoveControl', true, textAreaId); + this.display_spellcheck_controls(true); + if (flagElement && (flag = rcube_find_object(flagElement))) + flag.value = '0'; } }; diff --git a/program/js/editor.js b/program/js/editor.js index a9aec621c..179d089fc 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -38,40 +38,3 @@ function rcmail_editor_init(skin_path, editor_lang, spellcheck) rc_client: rcube_webmail_client }); } - -// Toggle between the HTML and Plain Text editors - -function rcmail_toggle_editor(toggler) - { - var selectedEditor = toggler.value; - - // determine the currently displayed editor - var htmlFlag = document.getElementsByName('_is_html')[0]; - var isHtml = htmlFlag.value; - - if (((selectedEditor == 'plain') && (isHtml == "0")) || - ((selectedEditor == 'html') && (isHtml == "1"))) - { - return; - } - - // do the appropriate conversion - if (selectedEditor == 'html') - { - rcmail.display_spellcheck_controls(false); - var composeElement = document.getElementById('compose-body'); - var htmlText = "<pre>" + composeElement.value + "</pre>"; - composeElement.value = htmlText; - tinyMCE.execCommand('mceAddControl', true, 'compose-body'); - htmlFlag.value = "1"; - } - else - { - var thisMCE = tinyMCE.get('compose-body'); - var existingHtml = thisMCE.getContent(); - rcmail.html2plain(existingHtml, 'compose-body'); - tinyMCE.execCommand('mceRemoveControl', true, 'compose-body'); - htmlFlag.value = "0"; - rcmail.display_spellcheck_controls(true); - } - } |