From b1710c8f53ed757f1c06e84e4c2790832232c58f Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 7 Apr 2007 07:34:21 +0000 Subject: [PATCH] =?utf8?q?Bug=20262275:=20Allow=20to=20expand/collapse=20c?= =?utf8?q?omments=20when=20viewing=20bugs=20-=20Patch=20by=20Fr=C3=83?= =?utf8?q?=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r=3Dmyk?= =?utf8?q?=20a=3DLpSolit?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/standard/global.css | 4 ++ template/en/default/bug/comments.html.tmpl | 61 +++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/skins/standard/global.css b/skins/standard/global.css index 1687a4aa0c..2449587499 100644 --- a/skins/standard/global.css +++ b/skins/standard/global.css @@ -322,6 +322,10 @@ div.user_match { padding: 0.5em 1em; } +.collapsed { + display: none; +} + /* Rules specific for printing */ @media print { #header, #footer { diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl index 9d05ba4ace..428b8771c1 100644 --- a/template/en/default/bug/comments.html.tmpl +++ b/template/en/default/bug/comments.html.tmpl @@ -37,6 +37,58 @@ comment_elem.className.replace(/(\s*|^)bz_private(\s*|$)/, '$2'); } } + + /* The functions below expand and collapse comments */ + + function toggle_comment_display(link, comment_id) { + var comment = document.getElementById('comment_text_' + comment_id); + var re = new RegExp(/\bcollapsed\b/); + if (comment.className.match(re)) + expand_comment(link, comment); + else + collapse_comment(link, comment); + } + + function toggle_all_comments(action) { + var num_comments = [% comments.size FILTER html %]; + + // If for some given ID the comment doesn't exist, this doesn't mean + // there are no more comments, but that the comment is private and + // the user is not allowed to view it. + + for (var id = 0; id < num_comments; id++) { + var comment = document.getElementById('comment_text_' + id); + if (!comment) + continue; + + var link = document.getElementById('comment_link_' + id); + if (action == 'collapse') + collapse_comment(link, comment); + else + expand_comment(link, comment); + } + } + + function collapse_comment(link, comment) { + link.innerHTML = "(+)"; + link.title = "Expand the comment."; + comment.className = "collapsed"; + } + + function expand_comment(link, comment) { + link.innerHTML = "(-)"; + link.title = "Collapse the comment"; + comment.className = ""; + } + + /* This way, we are sure that browsers which do not support JS + * won't display this link */ + + function addCollapseLink(count) { + document.write(' (-) '); + } //--> @@ -69,6 +121,11 @@ [% END %] [% END %] +[% IF mode == "edit" %] + Collapse All Comments - + Expand All Comments +
+[% END %] [% FOREACH comment = comments %] [% IF count >= start_at %] @@ -96,9 +153,10 @@ - Description:   + Description: [% IF mode == "edit" %] [%%] [% END %] @@ -122,6 +180,7 @@ [% IF mode == "edit" %] [% END %] ------- -- 2.47.3