Thomas Bruederli
2012-05-23 2b1b8a079b28fa4a9de9a98c32486fa723507b8c
Merge branch 'master' of github.com:roundcube/roundcubemail
6 files added
2 files modified
235 ■■■■■ changed files
plugins/hide_blockquote/hide_blockquote.js 46 ●●●●● patch | view | raw | blame | history
plugins/hide_blockquote/hide_blockquote.php 82 ●●●●● patch | view | raw | blame | history
plugins/hide_blockquote/localization/en_US.inc 8 ●●●●● patch | view | raw | blame | history
plugins/hide_blockquote/localization/pl_PL.inc 8 ●●●●● patch | view | raw | blame | history
plugins/hide_blockquote/package.xml 54 ●●●●● patch | view | raw | blame | history
plugins/hide_blockquote/skins/default/style.css 31 ●●●●● patch | view | raw | blame | history
skins/default/mail.css 2 ●●● patch | view | raw | blame | history
skins/default/print.css 4 ●●●● patch | view | raw | blame | history
plugins/hide_blockquote/hide_blockquote.js
New file
@@ -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);
  });
}
plugins/hide_blockquote/hide_blockquote.php
New file
@@ -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;
    }
}
plugins/hide_blockquote/localization/en_US.inc
New file
@@ -0,0 +1,8 @@
<?php
$labels = array();
$labels['hide'] = 'Hide';
$labels['show'] = 'Show';
$labels['quotelimit'] = 'Hide citation when lines count is greater than';
?>
plugins/hide_blockquote/localization/pl_PL.inc
New file
@@ -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';
?>
plugins/hide_blockquote/package.xml
New file
@@ -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>
plugins/hide_blockquote/skins/default/style.css
New file
@@ -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;
}
skins/default/mail.css
@@ -1189,7 +1189,7 @@
  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;
}
skins/default/print.css
@@ -118,8 +118,8 @@
  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