Skip to content

Commit

Permalink
Display signature in compose view.
Browse files Browse the repository at this point in the history
Final position, collapsibility and styling is open to discussion and not
decided yet. But the functionality is there.
  • Loading branch information
yunosh committed Oct 15, 2013
1 parent 4a5df32 commit 932c934
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 3 deletions.
1 change: 1 addition & 0 deletions imp/docs/CHANGES
Expand Up @@ -2,6 +2,7 @@
v6.2.0-git
----------

[jan] Display signature in compose view.
[mms] Add keyboard shortcuts to allow a more granular scroll of the dynamic
preview pane (Request #12750).
[mms] Add a simple domain checker to the autocompleter that checks for common
Expand Down
13 changes: 13 additions & 0 deletions imp/js/compose-base.js
Expand Up @@ -58,6 +58,19 @@ var ImpComposeBase = {
}
},

setSignature: function(identity)
{
if (ImpComposeBase.editor_on) {
$('signature')
.removeClassName('fixed')
.update(identity.hsig);
} else {
$('signature')
.addClassName('fixed')
.update(identity.sig);
}
},

updateAddressField: function(e)
{
var elt = $(e.memo.field),
Expand Down
5 changes: 4 additions & 1 deletion imp/js/compose-dimp.js
Expand Up @@ -114,6 +114,7 @@ var DimpCompose = {
this.toggleCC('bcc');
}
this.setSaveSentMail(identity.sm_save);
ImpComposeBase.setSignature(identity);
},

setSaveSentMail: function(set)
Expand Down Expand Up @@ -357,7 +358,8 @@ var DimpCompose = {

toggleHtmlEditor: function(noupdate)
{
var changed, sc, text, tmp;
var changed, sc, text, tmp,
identity = ImpComposeBase.identities[$F('identity')];

if (!DimpCore.conf.rte_avail) {
return;
Expand Down Expand Up @@ -416,6 +418,7 @@ var DimpCompose = {
}

ImpComposeBase.editor_on = !ImpComposeBase.editor_on;
ImpComposeBase.setSignature(identity);

$('htmlcheckbox').setValue(ImpComposeBase.editor_on);
$('html').setValue(Number(ImpComposeBase.editor_on));
Expand Down
3 changes: 3 additions & 0 deletions imp/js/compose.js
Expand Up @@ -73,6 +73,7 @@ var ImpCompose = {

bcc.setValue(bccval);
}
ImpComposeBase.setSignature(next);
},

uniqSubmit: function(actionID, e)
Expand Down Expand Up @@ -294,6 +295,8 @@ var ImpCompose = {
if (this.redirect) {
ImpComposeBase.focus('to');
} else {
ImpComposeBase.setSignature(ImpComposeBase.identities[$F('last_identity')]);

handler = this.keyDownHandler.bindAsEventListener(this);
/* Prevent Return from sending messages - it should bring us out
* of autocomplete, not submit the whole form. */
Expand Down
26 changes: 25 additions & 1 deletion imp/lib/Compose/Ui.php
Expand Up @@ -125,10 +125,30 @@ public function addIdentityJs()
{
$identities = array();
$identity = $GLOBALS['injector']->getInstance('IMP_Identity');
$filter = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter');

foreach (array_keys($identity->getAll('id')) as $ident) {
$sm = $identity->getValue(IMP_Mailbox::MBOX_SENT, $ident);

$sig = $identity->getSignature('text', $ident);
$html_sig = $identity->getSignature('html', $ident);
if (!strlen($html_sig) && strlen($sig)) {
$html_sig = IMP_Compose::text2html($sig);
}
$sig_dom = new Horde_Domhtml($html_sig, 'UTF-8');
$html_sig = '';
foreach ($sig_dom->getBody()->childNodes as $child) {
$html_sig .= $sig_dom->dom->saveXml($child);
}
$sig = $filter->filter(
trim($sig),
array('Text2html', 'Space2html'),
array(
array('parselevel' => Horde_Text_Filter_Text2html::NOHTML),
array()
)
);

$identities[] = array(
// Sent mail mailbox name
'sm_name' => $sm ? $sm->form_to : '',
Expand All @@ -137,7 +157,11 @@ public function addIdentityJs()
// Sent mail display name
'sm_display' => $sm ? $sm->display_html : '',
// Bcc addresses to add
'bcc' => strval($identity->getBccAddresses($ident))
'bcc' => strval($identity->getBccAddresses($ident)),
// Plain text signature
'sig' => $sig,
// HTML signature
'hsig' => $html_sig,
);
}

Expand Down
1 change: 1 addition & 0 deletions imp/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [jan] Display signature in compose view.
* [mms] Add keyboard shortcuts to allow a more granular scroll of the dynamic preview pane (Request #12750).
* [mms] Add a simple domain checker to the autocompleter that checks for common misspellings.
* [mms] Add country flag graphic to contact image information in dynamic view.
Expand Down
9 changes: 9 additions & 0 deletions imp/templates/basic/compose/compose.html.php
Expand Up @@ -201,6 +201,15 @@
</td>
</tr>

<tr>
<td class="light rightAlign">
<strong><?php echo _("Signature") ?></strong>
</td>
<td class="item">
<div id="signature" title="<?php echo _("The signature is not editable.") ?>"><?php echo $this->signature ?></div>
</td>
</tr>

<tr>
<td></td>
<td class="nowrap">
Expand Down
6 changes: 6 additions & 0 deletions imp/templates/dynamic/compose.html.php
Expand Up @@ -144,6 +144,12 @@
<?php echo $this->textFieldTag('subject') ?>
</td>
</tr>
<tr>
<td class="label"><?php echo _("Signature")?>:</td>
<td>
<div id="signature"></div>
</td>
</tr>
<tr class="atcrow">
<?php if ($this->attach): ?>
<td class="label">
Expand Down
9 changes: 8 additions & 1 deletion imp/themes/default/screen.css
Expand Up @@ -135,9 +135,16 @@ div.partsTreeDiv span span:last-child {
}

/* Compose view */
#to, #cc, #bcc, #subject {
#to, #cc, #bcc, #subject, #signature {
width: 500px;
}
#signature {
overflow: auto;
padding: 1px 5px;
min-height: 20px;
background-color: #ebeff0;
border: 1px solid #d0d0d0;
}
.spellcheck {
white-space: pre;
white-space: -moz-pre-wrap;
Expand Down

0 comments on commit 932c934

Please sign in to comment.