Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
f7dde138
Commit
f7dde138
authored
May 17, 2010
by
Edmund Wong
Committed by
Frédéric Buclin
May 17, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 460799: Move JS code out of bug/comments.html.tmpl
r/a=LpSolit
parent
2cdcaa08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
72 deletions
+92
-72
comments.js
js/comments.js
+88
-0
comments.html.tmpl
template/en/default/bug/comments.html.tmpl
+4
-72
No files found.
js/comments.js
0 → 100644
View file @
f7dde138
/* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Bugzilla Bug Tracking System.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
* Max Kanat-Alexander <mkanat@bugzilla.org>
* Edmund Wong <ewong@pw-wspx.org>
*/
function
updateCommentPrivacy
(
checkbox
,
id
)
{
var
comment_elem
=
document
.
getElementById
(
'comment_text_'
+
id
).
parentNode
;
if
(
checkbox
.
checked
)
{
if
(
!
comment_elem
.
className
.
match
(
'bz_private'
))
{
comment_elem
.
className
=
comment_elem
.
className
.
concat
(
' bz_private'
);
}
}
else
{
comment_elem
.
className
=
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
(
/
\b
collapsed
\b
/
);
if
(
comment
.
className
.
match
(
re
))
expand_comment
(
link
,
comment
);
else
collapse_comment
(
link
,
comment
);
}
function
toggle_all_comments
(
action
,
comments_size
)
{
var
num_comments
=
comments_size
;
// 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."
;
YAHOO
.
util
.
Dom
.
addClass
(
comment
,
'collapsed'
);
}
function
expand_comment
(
link
,
comment
)
{
link
.
innerHTML
=
"[-]"
;
link
.
title
=
"Collapse the comment"
;
YAHOO
.
util
.
Dom
.
removeClass
(
comment
,
'collapsed'
);
}
/* This way, we are sure that browsers which do not support JS
* won't display this link */
function
addCollapseLink
(
count
)
{
document
.
write
(
' <a href="#" class="bz_collapse_comment"'
+
' id="comment_link_'
+
count
+
'" onclick="toggle_comment_display(this, '
+
count
+
'); return false;" title="Collapse the comment.">[-]<
\
/a> '
);
}
template/en/default/bug/comments.html.tmpl
View file @
f7dde138
...
...
@@ -22,76 +22,8 @@
[% PROCESS bug/time.html.tmpl %]
<script type="text/javascript">
<!--
function updateCommentPrivacy(checkbox, id) {
var comment_elem = document.getElementById('comment_text_'+id).parentNode;
if (checkbox.checked) {
if (!comment_elem.className.match('bz_private')) {
comment_elem.className = comment_elem.className.concat(' bz_private');
}
}
else {
comment_elem.className =
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.";
YAHOO.util.Dom.addClass(comment, 'collapsed');
}
function expand_comment(link, comment) {
link.innerHTML = "[-]";
link.title = "Collapse the comment";
YAHOO.util.Dom.removeClass(comment, 'collapsed');
}
/* This way, we are sure that browsers which do not support JS
* won't display this link */
function addCollapseLink(count) {
document.write(' <a href="#" class="bz_collapse_comment"' +
' id="comment_link_' + count +
'" onclick="toggle_comment_display(this, ' + count +
'); return false;" title="Collapse the comment.">[-]<\/a> ');
}
//-->
</script>
<script src="js/comments.js" type="text/javascript">
</script>
[% DEFAULT start_at = 0 mode = "show" %]
[% sort_order = user.settings.comment_sort_order.value %]
...
...
@@ -142,9 +74,9 @@
<td>
[% IF mode == "edit" %]
<ul class="bz_collapse_expand_comments">
<li><a href="#" onclick="toggle_all_comments('collapse');
<li><a href="#" onclick="toggle_all_comments('collapse'
, [% comments.size %]
);
return false;">Collapse All Comments</a></li>
<li><a href="#" onclick="toggle_all_comments('expand');
<li><a href="#" onclick="toggle_all_comments('expand'
, [% comments.size %]
);
return false;">Expand All Comments</a></li>
</ul>
[% END %]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment