Elastic skin support for vcard_attachments plugin (with some refactorings)

pull/6040/head
Aleksander Machniak 7 years ago
parent 83fe734460
commit 4ade7acdac

@ -3,7 +3,7 @@
"type": "roundcube-plugin",
"description": "Detects vCard attachments and allows to add them to address book. Also allows to attach vCards of your contacts to composed messages",
"license": "GPLv3+",
"version": "4.0",
"version": "4.1",
"authors": [
{
"name": "Thomas Bruederli",

@ -2,18 +2,26 @@
p.vcardattachment {
margin: 0.5em 1em;
border: 1px solid #999;
border-radius:4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
width: auto;
position: relative;
}
p.vcardattachment a {
p.vcardattachment span {
display: block;
background: url(vcard_add_contact.png) 4px 0px no-repeat;
padding: 0.7em 0.5em 0.3em 42px;
height: 22px;
line-height: 32px;
padding: 0 60px 0 46px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
p.vcardattachment button {
position: absolute;
right: 0;
top: 0;
margin: 6px;
}
#abookactions a.vcard span {
@ -27,3 +35,7 @@ p.vcardattachment a {
#abookactions a.vcard.disabled span {
opacity: 0.5;
}
.messagelist tr .attachment span.attachment.vcard {
background: url(vcard.png) 0 center no-repeat;
}

@ -5,15 +5,31 @@ p.vcardattachment {
background: #f9f9f9;
border: 1px solid #d3d3d3;
border-radius: 4px;
position: relative;
}
p.vcardattachment a {
p.vcardattachment span {
display: block;
background: url(vcard_add_contact.png) 6px 2px no-repeat;
padding: 1.2em 0.5em 0.7em 46px;
line-height: 32px;
padding: 0 60px 0 46px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
p.vcardattachment button {
position: absolute;
right: 0;
top: 0;
margin: 5px;
}
a.listbutton.vcard .inner
{
background-position: center -2107px;
}
.messagelist tbody tr .attachment span.attachment.vcard {
background: url(vcard.png) 0 center no-repeat;
}

@ -21,6 +21,7 @@ class vcard_attachments extends rcube_plugin
if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
$this->add_hook('message_load', array($this, 'message_load'));
$this->add_hook('message_objects', array($this, 'message_objects'));
$this->add_hook('template_object_messagebody', array($this, 'html_output'));
}
else if ($rcmail->action == 'upload') {
@ -31,7 +32,7 @@ class vcard_attachments extends rcube_plugin
$btn_class = strpos($skin_path, 'classic') ? 'button' : 'listbutton';
$this->add_texts('localization', true);
$this->include_stylesheet($skin_path . '/style.css');
$this->include_stylesheet($skin_path . '/style.css', true);
$this->include_script('vcardattach.js');
$this->add_button(
array(
@ -46,8 +47,8 @@ class vcard_attachments extends rcube_plugin
'compose-contacts-toolbar');
}
else if (!$rcmail->output->framed && (!$rcmail->action || $rcmail->action == 'list')) {
$icon = 'plugins/vcard_attachments/' .$this->local_skin_path(). '/vcard.png';
$rcmail->output->set_env('vcard_icon', $icon);
$skin_path = $this->local_skin_path();
$this->include_stylesheet($skin_path . '/style.css', true);
$this->include_script('vcardattach.js');
}
@ -81,12 +82,13 @@ class vcard_attachments extends rcube_plugin
}
/**
* This callback function adds a box below the message content
* This callback function adds a box above the message content
* if there is a vcard attachment available
*/
function html_output($p)
function message_objects($p)
{
$attach_script = false;
$rcmail = rcmail::get_instance();
foreach ($this->vcard_parts as $part) {
$vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
@ -96,11 +98,6 @@ class vcard_attachments extends rcube_plugin
continue;
}
// remove part's body
if (in_array($part, $this->vcard_bodies)) {
$p['content'] = '';
}
foreach ($vcards as $idx => $vcard) {
// skip invalid vCards
if (empty($vcard->email) || empty($vcard->email[0])) {
@ -108,15 +105,16 @@ class vcard_attachments extends rcube_plugin
}
$display = $vcard->displayname . ' <'.$vcard->email[0].'>';
$vid = rcube::JQ($part.':'.$idx);
// add box below message body
$p['content'] .= html::p(array('class' => 'vcardattachment'),
html::a(array(
'href' => "#",
'onclick' => "return plugin_vcard_save_contact('" . rcube::JQ($part.':'.$idx) . "')",
'title' => $this->gettext('addvcardmsg'),
),
html::span(null, rcube::Q($display)))
$p['content'][] = html::p(array('class' => 'vcardattachment aligned-buttons'),
html::span(null, rcube::Q($display)) .
html::tag('button', array(
'onclick' => "return plugin_vcard_save_contact('$vid')",
'title' => $this->gettext('addvcardmsg'),
'class' => 'import',
), rcube::Q($rcmail->gettext('import')))
);
}
@ -125,7 +123,23 @@ class vcard_attachments extends rcube_plugin
if ($attach_script) {
$this->include_script('vcardattach.js');
$this->include_stylesheet($this->local_skin_path() . '/style.css');
$this->include_stylesheet($this->local_skin_path() . '/style.css', true);
}
return $p;
}
/**
* This callback function removes message part's content
* for parts that are vcards
*/
function html_output($p)
{
foreach ($this->vcard_parts as $part) {
// remove part's body
if (in_array($part, $this->vcard_bodies)) {
$p['content'] = '';
}
}
return $p;

@ -4,7 +4,7 @@
* @licstart The following is the entire license notice for the
* JavaScript code in this file.
*
* Copyright (c) 2012-2016, The Roundcube Dev Team
* Copyright (c) 2012-2017, The Roundcube Dev Team
*
* The JavaScript code in this page is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
@ -25,11 +25,8 @@ function plugin_vcard_save_contact(mime_id)
function plugin_vcard_insertrow(data)
{
var ctype = data.row.ctype;
if (ctype == 'text/vcard' || ctype == 'text/x-vcard' || ctype == 'text/directory') {
$('#rcmrow' + rcmail.html_identifier(data.uid, true) + ' > td.attachment')
.html('<img src="' + rcmail.env.vcard_icon + '" alt="" />');
if (data.row.ctype.match(/^(text\/vcard|text\/x-vcard|text\/directory)$/i)) {
$(data.row.obj).find('.attachment > .attachment').addClass('vcard');
}
}

Loading…
Cancel
Save