diff options
author | Koosha KM <koosha.khajeh@gmail.com> | 2014-10-14 22:42:46 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-10-14 22:42:46 +0200 |
commit | 42d5e45576b519f19879d2b0eba529932da81644 (patch) | |
tree | fc6a2aafc38c1d2aa6ebf0ab1453827893107886 /template/en | |
parent | 847191ac9f29dee98088203d2ac135b9d820b507 (diff) | |
download | bugzilla-42d5e45576b519f19879d2b0eba529932da81644.tar.gz bugzilla-42d5e45576b519f19879d2b0eba529932da81644.tar.xz |
Bug 1059723: Reply button should become AJAX-based
r=dkl,a=sgreen
Diffstat (limited to 'template/en')
-rw-r--r-- | template/en/default/bug/comments.html.tmpl | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl index 8f5742fee..617f49471 100644 --- a/template/en/default/bug/comments.html.tmpl +++ b/template/en/default/bug/comments.html.tmpl @@ -14,13 +14,16 @@ <script type="text/javascript"> <!-- /* Adds the reply text to the 'comment' textarea */ - function replyToComment(id, real_id, name) { + function replyToComment(id, real_id, name, text) { var prefix = "(In reply to " + name + " from comment #" + id + ")\n"; var replytext = ""; [% IF user.settings.quote_replies.value == 'quoted_reply' %] /* pre id="comment_name_N" */ - var text_elem = document.getElementById('comment_text_'+id); - var text = getText(text_elem); + + 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; @@ -41,6 +44,39 @@ 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> @@ -126,7 +162,13 @@ [% END %] [<a class="bz_reply_link" href="#add_comment" [% IF user.settings.quote_replies.value != 'off' %] - onclick="replyToComment('[% comment.count %]', '[% comment.id %]', '[% comment.author.name || comment.author.nick FILTER html FILTER js %]'); return false;" + onclick=" + [% IF feature_enabled('jsonrpc') && comment.is_markdown %] + replyToMarkdownComment('[% comment.count %]', '[% comment.id %]', '[% comment.author.name || comment.author.nick FILTER html FILTER js %]'); return false;" + [% ELSE %] + replyToComment('[% comment.count %]', '[% comment.id %]', '[% comment.author.name || comment.author.nick FILTER html FILTER js %]', null); return false;" + + [% END %] [% END %] >reply</a>] [% END %] |