Skip to content

Commit 44b0165

Browse files
committed
Fix plugin 'hide_blockquote' for iframed message parts
1 parent 601d394 commit 44b0165

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

plugins/hide_blockquote/hide_blockquote.js

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,64 @@
1717

1818
if (window.rcmail) {
1919
rcmail.addEventListener('init', function () {
20-
hide_blockquote();
21-
});
22-
}
20+
var limit = rcmail.env.blockquote_limit;
2321

24-
function hide_blockquote() {
25-
var limit = rcmail.env.blockquote_limit;
22+
if (limit <= 0) {
23+
return;
24+
}
2625

27-
if (limit <= 0) {
28-
return;
29-
}
26+
$('.framed-message-part').each(function (_id, iframe) {
27+
$(iframe).on('load', function () {
28+
$(iframe.contentDocument).find('.message-part div.pre > blockquote').each(function (_id, elem) {
29+
hide_blockquote(elem, limit);
30+
});
31+
window.dispatchEvent(new Event('resize'));
32+
});
33+
});
34+
});
35+
}
3036

31-
$('div.message-part div.pre > blockquote', $('#messagebody')).each(function () {
32-
var res, text, div, link, q = $(this);
37+
function hide_blockquote(elem, limit) {
38+
var res, text, div, link, q = $(elem);
3339

34-
// Add new-line character before each blockquote
35-
// This fixes counting lines of text, it also prevents
36-
// from merging lines from different quoting level
37-
$('blockquote').before(document.createTextNode('\n'));
40+
// Add new-line character before each blockquote
41+
// This fixes counting lines of text, it also prevents
42+
// from merging lines from different quoting level
43+
$('blockquote').before(document.createTextNode('\n'));
3844

39-
text = q.text().trim();
40-
res = text.split(/\n/);
45+
text = q.text().trim();
46+
res = text.split(/\n/);
4147

42-
if (res.length <= limit) {
43-
// there can be also a block with very long wrapped line
44-
// assume line height = 15px
45-
if (q.height() <= limit * 15) {
46-
return;
47-
}
48+
if (res.length <= limit) {
49+
// there can be also a block with very long wrapped line
50+
// assume line height = 15px
51+
if (q.height() <= limit * 15) {
52+
return;
4853
}
54+
}
4955

50-
div = $('<blockquote class="blockquote-header">')
51-
.css({ 'white-space': 'nowrap', overflow: 'hidden', position: 'relative' })
52-
.text(res[0]);
56+
div = $('<blockquote class="blockquote-header">')
57+
.css({ 'white-space': 'nowrap', overflow: 'hidden', position: 'relative' })
58+
.text(res[0]);
5359

54-
link = $('<span class="blockquote-link"></span>')
55-
.css({ position: 'absolute', 'z-Index': 2 })
56-
.text(rcmail.get_label('hide_blockquote.show'))
57-
.data('parent', div)
58-
.click(function () {
59-
var t = $(this), parent = t.data('parent'), visible = parent.is(':visible');
60+
link = $('<span class="blockquote-link"></span>')
61+
.css({ position: 'absolute', 'z-Index': 2 })
62+
.text(rcmail.get_label('hide_blockquote.show'))
63+
.data('parent', div)
64+
.click(function () {
65+
var t = $(this), parent = t.data('parent'), visible = parent.is(':visible');
6066

61-
t.text(rcmail.get_label(visible ? 'hide' : 'show', 'hide_blockquote'))
62-
.detach().appendTo(visible ? q : parent).toggleClass('collapsed');
67+
t.text(rcmail.get_label(visible ? 'hide' : 'show', 'hide_blockquote'))
68+
.detach().appendTo(visible ? q : parent).toggleClass('collapsed');
6369

64-
parent[visible ? 'hide' : 'show']();
65-
q[visible ? 'show' : 'hide']();
66-
});
70+
parent[visible ? 'hide' : 'show']();
71+
q[visible ? 'show' : 'hide']();
6772

68-
link.appendTo(div);
73+
window.dispatchEvent(new Event('resize'));
74+
});
6975

70-
// Modify blockquote
71-
q.hide().css({ position: 'relative' }).before(div);
72-
});
76+
link.appendTo(div);
77+
78+
// Modify blockquote
79+
q.hide().css({ position: 'relative' }).before(div);
7380
}

skins/elastic/styles/styles.less

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ body.task-error-login #layout {
368368
span.blockquote-link {
369369
top: 0;
370370
cursor: pointer;
371-
right: .5rem;
371+
right: 4.5rem;
372372
min-width: 4rem;
373373
padding: .2rem .25rem .2rem .5rem;
374374
font-size: 90%;
@@ -396,7 +396,8 @@ body.task-error-login #layout {
396396

397397
&.blockquote-header {
398398
text-overflow: ellipsis !important;
399-
padding-right: 5rem !important;
399+
padding-right: 4.5rem !important;
400+
min-height: 3ex;
400401
}
401402
}
402403
}

0 commit comments

Comments
 (0)