diff options
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | program/js/app.js | 18 | ||||
-rw-r--r-- | program/js/editor.js | 37 | ||||
-rw-r--r-- | program/localization/en_US/messages.inc | 1 | ||||
-rw-r--r-- | program/localization/pl_PL/messages.inc | 1 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 10 | ||||
-rw-r--r-- | program/steps/settings/edit_identity.inc | 4 | ||||
-rw-r--r-- | skins/default/templates/compose.html | 2 |
8 files changed, 32 insertions, 46 deletions
@@ -1,6 +1,11 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/11/03 (alec) +---------- +- Add warning when switching editor mode from html to plain (#1485488) +- Unified editor switching functions + 2008/10/29 (alec) ---------- - Fix problem with numeric folder names (#1485527) 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); - } - } diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index 568decc81..2eea16e60 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -93,5 +93,6 @@ $messages['importerror'] = 'Import failed! The uploaded file is not a valid vCar $messages['importconfirm'] = '<b>Successfully imported $inserted contacts, $skipped existing entries skipped</b>:<p><em>$names</em></p>'; $messages['opnotpermitted'] = 'Operation not permitted!'; $messages['nofromaddress'] = 'Missing e-mail address in selected identity'; +$messages['editorwarning'] = 'All text formatting will be lost after editor change. Are you sure, you want to do that?'; ?> diff --git a/program/localization/pl_PL/messages.inc b/program/localization/pl_PL/messages.inc index 7918b8aae..74127e257 100644 --- a/program/localization/pl_PL/messages.inc +++ b/program/localization/pl_PL/messages.inc @@ -98,5 +98,6 @@ $messages['importerror'] = 'Błąd! Pobrany plik nie jest poprawnym plikiem vCar $messages['importconfirm'] = '<b>Pomyślnie dodano $inserted kontaktów, pominięto $skipped istniejących wpisów</b>:<p><em>$names</em></p>'; $messages['opnotpermitted'] = 'Niedozwolona operacja!'; $messages['nofromaddress'] = 'Brak adresu e-mail w wybranej tożsamości'; +$messages['editorwarning'] = 'Zmiana edytora spowoduje utratę formatowania tekstu. Czy jesteś pewien, że chcesz to zrobić?'; ?> diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index df6f1ffae..758069acd 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -81,7 +81,9 @@ if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_v } // add some labels to client -$OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 'converting'); +$OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', + 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', + 'converting', 'editorwarning'); // add config parameters to client script if (!empty($CONFIG['drafts_mbox'])) { @@ -848,9 +850,13 @@ function rcmail_editor_selector($attrib) if ($compose_mode) $useHtml = ($useHtml && $MESSAGE->has_html_part()); + $editorid = empty($attrib['editorid']) ? 'rcmComposeMessage' : $attrib['editorid']; + $selector = ''; $chosenvalue = $useHtml ? 'html' : 'plain'; - $radio = new html_radiobutton(array('name' => '_editorSelect', 'onclick' => 'return rcmail_toggle_editor(this)')); + $radio = new html_radiobutton(array('name' => '_editorSelect', + 'onclick' => "return rcmail.toggle_editor(this.value=='html', '$editorid', '_is_html')")); + foreach ($choices as $value => $text) { $attrib['id'] = '_' . $value; diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index c8d448adb..e4bb50fea 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -72,7 +72,7 @@ function rcube_identity_form($attrib) "gecko_spellcheck : true });"); // add some labels to client - $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting'); + $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting', 'editorwarning'); $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; @@ -89,7 +89,7 @@ function rcube_identity_form($attrib) 'reply-to' => array('type' => 'text', 'label' => 'reply-to', 'size' => $i_size), 'bcc' => array('type' => 'text', 'size' => $i_size), 'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows), - 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this, \'rcmfd_signature\');'), + 'html_signature'=>array('type' => 'checkbox', 'label' => 'htmlsignature', 'onclick' => 'return rcmail.toggle_editor(this.checked, \'rcmfd_signature\');'), 'standard' => array('type' => 'checkbox', 'label' => 'setdefault')); // disable some field according to access level diff --git a/skins/default/templates/compose.html b/skins/default/templates/compose.html index beabe9867..aa45ef027 100644 --- a/skins/default/templates/compose.html +++ b/skins/default/templates/compose.html @@ -80,7 +80,7 @@ </td> <td style="text-align:right; white-space:nowrap"> <roundcube:label name="editortype" />: - <span class="radios-left"><roundcube:object name="editorSelector" tabindex="10" /></span> + <span class="radios-left"><roundcube:object name="editorSelector" editorid="compose-body" tabindex="10" /></span> </td> </tr> </tbody></table> |