From 85a6173879bb2486e394fb8e6b8a107a59167374 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 23 May 2012 12:56:20 +0200 Subject: hide_blockquote - a new plugin for hiding citation blocks --- plugins/hide_blockquote/hide_blockquote.js | 46 ++++++++++++++ plugins/hide_blockquote/hide_blockquote.php | 82 +++++++++++++++++++++++++ plugins/hide_blockquote/localization/en_US.inc | 8 +++ plugins/hide_blockquote/localization/pl_PL.inc | 8 +++ plugins/hide_blockquote/package.xml | 54 ++++++++++++++++ plugins/hide_blockquote/skins/default/style.css | 31 ++++++++++ 6 files changed, 229 insertions(+) create mode 100644 plugins/hide_blockquote/hide_blockquote.js create mode 100644 plugins/hide_blockquote/hide_blockquote.php create mode 100644 plugins/hide_blockquote/localization/en_US.inc create mode 100644 plugins/hide_blockquote/localization/pl_PL.inc create mode 100644 plugins/hide_blockquote/package.xml create mode 100644 plugins/hide_blockquote/skins/default/style.css 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 = $('
') + .css({'white-space': 'nowrap', overflow: 'hidden', position: 'relative'}) + .text(res[0]); + + 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 @@ + + */ +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 @@ + 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 @@ + 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 @@ + + + hide_blockquote + pear.roundcube.net + Citation blocks hiding for Roundcube + This allows to hide long blocks of cited text in messages. + + Aleksander Machniak + alec + alec@alec.pl + yes + + 2012-05-23 + + 1.0 + 1.0 + + + stable + stable + + GNU GPLv3+ + - + + + + + + + + + + + + + + + + + + + + 5.2.1 + + + 1.7.0 + + + + + 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 -- cgit v1.2.3