diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-08-18 23:20:57 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-08-18 23:20:57 +0200 |
commit | eb1dcb7d003293a56993552f6cc130ad13abcc30 (patch) | |
tree | dd219e7dd6bc69b98bb99b1fbde3cca3e824b822 /lib/JWebmail | |
parent | 1229bb6a838e96eb52be7aa1cac8d692746bc783 (diff) |
added tabbing to multipart/alternative
Diffstat (limited to 'lib/JWebmail')
-rw-r--r-- | lib/JWebmail/View/RenderMail.pm | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/JWebmail/View/RenderMail.pm b/lib/JWebmail/View/RenderMail.pm index 387e586..63d3bdb 100644 --- a/lib/JWebmail/View/RenderMail.pm +++ b/lib/JWebmail/View/RenderMail.pm @@ -36,29 +36,29 @@ sub render_multipart_alternative { my ($self, $_subtype, $content, $path) = @_; my $parts = $content->{parts}; - my $R = qq'<div class="jwm-mail-body jwm-mail-body-multipart-alternative"\n>'; - my $i = 0; - my $end; - - for (reverse @$parts) { - if (!$end) { - my $x = $self->mime_render(to_mime_types($_->{head}), $_->{body}, [@$path, $#$parts-$i]); - if ($x) { - $R .= $x; - $end = 1; - } - } - else { - $R .= '<details class="jwm-mail-body-multipart-alternative-extra" >'; - $R .= '<summary>'; - $R .= to_mime_type($_->{head}); - $R .= "</summary>\n"; - $R .= $self->mime_render(to_mime_types($_->{head}), $_->{body}, [@$path, $#$parts-$i]); - $R .= "</details>\n"; - } + my $T = "<div class=tabs><ul>\n"; + my $C = '<div class=jwm-mail-body-multipart-alternative-bodies>'; + my $i = 1; + my ($init, @rest) = reverse @$parts; + + $T .= '<li class=is-active data=0><a>' . to_mime_type($init->{head}) . '</a></li>'; + + $C .= "<div class=jwm-mail-body-multipart-alternative-body>\n"; + $C .= $self->mime_render(to_mime_types($init->{head}), $init->{body}, [@$path, $#$parts]); + $C .= "</div>\n"; + + for (@rest) { + $T .= "<li data=$i><a>" . to_mime_type($_->{head}) . "</a></li>\n"; + + $C .= qq'<div class="jwm-mail-body-multipart-alternative-body is-hidden">\n'; + $C .= $self->mime_render(to_mime_types($_->{head}), $_->{body}, [@$path, $#$parts-$i]); + $C .= "</div>\n"; + ++$i; } - return $R . "</div>\n"; + $C .= qq'</div>'; + $T .= qq'</ul></div>'; + return qq'<script src=/src/rendermail.js></script><div class="jwm-mail-body jwm-mail-body-multipart-alternative">\n$T\n$C\n</div>\n'; } sub render_multipart { @@ -69,6 +69,7 @@ sub render_multipart { my $i = 0; for (@$parts) { + $R .= "<div class=media><div class=media-content>\n"; if ( !$_->{head}{content_disposition} || lc $_->{head}{content_disposition} eq 'none' || lc $_->{head}{content_disposition} eq 'inline') { @@ -86,6 +87,7 @@ sub render_multipart { warn "unknown Content-Disposition '$_->{head}{content_disposition}'"; $R .= "<p>unknown Content-Disposition '$_->{head}{content_disposition}'</p>\n"; } + $R .= "</div></div>\n"; ++$i; } return $R . "</div>\n"; |