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
be26c119
Commit
be26c119
authored
Dec 22, 2014
by
David Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1093924: Move replyToMarkdownComment() and replyToComment() out of templates
r=LpSolit,a=glob
parent
0bc389f1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
73 deletions
+73
-73
comments.js
js/comments.js
+63
-0
comments.html.tmpl
template/en/default/bug/comments.html.tmpl
+9
-72
show-header.html.tmpl
template/en/default/bug/show-header.html.tmpl
+1
-1
No files found.
js/comments.js
View file @
be26c119
...
@@ -6,6 +6,69 @@
...
@@ -6,6 +6,69 @@
* defined by the Mozilla Public License, v. 2.0.
* defined by the Mozilla Public License, v. 2.0.
*/
*/
/* Adds the reply text to the 'comment' textarea */
function
replyToComment
(
id
,
real_id
,
replyto_header
,
text
)
{
var
replytext
=
""
;
if
(
replyCommentConfig
.
quote_replies
==
'quoted_reply'
)
{
/* pre id="comment_name_N" */
if
(
text
==
null
)
{
var
text_elem
=
document
.
getElementById
(
'comment_text_'
+
id
);
text
=
getText
(
text_elem
);
}
replytext
=
replyto_header
+
"
\
n"
+
wrapReplyText
(
text
);
}
else
if
(
replyCommentConfig
.
quote_replies
==
'simple_reply'
)
{
replytext
=
replyto_header
+
"
\
n"
;
}
if
(
replyCommentConfig
.
is_insider
)
{
if
(
document
.
getElementById
(
'isprivate_'
+
real_id
).
checked
)
{
document
.
getElementById
(
'newcommentprivacy'
).
checked
=
'checked'
;
updateCommentTagControl
(
document
.
getElementById
(
'newcommentprivacy'
),
'comment'
);
}
}
/* <textarea id="comment"> */
var
textarea
=
document
.
getElementById
(
'comment'
);
if
(
textarea
.
value
!=
replytext
)
{
textarea
.
value
+=
replytext
;
}
textarea
.
focus
();
}
function
replyToMarkdownComment
(
id
,
real_id
,
replyto_header
)
{
var
textarea
=
document
.
getElementById
(
'comment'
);
var
comment
=
textarea
.
value
;
textarea
.
value
+=
replyCommentConfig
.
markdown_fetching_comment
;
YAHOO
.
util
.
Connect
.
setDefaultPostHeader
(
'application/json'
,
true
);
YAHOO
.
util
.
Connect
.
asyncRequest
(
'POST'
,
'jsonrpc.cgi'
,
{
success
:
function
(
res
)
{
var
data
=
YAHOO
.
lang
.
JSON
.
parse
(
res
.
responseText
);
if
(
!
data
.
error
)
{
textarea
.
value
=
comment
;
var
text
=
data
.
result
.
comments
[
real_id
].
text
;
replyToComment
(
id
,
real_id
,
replyto_header
,
text
);
}
else
{
replyToComment
(
id
,
real_id
,
replyto_header
);
}
},
failure
:
function
(
res
)
{
/* On failure, quote the comment as plain-text */
replyToComment
(
id
,
real_id
,
replyto_header
);
}
},
YAHOO
.
lang
.
JSON
.
stringify
({
version
:
"1.1"
,
method
:
"Bug.comments"
,
params
:
{
Bugzilla_api_token
:
BUGZILLA
.
api_token
,
comment_ids
:
[
real_id
],
}
})
);
}
function
updateCommentPrivacy
(
checkbox
,
id
)
{
function
updateCommentPrivacy
(
checkbox
,
id
)
{
var
comment_elem
=
document
.
getElementById
(
'comment_text_'
+
id
).
parentNode
;
var
comment_elem
=
document
.
getElementById
(
'comment_text_'
+
id
).
parentNode
;
if
(
checkbox
.
checked
)
{
if
(
checkbox
.
checked
)
{
...
...
template/en/default/bug/comments.html.tmpl
View file @
be26c119
...
@@ -8,76 +8,12 @@
...
@@ -8,76 +8,12 @@
[% PROCESS bug/time.html.tmpl %]
[% PROCESS bug/time.html.tmpl %]
<script src="[% 'js/comments.js' FILTER mtime %]" type="text/javascript">
</script>
<script type="text/javascript">
<script type="text/javascript">
<!--
var replyCommentConfig = {
/* Adds the reply text to the 'comment' textarea */
quote_replies : "[% user.settings.quote_replies.value FILTER js %]",
function replyToComment(id, real_id, name, text) {
is_insider : [% user.is_insider ? 1 : 0 %],
var prefix = "(In reply to " + name + " from comment #" + id + ")\n";
markdown_fetching_comment : "Fetching comment..."
var replytext = "";
};
[% IF user.settings.quote_replies.value == 'quoted_reply' %]
/* pre id="comment_name_N" */
if (text == null) {
var text_elem = document.getElementById('comment_text_'+id);
text = getText(text_elem);
}
replytext = prefix + wrapReplyText(text);
[% ELSIF user.settings.quote_replies.value == 'simple_reply' %]
replytext = prefix;
[% END %]
[% IF user.is_insider %]
if (document.getElementById('isprivate_' + real_id).checked) {
document.getElementById('newcommentprivacy').checked = 'checked';
updateCommentTagControl(document.getElementById('newcommentprivacy'), 'comment');
}
[% END %]
/* <textarea id="comment"> */
var textarea = document.getElementById('comment');
if (textarea.value != replytext) {
textarea.value += replytext;
}
textarea.focus();
}
function replyToMarkdownComment(id, real_id, name) {
var textarea = document.getElementById('comment');
var comment = textarea.value;
textarea.value += "Fetching comment...";
YAHOO.util.Connect.setDefaultPostHeader('application/json', true);
YAHOO.util.Connect.asyncRequest('POST', 'jsonrpc.cgi',
{
success: function(res) {
var data = YAHOO.lang.JSON.parse(res.responseText);
if (!data.error) {
textarea.value = comment;
var text = data.result.comments[real_id].text;
replyToComment(id, real_id, name, text);
} else {
replyToComment(id, real_id, name, null);
}
},
failure: function(res) {
/* On failure, quote the comment as plain-text */
replyToComment(id, real_id, name, null);
}
},
YAHOO.lang.JSON.stringify({
version: "1.1",
method: "Bug.comments",
params: {
Bugzilla_api_token: BUGZILLA.api_token,
comment_ids: [real_id],
}
})
);
}
//-->
</script>
</script>
[% DEFAULT mode = "show" %]
[% DEFAULT mode = "show" %]
...
@@ -160,14 +96,15 @@
...
@@ -160,14 +96,15 @@
[<a href="#"
[<a href="#"
onclick="YAHOO.bugzilla.commentTagging.toggle([% comment.id %], [% comment.count %]);return false">tag</a>]
onclick="YAHOO.bugzilla.commentTagging.toggle([% comment.id %], [% comment.count %]);return false">tag</a>]
[% END %]
[% END %]
[% replyto_author = comment.author.name || comment.author.nick FILTER html %]
[% replyto_header = "(In reply to $replyto_author from comment #$comment.count)" %]
[<a class="bz_reply_link" href="#add_comment"
[<a class="bz_reply_link" href="#add_comment"
[% IF user.settings.quote_replies.value != 'off' %]
[% IF user.settings.quote_replies.value != 'off' %]
onclick="
onclick="
[% IF feature_enabled('jsonrpc') && comment.is_markdown %]
[% IF feature_enabled('jsonrpc') && comment.is_markdown %]
replyToMarkdownComment('[% comment.count %]', '[% comment.id %]', '[%
comment.author.name || comment.author.nick FILTER html
FILTER js %]'); return false;"
replyToMarkdownComment('[% comment.count %]', '[% comment.id %]', '[%
replyto_header
FILTER js %]'); return false;"
[% ELSE %]
[% ELSE %]
replyToComment('[% comment.count %]', '[% comment.id %]', '[% comment.author.name || comment.author.nick FILTER html FILTER js %]', null); return false;"
replyToComment('[% comment.count %]', '[% comment.id %]', '[% replyto_header FILTER js %]', null); return false;"
[% END %]
[% END %]
[% END %]
[% END %]
>reply</a>]
>reply</a>]
...
...
template/en/default/bug/show-header.html.tmpl
View file @
be26c119
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
[% title = title _ filtered_desc %]
[% title = title _ filtered_desc %]
[% yui = ['autocomplete', 'calendar'] %]
[% yui = ['autocomplete', 'calendar'] %]
[% yui.push('container') IF user.can_tag_comments %]
[% yui.push('container') IF user.can_tag_comments %]
[% javascript_urls = [ "js/util.js", "js/field.js" ] %]
[% javascript_urls = [ "js/util.js", "js/field.js"
, "js/comments.js"
] %]
[% javascript_urls.push("js/bug.js") IF user.id %]
[% javascript_urls.push("js/bug.js") IF user.id %]
[% javascript_urls.push('js/comment-tagging.js')
[% javascript_urls.push('js/comment-tagging.js')
IF user.id && Param('comment_taggers_group') %]
IF user.id && Param('comment_taggers_group') %]
...
...
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