Skip to content

Commit

Permalink
Make signatures editable.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Oct 25, 2013
1 parent 255bfc5 commit 7ecbc62
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 84 deletions.
4 changes: 4 additions & 0 deletions framework/Editor/js/ckeditor/nomargin.css
@@ -0,0 +1,4 @@
body {
margin: 0;
padding: 0;
}
7 changes: 4 additions & 3 deletions framework/Editor/package.xml
Expand Up @@ -16,8 +16,7 @@
<email>slusarz@horde.org</email>
<active>yes</active>
</lead>
<date>2013-02-11</date>
<time>19:10:42</time>
<date>2013-10-17</date>
<version>
<release>2.0.4</release>
<api>1.0.0</api>
Expand Down Expand Up @@ -583,6 +582,7 @@
<file name="config.js" role="horde" />
<file name="contents.css" role="horde" />
<file name="LICENSE.html" role="horde" />
<file name="nomargin.css" role="horde" />
</dir> <!-- /js/ckeditor -->
</dir> <!-- /js -->
<dir name="lib">
Expand Down Expand Up @@ -640,6 +640,7 @@
<install as="js/ckeditor/config.js" name="js/ckeditor/config.js" />
<install as="js/ckeditor/contents.css" name="js/ckeditor/contents.css" />
<install as="js/ckeditor/LICENSE.html" name="js/ckeditor/LICENSE.html" />
<install as="js/ckeditor/nomargin.css" name="js/ckeditor/nomargin.css" />
<install as="js/ckeditor/images/spacer.gif" name="js/ckeditor/images/spacer.gif" />
<install as="js/ckeditor/lang/af.js" name="js/ckeditor/lang/af.js" />
<install as="js/ckeditor/lang/ar.js" name="js/ckeditor/lang/ar.js" />
Expand Down Expand Up @@ -1228,7 +1229,7 @@ Initial packaging
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-02-11</date>
<date>2013-10-17</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
Expand Down
2 changes: 1 addition & 1 deletion imp/docs/CHANGES
Expand Up @@ -4,7 +4,7 @@ v6.2.0-git

