|
17 | 17 |
|
18 | 18 | if (window.rcmail) { |
19 | 19 | rcmail.addEventListener('init', function () { |
20 | | - hide_blockquote(); |
21 | | - }); |
22 | | -} |
| 20 | + var limit = rcmail.env.blockquote_limit; |
23 | 21 |
|
24 | | -function hide_blockquote() { |
25 | | - var limit = rcmail.env.blockquote_limit; |
| 22 | + if (limit <= 0) { |
| 23 | + return; |
| 24 | + } |
26 | 25 |
|
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 | +} |
30 | 36 |
|
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); |
33 | 39 |
|
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')); |
38 | 44 |
|
39 | | - text = q.text().trim(); |
40 | | - res = text.split(/\n/); |
| 45 | + text = q.text().trim(); |
| 46 | + res = text.split(/\n/); |
41 | 47 |
|
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; |
48 | 53 | } |
| 54 | + } |
49 | 55 |
|
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]); |
53 | 59 |
|
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'); |
60 | 66 |
|
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'); |
63 | 69 |
|
64 | | - parent[visible ? 'hide' : 'show'](); |
65 | | - q[visible ? 'show' : 'hide'](); |
66 | | - }); |
| 70 | + parent[visible ? 'hide' : 'show'](); |
| 71 | + q[visible ? 'show' : 'hide'](); |
67 | 72 |
|
68 | | - link.appendTo(div); |
| 73 | + window.dispatchEvent(new Event('resize')); |
| 74 | + }); |
69 | 75 |
|
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); |
73 | 80 | } |
0 commit comments