commit | author | age
|
85a617
|
1 |
if (window.rcmail) |
AM |
2 |
rcmail.addEventListener('init', function() { hide_blockquote(); }); |
|
3 |
|
|
4 |
function hide_blockquote() |
|
5 |
{ |
|
6 |
var limit = rcmail.env.blockquote_limit; |
|
7 |
|
|
8 |
if (limit <= 0) |
|
9 |
return; |
|
10 |
|
|
11 |
$('pre > blockquote', $('#messagebody')).each(function() { |
|
12 |
var div, link, q = $(this), |
|
13 |
text = $.trim(q.text()), |
|
14 |
res = text.split(/\n/); |
|
15 |
|
|
16 |
if (res.length <= limit) { |
|
17 |
// there can be also a block with very long wrapped line |
|
18 |
// assume line height = 15px |
|
19 |
if (q.height() <= limit * 15) |
|
20 |
return; |
|
21 |
} |
|
22 |
|
|
23 |
div = $('<blockquote class="blockquote-header">') |
|
24 |
.css({'white-space': 'nowrap', overflow: 'hidden', position: 'relative'}) |
|
25 |
.text(res[0]); |
|
26 |
|
4a5c1f
|
27 |
link = $('<span class="blockquote-link"></span>') |
85a617
|
28 |
.css({position: 'absolute', 'z-Index': 2}) |
AM |
29 |
.text(rcmail.gettext('hide_blockquote.show')) |
|
30 |
.data('parent', div) |
|
31 |
.click(function() { |
|
32 |
var t = $(this), parent = t.data('parent'), visible = parent.is(':visible'); |
|
33 |
|
|
34 |
t.text(rcmail.gettext(visible ? 'hide' : 'show', 'hide_blockquote')) |
|
35 |
.detach().appendTo(visible ? q : parent); |
|
36 |
|
|
37 |
parent[visible ? 'hide' : 'show'](); |
|
38 |
q[visible ? 'show' : 'hide'](); |
|
39 |
}); |
|
40 |
|
|
41 |
link.appendTo(div); |
|
42 |
|
|
43 |
// Modify blockquote |
|
44 |
q.hide().css({position: 'relative'}).before(div); |
|
45 |
}); |
|
46 |
} |