- Add warning when switching editor mode from html to plain (#1485488)

- Unified editor switching functions
release-0.6
alecpl 16 years ago
parent 3d54e6e9b7
commit 79af0bb1ba

@ -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)

@ -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';
}
};

@ -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);
}
}

@ -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?';
?>

@ -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ć?';
?>

@ -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;

@ -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

@ -80,7 +80,7 @@
</td>
<td style="text-align:right; white-space:nowrap">
<roundcube:label name="editortype" />:&nbsp;
<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>

Loading…
Cancel
Save