summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/hide_blockquote/hide_blockquote.js46
-rw-r--r--plugins/hide_blockquote/hide_blockquote.php82
-rw-r--r--plugins/hide_blockquote/localization/en_US.inc8
-rw-r--r--plugins/hide_blockquote/localization/pl_PL.inc8
-rw-r--r--plugins/hide_blockquote/package.xml54
-rw-r--r--plugins/hide_blockquote/skins/default/style.css31
-rw-r--r--skins/default/mail.css2
-rw-r--r--skins/default/print.css4
8 files changed, 232 insertions, 3 deletions
diff --git a/plugins/hide_blockquote/hide_blockquote.js b/plugins/hide_blockquote/hide_blockquote.js
new file mode 100644
index 000000000..9ab90af0d
--- /dev/null
+++ b/plugins/hide_blockquote/hide_blockquote.js
@@ -0,0 +1,46 @@
+if (window.rcmail)
+ rcmail.addEventListener('init', function() { hide_blockquote(); });
+
+function hide_blockquote()
+{
+ var limit = rcmail.env.blockquote_limit;
+
+ if (limit <= 0)
+ return;
+
+ $('pre > blockquote', $('#messagebody')).each(function() {
+ var div, link, q = $(this),
+ text = $.trim(q.text()),
+ res = text.split(/\n/);
+
+ if (res.length <= limit) {
+ // there can be also a block with very long wrapped line
+ // assume line height = 15px
+ if (q.height() <= limit * 15)
+ return;
+ }
+
+ div = $('<blockquote class="blockquote-header">')
+ .css({'white-space': 'nowrap', overflow: 'hidden', position: 'relative'})
+ .text(res[0]);
+
+ link = $('<span class="blockquote-link">')
+ .css({position: 'absolute', 'z-Index': 2})
+ .text(rcmail.gettext('hide_blockquote.show'))
+ .data('parent', div)
+ .click(function() {
+ var t = $(this), parent = t.data('parent'), visible = parent.is(':visible');
+
+ t.text(rcmail.gettext(visible ? 'hide' : 'show', 'hide_blockquote'))
+ .detach().appendTo(visible ? q : parent);
+
+ parent[visible ? 'hide' : 'show']();
+ q[visible ? 'show' : 'hide']();
+ });
+
+ link.appendTo(div);
+
+ // Modify blockquote
+ q.hide().css({position: 'relative'}).before(div);
+ });
+}
diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php
new file mode 100644
index 000000000..ca0273a5d
--- /dev/null
+++ b/plugins/hide_blockquote/hide_blockquote.php
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * Quotation block hidding
+ *
+ * Plugin that adds a possibility to hide long blocks of cited text in messages.
+ *
+ * Configuration:
+ * // Minimum number of citation lines. Longer citation blocks will be hidden.
+ * // 0 - no limit (no hidding).
+ * $rcmail_config['hide_blockquote_limit'] = 0;
+ *
+ * @version @package_version@
+ * @license GNU GPLv3+
+ * @author Aleksander Machniak <alec@alec.pl>
+ */
+class hide_blockquote extends rcube_plugin
+{
+ public $task = 'mail|settings';
+
+ function init()
+ {
+ $rcmail = rcmail::get_instance();
+
+ if ($rcmail->task == 'mail'
+ && ($rcmail->action == 'preview' || $rcmail->action == 'show')
+ && ($limit = $rcmail->config->get('hide_blockquote_limit'))
+ ) {
+ // include styles
+ $skin = $rcmail->config->get('skin');
+ if (!file_exists($this->home."/skins/$skin/style.css")) {
+ $skin = 'default';
+ }
+ $this->include_stylesheet("skins/$skin/style.css");
+
+ // Script and localization
+ $this->include_script('hide_blockquote.js');
+ $this->add_texts('localization', true);
+
+ // set env variable for client
+ $rcmail->output->set_env('blockquote_limit', $limit);
+ }
+ else if ($rcmail->task == 'settings') {
+ $dont_override = $rcmail->config->get('dont_override', array());
+ if (!in_array('hide_blockquote_limit', $dont_override)) {
+ $this->add_hook('preferences_list', array($this, 'prefs_table'));
+ $this->add_hook('preferences_save', array($this, 'save_prefs'));
+ }
+ }
+ }
+
+ function prefs_table($args)
+ {
+ if ($args['section'] != 'mailview') {
+ return $args;
+ }
+
+ $this->add_texts('localization');
+
+ $rcmail = rcmail::get_instance();
+ $limit = (int) $rcmail->config->get('hide_blockquote_limit');
+ $field_id = 'hide_blockquote_limit';
+ $input = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5));
+
+ $args['blocks']['main']['options']['hide_blockquote_limit'] = array(
+ 'title' => $this->gettext('quotelimit'),
+ 'content' => $input->show($limit ? $limit : '')
+ );
+
+ return $args;
+ }
+
+ function save_prefs($args)
+ {
+ if ($args['section'] == 'mailview') {
+ $args['prefs']['hide_blockquote_limit'] = (int) get_input_value('_hide_blockquote_limit', RCUBE_INPUT_POST);
+ }
+
+ return $args;
+ }
+
+}
diff --git a/plugins/hide_blockquote/localization/en_US.inc b/plugins/hide_blockquote/localization/en_US.inc
new file mode 100644
index 000000000..cf7eb137f
--- /dev/null
+++ b/plugins/hide_blockquote/localization/en_US.inc
@@ -0,0 +1,8 @@
+<?php
+
+$labels = array();
+$labels['hide'] = 'Hide';
+$labels['show'] = 'Show';
+$labels['quotelimit'] = 'Hide citation when lines count is greater than';
+
+?>
diff --git a/plugins/hide_blockquote/localization/pl_PL.inc b/plugins/hide_blockquote/localization/pl_PL.inc
new file mode 100644
index 000000000..0a8339149
--- /dev/null
+++ b/plugins/hide_blockquote/localization/pl_PL.inc
@@ -0,0 +1,8 @@
+<?php
+
+$labels = array();
+$labels['hide'] = 'Ukryj';
+$labels['show'] = 'Pokaż';
+$labels['quotelimit'] = 'Ukryj blok cytatu gdy liczba linii jest większa od';
+
+?>
diff --git a/plugins/hide_blockquote/package.xml b/plugins/hide_blockquote/package.xml
new file mode 100644
index 000000000..833691261
--- /dev/null
+++ b/plugins/hide_blockquote/package.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>hide_blockquote</name>
+ <channel>pear.roundcube.net</channel>
+ <summary>Citation blocks hiding for Roundcube</summary>
+ <description>This allows to hide long blocks of cited text in messages.</description>
+ <lead>
+ <name>Aleksander Machniak</name>
+ <user>alec</user>
+ <email>alec@alec.pl</email>
+ <active>yes</active>
+ </lead>
+ <date>2012-05-23</date>
+ <version>
+ <release>1.0</release>
+ <api>1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license>
+ <notes>-</notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <file name="hide_blockquote.php" role="php">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="hide_blockquote.js" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="localization/en_US.inc" role="data"></file>
+ <file name="localization/pl_PL.inc" role="data"></file>
+ <file name="skins/default/style.css" role="data"></file>
+ </dir>
+ <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.1</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease/>
+</package>
diff --git a/plugins/hide_blockquote/skins/default/style.css b/plugins/hide_blockquote/skins/default/style.css
new file mode 100644
index 000000000..7b3c871c3
--- /dev/null
+++ b/plugins/hide_blockquote/skins/default/style.css
@@ -0,0 +1,31 @@
+span.blockquote-link {
+ font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
+ top: 0;
+ cursor: pointer;
+ right: 5px;
+ height: 14px;
+ min-width: 40px;
+ padding: 0 8px;
+ font-size: 10px;
+ font-weight: bold;
+ color: #a8a8a8;
+ line-height: 14px;
+ text-decoration: none;
+ text-shadow: 0px 1px 1px #fff;
+ text-align: center;
+ border: 1px solid #e8e8e8;
+ border-top: none;
+ border-bottom-right-radius: 6px;
+ border-bottom-left-radius: 6px;
+ background: #fff;
+ background: -moz-linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#e8e8e8));
+ background: -o-linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
+ background: -ms-linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
+ background: linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
+}
+
+blockquote.blockquote-header {
+ text-overflow: ellipsis !important;
+ padding-right: 60px !important;
+} \ No newline at end of file
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 4eb1671a5..c8db8e0c8 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -1189,7 +1189,7 @@ div.message-part blockquote
border-left: 2px solid blue;
border-right: 2px solid blue;
background-color: #F6F6F6;
- margin: 2px 0px 2px 0px;
+ margin: 2px 0px;
padding: 1px 8px 1px 10px;
}
diff --git a/skins/default/print.css b/skins/default/print.css
index 59d400e5c..129770d25 100644
--- a/skins/default/print.css
+++ b/skins/default/print.css
@@ -118,8 +118,8 @@ div.message-part blockquote
border-left: 2px solid blue;
border-right: 2px solid blue;
background-color: #F6F6F6;
- margin: 0.5em 0em 0.5em 0em;
- padding: 0.25em 1em 0.25em 1em;
+ margin: 2px 0px;
+ padding: 1px 8px 1px 10px;
}
div.message-part blockquote blockquote