mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26:06 +01:00
Fix comment reply form behavior in the diff view (#1796)
This commit is contained in:
@@ -232,7 +232,6 @@ $(function(){
|
||||
var $this = $(this);
|
||||
var $tr = $this.closest('tr');
|
||||
var $check = $this.closest('table:not(.diff)').find('.toggle-notes');
|
||||
//var url = '';
|
||||
if (!$check.prop('checked')) {
|
||||
$check.prop('checked', true).trigger('change');
|
||||
}
|
||||
|
||||
@@ -186,11 +186,7 @@ $(function(){
|
||||
$content = $('#issueContent');
|
||||
}
|
||||
|
||||
$.get(url,
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
function(data){
|
||||
$.get(url, { dataType : 'html' }, function(data){
|
||||
$content.empty().html(data);
|
||||
});
|
||||
return false;
|
||||
@@ -198,8 +194,7 @@ $(function(){
|
||||
$('.issue-comment-box i.octicon-x').click(function(){
|
||||
if(confirm('Are you sure you want to delete this?')) {
|
||||
var id = $(this).closest('a').data('comment-id');
|
||||
$.post('@helpers.url(repository)/issue_comments/delete/' + id,
|
||||
function(data){
|
||||
$.post('@helpers.url(repository)/issue_comments/delete/' + id, function(data){
|
||||
if(data > 0) {
|
||||
$('#comment-' + id).remove();
|
||||
}
|
||||
@@ -213,22 +208,24 @@ $(function(){
|
||||
var url = '@helpers.url(repository)/commit_comments/_data/' + id;
|
||||
var $content = $('.commit-commentContent-' + id, $(this).closest('.commit-comment-box'));
|
||||
|
||||
$.get(url,
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
function(data){
|
||||
$.get(url, { dataType : 'html' }, function(data){
|
||||
$content.empty().html(data);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '.commit-comment-box i.octicon-x', function(){
|
||||
if(confirm('Are you sure you want to delete this?')) {
|
||||
var id = $(this).closest('a').data('comment-id');
|
||||
$.post('@helpers.url(repository)/commit_comments/delete/' + id,
|
||||
function(data){
|
||||
if(data > 0) {
|
||||
$('.commit-comment-' + id).closest('.not-diff').remove();
|
||||
var comment = $('.commit-comment-' + id).closest('.not-diff');
|
||||
if(comment.prev('.not-diff').length == 0){
|
||||
comment.next('.not-diff').find('.reply-comment').remove();
|
||||
}
|
||||
comment.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -260,10 +257,7 @@ $(function(){
|
||||
var $commentContent = $(ev.target).parents('div[class*=commit-commentContent-]'),
|
||||
commentId = $commentContent.attr('class').match(/commit-commentContent-.+/)[0].replace(/commit-commentContent-/, ''),
|
||||
checkboxes = $commentContent.find(':checkbox');
|
||||
$.get('@helpers.url(repository)/commit_comments/_data/' + commentId,
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
$.get('@helpers.url(repository)/commit_comments/_data/' + commentId, { dataType : 'html' },
|
||||
function(responseContent){
|
||||
$.ajax({
|
||||
url: '@helpers.url(repository)/commit_comments/edit/' + commentId,
|
||||
@@ -283,10 +277,7 @@ $(function(){
|
||||
@if(issue.isDefined){
|
||||
$('#issueContent').on('click', ':checkbox', function(ev){
|
||||
var checkboxes = $('#issueContent :checkbox');
|
||||
$.get('@helpers.url(repository)/issues/_data/@issue.get.issueId',
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
$.get('@helpers.url(repository)/issues/_data/@issue.get.issueId', { dataType : 'html' },
|
||||
function(responseContent){
|
||||
$.ajax({
|
||||
url: '@helpers.url(repository)/issues/edit/@issue.get.issueId',
|
||||
@@ -304,10 +295,7 @@ $(function(){
|
||||
var $commentContent = $(ev.target).parents('div[id^=commentContent-]'),
|
||||
commentId = $commentContent.attr('id').replace(/commentContent-/, ''),
|
||||
checkboxes = $commentContent.find(':checkbox');
|
||||
$.get('@helpers.url(repository)/issue_comments/_data/' + commentId,
|
||||
{
|
||||
dataType : 'html'
|
||||
},
|
||||
$.get('@helpers.url(repository)/issue_comments/_data/' + commentId, { dataType : 'html' },
|
||||
function(responseContent){
|
||||
$.ajax({
|
||||
url: '@helpers.url(repository)/issue_comments/edit/' + commentId,
|
||||
|
||||
@@ -71,8 +71,19 @@
|
||||
|
||||
// Show reply comment form
|
||||
var replyComment = $tr.prev().find('.reply-comment').closest('.not-diff').show();
|
||||
replyComment.remove();
|
||||
$tr.after(replyComment);
|
||||
if(replyComment.length != 0){
|
||||
replyComment.remove();
|
||||
$tr.after(replyComment);
|
||||
} else {
|
||||
var $v = $('<div class="commit-comment-box reply-comment-box">')
|
||||
.append($('<input type="text" class="form-control reply-comment" placeholder="Reply...">')
|
||||
.data('filename', '@fileName')
|
||||
.data('newline', @newLineNumber.getOrElse("undefined"))
|
||||
.data('oldline', @oldLineNumber.getOrElse("undefined")));
|
||||
var tmp = getInlineContainer();
|
||||
tmp.children('td:last').html($v)
|
||||
$tr.after(tmp);
|
||||
}
|
||||
|
||||
$('#comment-list').append(data);
|
||||
if (typeof $('#show-notes')[0] !== 'undefined' && !$('#show-notes')[0].checked) {
|
||||
@@ -82,6 +93,19 @@
|
||||
$('.btn-inline-comment').removeAttr('disabled');
|
||||
$('#error-content', $form).html($.parseJSON(req.responseText).content);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
function getInlineContainer() {
|
||||
console.log(window.viewType);
|
||||
if (window.viewType == 0) {
|
||||
if(@newLineNumber.isDefined){
|
||||
return $('<tr class="not-diff"><td colspan="2"></td><td colspan="2" class="comment-box-container"></td></tr>');
|
||||
}
|
||||
if(@oldLineNumber.isDefined){
|
||||
return $('<tr class="not-diff"><td colspan="2" class="comment-box-container"></td><td colspan="2"></td></tr>');
|
||||
}
|
||||
}
|
||||
return $('<tr class="not-diff"><td colspan="3" class="comment-box-container"></td></tr>');
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user