[mms] Better reporting of e-mail address errors when composing.
[mms] Add list information display to dynamic view.
[jan] Display signature in compose view.
[jan] Add signatures back to compose view.
[mms] Add keyboard shortcuts to allow a more granular scroll of the dynamic
preview pane (Request #12750).
[mms] Add country flag graphic to contact image information in dynamic view.
Expand Down
41 changes: 31 additions & 10 deletions imp/js/compose-base.js
Expand Up @@ -8,7 +8,7 @@

var ImpComposeBase = {

// Vars defaulting to null: editor_on, identities
// Vars defaulting to null: editor_on, identities, rte, rte_loade

getSpellChecker: function()
{
Expand Down Expand Up @@ -59,16 +59,37 @@ var ImpComposeBase = {

setSignature: function(identity)
{
var s = $('signature');

if (s) {
if (ImpComposeBase.editor_on) {
s.removeClassName('fixed')
.update(identity.hsig);
} else {
s.addClassName('fixed')
.update(identity.sig);
var config, s = $('signature');

if (!s) {
return;
}

if (this.editor_on) {
s.removeClassName('fixed')
.update(identity.hsig);

if (Object.isUndefined(this.rte_loaded)) {
CKEDITOR.on('instanceReady', function(evt) {
this.rte_loaded = true;
}.bind(this));
CKEDITOR.on('instanceDestroyed', function(evt) {
this.rte_loaded = false;
}.bind(this));
}

config = Object.clone(IMP.ckeditor_config);
config.removePlugins = 'toolbar,elementspath';
config.contentsCss = [ CKEDITOR.basePath + 'contents.css', CKEDITOR.basePath + 'nomargin.css' ];
config.height = $('signatureBorder').getLayout().get('height');
this.rte = CKEDITOR.replace('signature', config);
} else {
if (this.rte) {
this.rte.destroy(true);
delete this.rte;
}
s.addClassName('fixed')
.update(identity.sig);
}
},

Expand Down
3 changes: 3 additions & 0 deletions imp/js/compose-dimp.js
Expand Up @@ -235,6 +235,9 @@ var DimpCompose = {
// Move HTML text to textarea field for submission.
if (ImpComposeBase.editor_on) {
this.rte.updateElement();
if (!Object.isUndefined(ImpComposeBase.rte)) {
ImpComposeBase.rte.updateElement();
}
}

DimpCore.doAction(
Expand Down
1 change: 1 addition & 0 deletions imp/lib/Ajax/Application/Handler/Common.php
Expand Up @@ -522,6 +522,7 @@ public function sendMessage()
$headers,
$identity,
array(
'signature' => $this->vars->signature,
'encrypt' => ($prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $this->vars->encrypt),
'html' => $this->vars->html,
'pgp_attach_pubkey' => $this->vars->pgp_attach_pubkey,
Expand Down
90 changes: 39 additions & 51 deletions imp/lib/Compose.php
Expand Up @@ -653,48 +653,25 @@ public function hasDrafts()
* of this message.
* @param array $opts An array of options w/the
* following keys:
* <ul>
* <li>
* encrypt: (integer) A flag whether to encrypt or sign the message.
* - encrypt: (integer) A flag whether to encrypt or sign the message.
* One of:
* <ul>
* <li>IMP_Crypt_Pgp::ENCRYPT</li>
* <li>IMP_Crypt_Pgp::SIGNENC</li>
* <li>IMP_Crypt_Smime::ENCRYPT</li>
* <li>IMP_Crypt_Smime::SIGNENC</li>
* </ul>
* </li>
* <li>
* html: (boolean) Whether this is an HTML message.
* DEFAULT: false
* </li>
* <li>
* pgp_attach_pubkey: (boolean) Attach the user's PGP public key to the
* message?
* </li>
* <li>
* priority: (string) The message priority ('high', 'normal', 'low').
* </li>
* <li>
* save_sent: (boolean) Save sent mail?
* </li>
* <li>
* sent_mail: (IMP_Mailbox) The sent-mail mailbox (UTF-8).
* </li>
* <li>
* save_attachments: (bool) Save attachments with the message?
* </li>
* <li>
* readreceipt: (boolean) Add return receipt headers?
* </li>
* <li>
* useragent: (string) The User-Agent string to use.
* </li>
* <li>
* vcard_attach: (string) Attach the user's vCard (value is name to
* display as vcard filename).
* </li>
* </ul>
* - IMP_Crypt_Pgp::ENCRYPT</li>
* - IMP_Crypt_Pgp::SIGNENC</li>
* - IMP_Crypt_Smime::ENCRYPT</li>
* - IMP_Crypt_Smime::SIGNENC</li>
* - html: (boolean) Whether this is an HTML message.
* DEFAULT: false
* - pgp_attach_pubkey: (boolean) Attach the user's PGP public key to the
* message?
* - priority: (string) The message priority ('high', 'normal', 'low').
* - save_sent: (boolean) Save sent mail?
* - sent_mail: (IMP_Mailbox) The sent-mail mailbox (UTF-8).
* - save_attachments: (bool) Save attachments with the message?
* - signature: (string) The message signature.
* - readreceipt: (boolean) Add return receipt headers?
* - useragent: (string) The User-Agent string to use.
* - vcard_attach: (string) Attach the user's vCard (value is name to
* display as vcard filename).
*
* @throws Horde_Exception
* @throws IMP_Compose_Exception
Expand Down Expand Up @@ -750,7 +727,7 @@ public function buildAndSendMessage(
'html' => !empty($opts['html']),
'identity' => $identity,
'pgp_attach_pubkey' => (!empty($opts['pgp_attach_pubkey']) && $prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')),
'signature' => $identity,
'signature' => is_null($opts['signature']) ? $identity : $opts['signature'],
'vcard_attach' => ((!empty($opts['vcard_attach']) && $registry->hasMethod('contacts/ownVCard')) ? ((strlen($opts['vcard_attach']) ? $opts['vcard_attach'] : 'vcard') . '.vcf') : null)
);

Expand Down Expand Up @@ -1316,8 +1293,8 @@ public function recipientList($hdr)
* - nofinal: (boolean) This is not a message which will be sent out.
* - noattach: (boolean) Don't add attachment information.
* - pgp_attach_pubkey: (boolean) Attach the user's PGP public key?
* - signature: (IMP_Prefs_Identity) If set, add the signature to the
* message?
* - signature: (IMP_Prefs_Identity|string) If set, add the signature to
* the message.
* - vcard_attach: (string) If set, attach user's vcard to message.
*
* @return Horde_Mime_Part The MIME message to send.
Expand Down Expand Up @@ -1361,15 +1338,26 @@ protected function _createMimeMessage(

/* Add signature data. */
if (!empty($options['signature'])) {
$sig = $options['signature']->getSignature('text');
$body .= $sig;

if (!empty($options['html'])) {
$html_sig = $options['signature']->getSignature('html');
if (!strlen($html_sig) && strlen($sig)) {
$html_sig = $this->text2html($sig);
if (is_string($options['signature'])) {
if (empty($options['html'])) {
$body .= $options['signature'];
} else {
$html_sig = $options['signature'];
$body .= "\n" . $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($html_sig, 'Html2text');
}
} else {
$sig = $options['signature']->getSignature('text');
$body .= $sig;

if (!empty($options['html'])) {
$html_sig = $options['signature']->getSignature('html');
if (!strlen($html_sig) && strlen($sig)) {
$html_sig = $this->text2html($sig);
}

}
}
if (!empty($options['html'])) {
$sig_dom = new Horde_Domhtml($html_sig, 'UTF-8');
foreach ($sig_dom->getBody()->childNodes as $child) {
$body_html_body->appendChild($body_html->dom->importNode($child, true));
Expand Down
9 changes: 1 addition & 8 deletions imp/lib/Compose/Ui.php
Expand Up @@ -157,14 +157,7 @@ public function addIdentityJs()
$html_sig .= $sig_dom->dom->saveXml($child);
}

$entry['sig'] = $filter->filter(
trim($sig),
array('Text2html', 'Space2html'),
array(
array('parselevel' => Horde_Text_Filter_Text2html::NOHTML),
array()
)
);
$entry['sig'] = trim($sig);
$entry['hsig'] = $html_sig;
}

Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Editor.php
Expand Up @@ -83,7 +83,7 @@ public function init($id = null)

$buttons = $prefs->getValue('ckeditor_buttons');
if (!empty($buttons)) {
$config[] = 'toolbar: ' . $prefs->getValue('ckeditor_buttons');
$config[] = 'toolbar: ' . $buttons;
}

$page_output->addInlineScript(array(
Expand Down
2 changes: 1 addition & 1 deletion imp/package.xml
Expand Up @@ -35,7 +35,7 @@
<notes>
* [mms] Better reporting of e-mail address errors when composing.
* [mms] Add list information display to dynamic view.
* [jan] Display signature in compose view.
* [jan] Add signatures back to compose view.
* [mms] Add keyboard shortcuts to allow a more granular scroll of the dynamic preview pane (Request #12750).
* [mms] Add country flag graphic to contact image information in dynamic view.
* [mms] Address autocompleter on dynamic and basic page now uses a fancy UI.
Expand Down
4 changes: 3 additions & 1 deletion imp/templates/dynamic/compose.html.php
Expand Up @@ -208,7 +208,9 @@
<span id="signatureToggle" class="iconImg<?php if ($this->sigExpanded) echo ' signatureExpanded' ?>"></span>
<?php echo _("Signature")?>:
</div>
<div id="signature"<?php if (!$this->sigExpanded) echo ' style="display:none"' ?> title="<?php echo _("The signature is not editable.") ?>"></div>
<div id="signatureBorder">
<textarea id="signature" name="signature"<?php if (!$this->sigExpanded) echo ' style="display:none"' ?>></textarea>
</div>
</div>
<?php endif; ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion imp/themes/default/basic/screen.css
Expand Up @@ -224,7 +224,7 @@ div.msgActions, #fmanager div.folderActions {
.composebody {
padding: 2px;
}
#text_identity, #signature {
#text_identity, #signatureBorder {
width: 500px;
}
#compose td.light {
Expand Down
2 changes: 1 addition & 1 deletion imp/themes/default/dynamic/screen.css
Expand Up @@ -690,7 +690,7 @@ div.dimpActionsMsg #windowclose {
cursor: default;
padding: 10px;
}
#signature {
#signatureBorder {
margin-top: 4px;
}
#signatureParent .label {
Expand Down
20 changes: 14 additions & 6 deletions imp/themes/default/screen.css
Expand Up @@ -138,13 +138,21 @@ div.partsTreeDiv {
#to, #cc, #bcc, #subject {
width: 500px;
}
#signature {
overflow: auto;
padding: 1px 5px;
min-height: 20px;
max-height: 52px;
background-color: #ebeff0;
#signatureBorder {
height: 4.4em;
border: 1px solid #d0d0d0;
background-color: #fff;
padding: 0.2em 5px;
}
#signature {
height: 100%;
width: 100%;
border: 0;
background-color: #fff;
}
#signatureBorder .cke_skin_kama, #signatureBorder .cke_skin_kama .cke_wrapper {
border: 0;
padding: 0;
}
.spellcheck {
white-space: pre;
Expand Down

0 comments on commit 7ecbc62

Please sign in to comment.