comparison plugins/hide_blockquote/hide_blockquote.js @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 /**
2 * Hide Blockquotes plugin script
3 *
4 * @licstart The following is the entire license notice for the
5 * JavaScript code in this file.
6 *
7 * Copyright (c) 2012-2014, The Roundcube Dev Team
8 *
9 * The JavaScript code in this page is free software: you can redistribute it
10 * and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 3 of
12 * the License, or (at your option) any later version.
13 *
14 * @licend The above is the entire license notice
15 * for the JavaScript code in this file.
16 */
17
18 if (window.rcmail)
19 rcmail.addEventListener('init', function() { hide_blockquote(); });
20
21 function hide_blockquote()
22 {
23 var limit = rcmail.env.blockquote_limit;
24
25 if (limit <= 0)
26 return;
27
28 $('div.message-part div.pre > blockquote', $('#messagebody')).each(function() {
29 var div, link, q = $(this),
30 text = $.trim(q.text()),
31 res = text.split(/\n/);
32
33 if (res.length <= limit) {
34 // there can be also a block with very long wrapped line
35 // assume line height = 15px
36 if (q.height() <= limit * 15)
37 return;
38 }
39
40 div = $('<blockquote class="blockquote-header">')
41 .css({'white-space': 'nowrap', overflow: 'hidden', position: 'relative'})
42 .text(res[0]);
43
44 link = $('<span class="blockquote-link"></span>')
45 .css({position: 'absolute', 'z-Index': 2})
46 .text(rcmail.get_label('hide_blockquote.show'))
47 .data('parent', div)
48 .click(function() {
49 var t = $(this), parent = t.data('parent'), visible = parent.is(':visible');
50
51 t.text(rcmail.get_label(visible ? 'hide' : 'show', 'hide_blockquote'))
52 .detach().appendTo(visible ? q : parent);
53
54 parent[visible ? 'hide' : 'show']();
55 q[visible ? 'show' : 'hide']();
56 });
57
58 link.appendTo(div);
59
60 // Modify blockquote
61 q.hide().css({position: 'relative'}).before(div);
62 });
63 }