Horde::addInlineScript($compose_result['js_onload'], 'load');
$scripts = array(
+ array('compose-base.js', 'imp'),
array('compose-dimp.js', 'imp'),
array('md5.js', 'horde'),
array('TextareaResize.js', 'horde')
$msg = '';
$get_sig = true;
-$showmenu = false;
-$cursor_pos = $oldrtemode = $rtemode = $siglocation = null;
+$showmenu = $spellcheck = false;
+$oldrtemode = $rtemode = null;
/* Set the current identity. */
$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
$redirect = ($actionID == 'redirect_compose');
/* Attach autocompleters to the compose form elements. */
-$spellcheck = false;
if ($browser->hasFeature('javascript')) {
if ($redirect) {
$imp_ui->attachAutoCompleter(array('to'));
}
}
$imp_ui->attachAutoCompleter($auto_complete);
+
if (!empty($conf['spell']['driver'])) {
try {
Horde_SpellChecker::factory($conf['spell']['driver'], array());
$msg = preg_replace('/\s+##IMP_SIGNATURE##/', '##IMP_SIGNATURE_WS####IMP_SIGNATURE##', $msg);
$msg = $imp_compose->text2html($msg);
$msg = str_replace(array('##IMP_SIGNATURE_WS##', '##IMP_SIGNATURE##'),
- array('<p> </p>', '<p class="imp-signature"><!--begin_signature-->' . $imp_compose->text2html($sig) . '<!--end_signature--></p>'),
+ array('<p> </p>', '<p><!--begin_signature-->' . $imp_compose->text2html($sig) . '<!--end_signature--></p>'),
$msg);
} else {
$msg = Horde_Text_Filter::filter($msg, 'html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false));
if ($get_sig && isset($msg) && !empty($sig)) {
if ($rtemode) {
- $sig = '<p> </p><p class="imp-signature"><!--begin_signature-->' . $imp_compose->text2html(trim($sig)) . '<!--end_signature--></p>';
+ $sig = '<p> </p><p><!--begin_signature-->' . $imp_compose->text2html(trim($sig)) . '<!--end_signature--></p>';
}
if ($identity->getValue('sig_first')) {
- $siglocation = 0;
$msg = "\n" . $sig . $msg;
} else {
- $siglocation = Horde_String::length($msg);
- /* We always add a line break at the beginning, so if length is 1,
- ignore that line break (i.e. the message is empty). */
- if ($siglocation == 1) {
- $siglocation = 0;
- }
$msg .= "\n" . $sig;
}
}
}
}
-/* Determine the default cursor position in the compose text area. */
-if (!$rtemode) {
- switch ($prefs->getValue('compose_cursor')) {
- case 'top':
- default:
- $cursor_pos = 0;
- break;
-
- case 'bottom':
- $cursor_pos = Horde_String::length($msg);
- break;
-
- case 'sig':
- if (!is_null($siglocation)) {
- $cursor_pos = $siglocation;
- } elseif (!empty($sig)) {
- $next_pos = $pos = 0;
- $sig_length = Horde_String::length($sig);
- do {
- $cursor_pos = $pos;
- $pos = strpos($msg, $sig, $next_pos);
- $next_pos = $pos + $sig_length;
- } while ($pos !== false);
- }
- break;
- };
-}
-
/* Define some variables used in the javascript code. */
$js_code = array(
+ 'IMP_Compose_Base.editor_on = ' . intval($rtemode),
'ImpCompose.auto_save = ' . intval($prefs->getValue('auto_save_drafts')),
'ImpCompose.cancel_url = \'' . $cancel_url . '\'',
- 'ImpCompose.cursor_pos = ' . (is_null($cursor_pos) ? 'null' : $cursor_pos),
+ 'ImpCompose.cursor_pos = ' .($rtemode ? 'null' : ('"' . $prefs->getValue('compose_cursor') . '"')),
'ImpCompose.max_attachments = ' . (($max_attach === true) ? 'null' : $max_attach),
'ImpCompose.popup = ' . intval($isPopup),
'ImpCompose.redirect = ' . intval($redirect),
'ImpCompose.reloaded = ' . intval($token),
- 'ImpCompose.rtemode = ' . intval($rtemode),
'ImpCompose.smf_check = ' . intval($smf_check),
'ImpCompose.spellcheck = ' . intval($spellcheck && $prefs->getValue('compose_spellcheck'))
);
/* Create javascript identities array. */
if (!$redirect) {
- $js_ident = array();
- foreach ($identity->getAllSignatures() as $ident => $sig) {
- $smf = $identity->getValue('sent_mail_folder', $ident);
- $js_ident[] = array(
- ($rtemode) ? str_replace(' target="_blank"', '', Horde_Text_Filter::filter($sig, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL, 'class' => null, 'callback' => null))) : $sig,
- $identity->getValue('sig_first', $ident),
- ($smf_check) ? $smf : IMP::displayFolder($smf),
- $identity->saveSentmail($ident),
- Horde_Mime_Address::addrArray2String($identity->getBccAddresses($ident))
- );
- }
- $js_code[] = 'ImpCompose.identities = ' . Horde_Serialize::serialize($js_ident, Horde_Serialize::JSON, Horde_Nls::getCharset());
+ $js_code[] = $imp_ui->identityJs();
}
-
/* Set up the base template now. */
$t = $injector->createInstance('Horde_Template');
$t->setOption('gettext', true);
if ($showmenu) {
IMP::prepareMenu();
}
+Horde::addScriptFile('compose-base.js', 'imp');
Horde::addScriptFile('compose.js', 'imp');
Horde::addScriptFile('md5.js', 'horde');
require IMP_TEMPLATES . '/common-header.inc';
--- /dev/null
+/**
+ * compose-base.js - Provides basic compose javascript functions shared
+ * between standarad and dynamic displays.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ */
+
+var IMP_Compose_Base = {
+
+ // Vars defaulting to null: editor_on, identities
+
+ getIdentity: function(id)
+ {
+ return {
+ id: this.identities[id],
+ sig: this.identities[id][(this.editor_on ? 'sig_html' : 'sig')].replace(/^\n/, '')
+ };
+ },
+
+ setCursorPosition: function(input, type, sig)
+ {
+ var pos, range;
+
+ if (!(input = $(input))) {
+ return;
+ }
+
+ switch (type) {
+ case 'top':
+ pos = 0;
+ input.setValue('\n' + $F(input));
+ break;
+
+ case 'bottom':
+ pos = input.length;
+ break;
+
+ case 'sig':
+ pos = input.replace(/\r\n/g, '\n').lastIndexOf(sig) - 1;
+ break;
+
+ default:
+ return;
+ }
+
+ if (input.setSelectionRange) {
+ /* This works in Mozilla. */
+ Field.focus(input);
+ input.setSelectionRange(pos, pos);
+ if (pos) {
+ (function() { input.scrollTop = input.scrollHeight - input.offsetHeight; }).defer();
+ }
+ } else if (input.createTextRange) {
+ /* This works in IE */
+ range = input.createTextRange();
+ range.collapse(true);
+ range.moveStart('character', pos);
+ range.moveEnd('character', 0);
+ Field.select(range);
+ range.scrollIntoView(true);
+ }
+ },
+
+ replaceSignature: function(id)
+ {
+ var lastsig, msg, nextsig, oldmsg, pos,
+ last = this.getIdentity($F('last_identity')),
+ next = this.getIdentity(id);
+
+ // If the rich text editor is on, we'll use a regexp to find the
+ // signature comment and replace its contents.
+ if (this.editor_on) {
+ msg = oldmsg = CKEDITOR.instances['composeMessage'].getData().replace(/\r\n/g, '\n');
+
+ lastsig = '<p><!--begin_signature--><!--end_signature--></p>';
+ nextsig = '<p><!--begin_signature-->' + next.sig.replace(/^ ?<br \/>\n/, '').replace(/ +/g, ' ') + '<!--end_signature--></p>';
+
+ // Dot-all functionality achieved with [\s\S], see:
+ // http://simonwillison.net/2004/Sep/20/newlines/
+ msg = msg.replace(/<p>\s*<!--begin_signature-->[\s\S]*?<!--end_signature-->\s*<\/p>/, lastsig);
+ if (msg == oldmsg) {
+ msg = nextsig;
+ }
+ } else {
+ msg = $F('composeMessage').replace(/\r\n/g, '\n');
+
+ lastsig = last.sig.replace(/^\n/, '');
+ nextsig = next.sig.replace(/^\n/, '');
+ }
+
+ pos = (last.id.sig_loc)
+ ? msg.indexOf(lastsig)
+ : msg.lastIndexOf(lastsig);
+
+ if (pos != -1) {
+ if (next.id.sig_loc == last.id.sig_loc) {
+ msg = msg.substring(0, pos) + nextsig + msg.substring(pos + lastsig.length, msg.length);
+ } else if (next.id.sig_loc) {
+ msg = nextsig + msg.substring(0, pos) + msg.substring(pos + lastsig.length, msg.length);
+ } else {
+ msg = msg.substring(0, pos) + msg.substring(pos + lastsig.length, msg.length) + nextsig;
+ }
+
+ msg = msg.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
+ }
+
+ if (this.editor_on) {
+ CKEDITOR.instances['composeMessage'].setData(msg);
+ } else {
+ $('composeMessage').setValue(msg);
+ }
+
+ $('last_identity').setValue(id);
+ }
+
+};
var DimpCompose = {
// Variables defaulting to empty/false:
- // auto_save_interval, compose_cursor, disabled, drafts_mbox, editor_on,
+ // auto_save_interval, compose_cursor, disabled, drafts_mbox,
// is_popup, knl_p, knl_sm, last_msg, loaded, rte, skip_spellcheck,
// spellcheck, sc_submit, uploading
$('composeCache').clear();
$('qreply', 'sendcc', 'sendbcc').invoke('hide');
[ $('msgData'), $('togglecc'), $('togglebcc') ].invoke('show');
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.toggleHtmlEditor();
}
$('compose').reset();
changeIdentity: function()
{
- var lastSignature, msg, nextSignature, pos,
- id = $F('identity'),
- last = this.getIdentity($F('last_identity')),
- msgval = $('composeMessage'),
- next = this.getIdentity(id);
-
- this.setSentMailLabel(next.id[3], next.id[5], true);
- $('bcc').setValue(next.id[6]);
- this.setSaveSentMail(next.id[4]);
-
- // Finally try and replace the signature.
- if (this.editor_on) {
- msg = this.rte.getData().replace(/\r\n/g, '\n');
- lastSignature = '<p><!--begin_signature--><!--end_signature--></p>';
- nextSignature = '<p><!--begin_signature-->' + next.sig.replace(/^ ?<br \/>\n/, '').replace(/ +/g, ' ') + '<!--end_signature--></p>';
-
- // Dot-all functionality achieved with [\s\S], see:
- // http://simonwillison.net/2004/Sep/20/newlines/
- msg = msg.replace(/<p>\s*<!--begin_signature-->[\s\S]*?<!--end_signature-->\s*<\/p>/, lastSignature);
- } else {
- msg = $F(msgval).replace(/\r\n/g, '\n');
- lastSignature = last.sig;
- nextSignature = next.sig;
- }
-
- pos = (last.id[2])
- ? msg.indexOf(lastSignature)
- : msg.lastIndexOf(lastSignature);
-
- if (pos != -1) {
- if (next.id[2] == last.id[2]) {
- msg = msg.substring(0, pos) + nextSignature + msg.substring(pos + lastSignature.length, msg.length);
- } else if (next.id[2]) {
- msg = nextSignature + msg.substring(0, pos) + msg.substring(pos + lastSignature.length, msg.length);
- } else {
- msg = msg.substring(0, pos) + msg.substring(pos + lastSignature.length, msg.length) + nextSignature;
- }
+ var identity = IMP_Compose_Base.getIdentity($F('identity'));
- msg = msg.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
- if (this.editor_on) {
- this.rte.setData(msg);
- } else {
- msgval.setValue(msg);
- }
- $('last_identity').setValue(id);
- }
+ this.setSentMailLabel(identity.id.smf_name, identity.id.smf_display, true);
+ $('bcc').setValue(identity.id.bcc);
+ this.setSaveSentMail(identity.id.smf_save);
+
+ IMP_Compose_Base.replaceSignature($F('identity'));
},
setSaveSentMail: function(set)
$('priority_label').setText(l.l);
},
- getIdentity: function(id, editor_on)
- {
- editor_on = Object.isUndefined(editor_on) ? this.editor_on : editor_on;
- return {
- id: DIMP.conf_compose.identities[id],
- sig: DIMP.conf_compose.identities[id][(editor_on ? 1 : 0)].replace(/^\n/, '')
- };
- },
-
uniqueSubmit: function(action)
{
var c = $('compose');
c.submit();
} else {
// Move HTML text to textarea field for submission.
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.rte.updateElement();
}
if (DIMP.SpellChecker) {
DIMP.SpellChecker.disable(disable);
}
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.RTELoading(disable ? 'show' : 'hide', true);
}
},
var config, text;
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
text = this.rte.getData();
this.rte.destroy();
this.rte = CKEDITOR.replace('composeMessage', config);
}
- this.editor_on = !this.editor_on;
+ IMP_Compose_Base.editor_on = !IMP_Compose_Base.editor_on;
- $('htmlcheckbox').setValue(this.editor_on);
- $('html').setValue(this.editor_on ? 1 : 0);
+ $('htmlcheckbox').setValue(IMP_Compose_Base.editor_on);
+ $('html').setValue(Number(IMP_Compose_Base.editor_on));
},
RTELoading: function(cmd, notxt)
_onSpellCheckAfter: function()
{
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.rte.setData($F('composeMessage'));
$('composeMessage').next().show();
}
_onSpellCheckBefore: function()
{
- DIMP.SpellChecker.htmlAreaParent = this.editor_on
+ DIMP.SpellChecker.htmlAreaParent = IMP_Compose_Base.editor_on
? 'composeMessageParent'
: null;
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.rte.updateElement();
$('composeMessage').next().hide();
}
ta.setValue(r.response.text);
}
- if (!this.editor_on) {
+ if (!IMP_Compose_Base.editor_on) {
this.resizeMsgArea();
}
},
}
var bcc_add,
- identity = this.getIdentity($F('last_identity'));
+ identity = IMP_Compose_Base.getIdentity($F('last_identity'));
opts = opts || {};
// Set auto-save-drafts now if not already active.
if (DIMP.conf_compose.auto_save_interval_val &&
!this.auto_save_interval) {
this.auto_save_interval = new PeriodicalExecuter(function() {
- var curr_hash = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0') + (this.editor_on ? this.rte.getData() : $F('composeMessage')));
+ var curr_hash = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0') + (IMP_Compose_Base.editor_on ? this.rte.getData() : $F('composeMessage')));
if (this.last_msg && curr_hash != this.last_msg) {
this.uniqueSubmit('AutoSaveDraft');
}
if (DIMP.conf_compose.cc) {
this.toggleCC('cc', true);
}
- this.setSentMailLabel(identity.id[3], identity.id[5], true);
- this.setSaveSentMail(identity.id[4]);
+ this.setSentMailLabel(identity.id.smf_name, identity.id.smf_display, true);
+ this.setSaveSentMail(identity.id.smf_save);
if (header.bcc) {
$('bcc').setValue(header.bcc);
}
- if (identity.id[6]) {
+ if (identity.id.bcc) {
bcc_add = $F('bcc');
if (bcc_add) {
bcc_add += ', ';
}
- $('bcc').setValue(bcc_add + identity.id[6]);
+ $('bcc').setValue(bcc_add + identity.id.bcc);
}
if (DIMP.conf_compose.bcc) {
this.toggleCC('bcc', true);
}
if (DIMP.conf_compose.show_editor) {
- if (!this.editor_on) {
+ if (!IMP_Compose_Base.editor_on) {
this.toggleHtmlEditor(opts.noupdate);
}
if (opts.focus && (opts.focus == 'composeMessage')) {
setBodyText: function(msg)
{
- var msgval;
-
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
this.rte.setData(msg);
} else {
- msgval = $('composeMessage');
- msgval.setValue(msg);
- this.setCursorPosition(msgval);
+ $('composeMessage').setValue(msg);
+ IMP_Compose_Base.setCursorPosition('composeMessage', DIMP.conf_compose.compose_cursor, IMP_Compose_Base.getIdentity($F('last_identity')).sig);
}
},
mah = document.viewport.getHeight() - cmp.offsetTop;
- if (this.editor_on) {
+ if (IMP_Compose_Base.editor_on) {
[ 'margin', 'padding', 'border' ].each(function(s) {
[ 'Top', 'Bottom' ].each(function(h) {
var a = parseInt(cmp.getStyle(s + h), 10);
}
},
- /* Sets the cursor to the given position. */
- setCursorPosition: function(input)
- {
- var pos, range;
-
- switch (DIMP.conf_compose.compose_cursor) {
- case 'top':
- pos = 0;
- $('composeMessage').setValue('\n' + $F('composeMessage'));
- break;
-
- case 'bottom':
- pos = $F('composeMessage').length;
- break;
-
- case 'sig':
- pos = $F('composeMessage').replace(/\r\n/g, '\n').lastIndexOf(this.getIdentity($F('last_identity')).sig) - 1;
- break;
-
- default:
- return;
- }
-
- if (input.setSelectionRange) {
- /* This works in Mozilla */
- Field.focus(input);
- input.setSelectionRange(pos, pos);
- if (pos) {
- (function() { input.scrollTop = input.scrollHeight - input.offsetHeight; }).defer();
- }
- } else if (input.createTextRange) {
- /* This works in IE */
- range = input.createTextRange();
- range.collapse(true);
- range.moveStart('character', pos);
- range.moveEnd('character', 0);
- Field.select(range);
- range.scrollIntoView(true);
- }
- },
-
/* Open the addressbook window. */
openAddressbook: function()
{
break;
case 'htmlcheckbox':
- if (!this.editor_on || window.confirm(DIMP.text_compose.toggle_html)) {
+ if (!IMP_Compose_Base.editor_on ||
+ window.confirm(DIMP.text_compose.toggle_html)) {
this.toggleHtmlEditor();
} else {
$('htmlcheckbox').setValue(true);
list: DIMP.conf_compose.flist,
onChoose: this.setSentMailLabel.bind(this)
});
- this.knl_sm.setSelected(this.getIdentity($F('identity'))[3]);
+ this.knl_sm.setSelected(IMP_Compose_Base.getIdentity($F('identity')).id.smf_name);
$('sent_mail_folder_label').insert({ after: new Element('SPAN', { className: 'popdownImg' }).observe('click', function(e) { if (!this.disabled) { this.knl_sm.show(); this.knl_sm.ignoreClick(e); e.stop(); } }.bindAsEventListener(this)) });
}
var ImpCompose = {
// Variables defined in compose.php:
- // cancel_url, spellcheck, cursor_pos, identities, last_msg,
- // max_attachments, popup, redirect, reloaded, rtemode, sc_submit,
- // smf_check, skip_spellcheck
+ // cancel_url, spellcheck, cursor_pos, last_msg, max_attachments,
+ // popup, redirect, reloaded, sc_submit, smf_check, skip_spellcheck
display_unload_warning: true,
confirmCancel: function(e)
}
},
- /**
- * Sets the cursor to the given position.
- */
- setCursorPosition: function(input, position)
- {
- if (input.setSelectionRange) {
- /* This works in Mozilla */
- Field.focus(input);
- input.setSelectionRange(position, position);
- if (position) {
- (function() { input.scrollTop = input.scrollHeight - input.offsetHeight; }).defer();
- }
- } else if (input.createTextRange) {
- /* This works in IE */
- var range = input.createTextRange();
- range.collapse(true);
- range.moveStart('character', position);
- range.moveEnd('character', 0);
- Field.select(range);
- range.scrollIntoView(true);
- }
- },
-
changeIdentity: function(elt)
{
var id = $F(elt),
- last = this.identities[$F('last_identity')],
- next = this.identities[id],
+ last = IMP_Compose_Base.getIdentity($F('last_identity')),
+ next = IMP_Compose_Base.getIdentity(id),
i = 0,
bcc = $('bcc'),
save = $('ssm'),
smf = $('sent_mail_folder'),
- lastSignature, msg, nextSignature, pos, re;
-
- // If the rich text editor is on, we'll use a regexp to find the
- // signature comment and replace its contents.
- if (this.rtemode) {
- msg = CKEDITOR.instances.composeMessage.getData().replace(/\r\n/g, '\n');
-
- lastSignature = '<p><!--begin_signature--><!--end_signature--></p>';
- nextSignature = '<p><!--begin_signature-->' + next[0].replace(/^ ?<br \/>\n/, '').replace(/ +/g, ' ') + '<!--end_signature--></p>';
-
- // Dot-all functionality achieved with [\s\S], see:
- // http://simonwillison.net/2004/Sep/20/newlines/
- msg = msg.replace(/<p class="imp-signature">\s*<!--begin_signature-->[\s\S]*?<!--end_signature-->\s*<\/p>/, lastSignature);
- } else {
- msg = $F('composeMessage').replace(/\r\n/g, '\n');
-
- lastSignature = last[0].replace(/^\n/, '');
- nextSignature = next[0].replace(/^\n/, '');
- }
-
- pos = (last[1]) ? msg.indexOf(lastSignature) : msg.lastIndexOf(lastSignature);
- if (pos != -1) {
- if (next[1] == last[1]) {
- msg = msg.substring(0, pos) + nextSignature + msg.substring(pos + lastSignature.length, msg.length);
- } else if (next[1]) {
- msg = nextSignature + msg.substring(0, pos) + msg.substring(pos + lastSignature.length, msg.length);
- } else {
- msg = msg.substring(0, pos) + msg.substring(pos + lastSignature.length, msg.length) + nextSignature;
- }
-
- msg = msg.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
-
- $('last_identity').setValue(id);
- window.status = IMP.text.compose_sigreplace;
- } else {
- window.status = IMP.text.compose_signotreplace;
- }
-
- if (this.rtemode) {
- CKEDITOR.instances.composeMessage.setData(msg);
- } else {
- $('composeMessage').setValue(msg);
- }
+ re;
+ IMP_Compose_Base.replaceSignature(id);
if (this.smf_check) {
$A(smf.options).detect(function(f) {
- if (f.value == next[2]) {
+ if (f.value == next.id.smf_name) {
smf.selectedIndex = i;
return true;
}
});
} else {
if (smf.firstChild) {
- smf.replaceChild(document.createTextNode(next[2]), smf.firstChild);
+ smf.replaceChild(document.createTextNode(next.id.smf_name), smf.firstChild);
} else {
- smf.appendChild(document.createTextNode(next[2]));
+ smf.appendChild(document.createTextNode(next.id.smf_name));
}
}
if (save) {
- save.checked = next[3];
+ save.checked = next.id.smf_save;
}
if (bcc) {
bccval = bcc.value;
- if (last[4]) {
- re = new RegExp(last[4] + ",? ?", 'gi');
+ if (last.id.bcc) {
+ re = new RegExp(last.id.bcc + ",? ?", 'gi');
bccval = bccval.replace(re, "");
if (bccval) {
bccval = bccval.replace(/, ?$/, "");
}
}
- if (next[4]) {
+ if (next.id.bcc) {
if (bccval) {
bccval += ', ';
}
- bccval += next[4];
+ bccval += next.id.bcc;
}
bcc.setValue(bccval);
case 'auto_save_draft':
// Move HTML text to textarea field for submission.
- if (this.rtemode) {
+ if (IMP_Compose_Base.editor_on) {
CKEDITOR.instances.composeMessage.updateElement();
}
}
});
- if (this.cursor_pos !== null && $('composeMessage')) {
- this.setCursorPosition($('composeMessage'), this.cursor_pos);
- }
+ IMP_Compose_Base.setCursorPosition('composeMessage', this.cursor_pos, IMP_Compose_Base.getIdentity($F('last_identity')).sig);
if (this.redirect) {
$('to').focus();
});
}
- if (this.rtemode) {
+ if (IMP_Compose_Base.editor_on) {
document.observe('SpellChecker:after', this._onAfterSpellCheck.bind(this));
document.observe('SpellChecker:before', this._onBeforeSpellCheck.bind(this));
}
if ($('to') && !$F('to')) {
$('to').focus();
} else if (!$F('subject')) {
- if (this.rtemode) {
+ if (IMP_Compose_Base.editor_on) {
$('subject').focus();
} else {
$('composeMessage').focus();
if (this.sc_submit) {
this.skip_spellcheck = true;
this.uniqSubmit(this.sc_submit.a, this.sc_submit.e);
- } else if (this.rtemode) {
+ } else if (IMP_Compose_Base.editor_on) {
this._onAfterSpellCheck();
} else {
this.sc_submit = null;
Horde::addInlineScript(array($js), 'dom');
}
+ /**
+ */
+ public function identityJs()
+ {
+ $identities = array();
+ $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
+
+ foreach ($identity->getAllSignatures() as $ident => $sig) {
+ $identities[] = array(
+ // Plain text signature
+ 'sig' => $sig,
+ // HTML signature
+ 'sig_html' => str_replace(' target="_blank"', '', Horde_Text_Filter::filter($sig, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL, 'class' => null, 'callback' => null))),
+ // Signature location
+ 'sig_loc' => (bool)$identity->getValue('sig_first', $ident),
+ // Sent mail folder name
+ 'smf_name' => $identity->getValue('sent_mail_folder', $ident),
+ // Save in sent mail folder by default?
+ 'smf_save' => (bool)$identity->saveSentmail($ident),
+ // Sent mail display name
+ 'smf_display' => IMP::displayFolder($identity->getValue('sent_mail_folder', $ident)),
+ // Bcc addresses to add
+ 'bcc' => Horde_Mime_Address::addrArray2String($identity->getBccAddresses($ident))
+ );
+ }
+
+ return 'IMP_Compose_Base.identities = ' . Horde_Serialize::serialize($identities, Horde_Serialize::JSON);
+ }
+
+
}
$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
$selected_identity = $identity->getDefault();
- /* Get user identities. */
- $all_sigs = $identity->getAllSignatures();
- foreach ($all_sigs as $ident => $sig) {
- $identities[] = array(
- // 0 = Plain text signature
- $sig,
- // 1 = HTML signature
- str_replace(' target="_blank"', '', Horde_Text_Filter::filter($sig, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL, 'class' => null, 'callback' => null))),
- // 2 = Signature location
- (bool)$identity->getValue('sig_first', $ident),
- // 3 = Sent mail folder name
- $identity->getValue('sent_mail_folder', $ident),
- // 4 = Save in sent mail folder by default?
- (bool)$identity->saveSentmail($ident),
- // 5 = Sent mail display name
- IMP::displayFolder($identity->getValue('sent_mail_folder', $ident)),
- // 6 = Bcc addresses to add
- Horde_Mime_Address::addrArray2String($identity->getBccAddresses($ident))
- );
- }
+ /* Generate identities list. */
+ $imp_ui = new IMP_Ui_Compose();
+ $result['js'] = array($imp_ui->identityJs());
$composeCache = null;
if (!empty($args['composeCache'])) {
}
}
- $result['js'] = array(
- 'DIMP.conf_compose.identities = ' . Horde_Serialize::serialize($identities, Horde_Serialize::JSON)
- );
-
if (!empty($args['qreply'])) {
$result['js'][] = 'DIMP.conf_compose.qreply = 1';
}
$compose_html = $GLOBALS['prefs']->getValue('compose_html');
$rte = true;
- $imp_ui = new IMP_Ui_Compose();
$imp_ui->initRTE(!$compose_html);
}
/* Check to make sure the sent-mail folders are created - they
* need to exist to show up in drop-down list. */
- foreach ($identities as $val) {
- if (!$imp_folder->exists($val[3])) {
- $imp_folder->create($val[3], true);
+ foreach (array_keys($identity->getAllSignatures()) as $ident) {
+ $val = $identity->getValue('sent_mail_folder', $ident);
+ if (!$imp_folder->exists($val)) {
+ $imp_folder->create($val, true);
}
}
);
$compose_result = IMP_Views_Compose::showCompose($compose_args);
- /* Init IMP_Ui_Compose:: object. */
- $imp_ui = new IMP_Ui_Compose();
-
/* Attach spellchecker & auto completer. */
+ $imp_ui = new IMP_Ui_Compose();
$imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc'));
$imp_ui->attachSpellChecker();
$js_out = array_merge($js_out, $compose_result['js']);
+ $scripts[] = array('compose-base.js', 'imp');
$scripts[] = array('compose-dimp.js', 'imp');
$js_onload = $compose_result['jsonload'];
'compose_cancel' => _("Cancelling this message will permanently discard its contents.") . "\n" . _("Are you sure you want to do this?"),
'compose_discard' => _("Doing so will discard this message permanently."),
'compose_recipient' => _("You must specify a recipient."),
- 'compose_sigreplace' => _("The signature was successfully replaced."),
- 'compose_signotreplace' => _("The signature could not be replaced."),
'compose_nosubject' => _("The message does not have a Subject entered.") . "\n" . _("Send message without a Subject?"),
'compose_file' => _("File"),
'compose_attachment' => _("Attachment"),