2012-09-18 19:42:22 +01:00
|
|
|
$(document).ready(function() {
|
2012-10-04 19:40:12 +01:00
|
|
|
var new_comment = $('#open-comment.comment.hidden.new_line_comment');
|
|
|
|
|
|
|
|
$(document).on('click', '.buttons a.edit_comment', function() {
|
2012-09-18 19:42:22 +01:00
|
|
|
$(this).parent().parent().parent().hide();
|
|
|
|
$('#open-comment'+'.comment.'+$(this).attr('id')).show();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-10-04 19:40:12 +01:00
|
|
|
$(document).on('click', '.cancel_edit_comment.button', function() {
|
2012-09-18 19:42:22 +01:00
|
|
|
$(this).parent().parent().parent().hide();
|
|
|
|
$('.buttons a.edit_comment#'+$(this).attr('id')).parent().parent().parent().show();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-10-04 19:40:12 +01:00
|
|
|
$(document).on('submit', 'form.edit_comment', function() {
|
2012-09-18 19:42:22 +01:00
|
|
|
var form = $(this);
|
2012-09-24 18:34:14 +01:00
|
|
|
form.parent().find('.flash').remove();
|
2012-09-18 19:42:22 +01:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: form.attr("action"),
|
|
|
|
data: form.serialize(),
|
|
|
|
success: function(data){
|
|
|
|
var cancel_button = form.find('.cancel_edit_comment.button');
|
|
|
|
cancel_button.click();
|
2012-09-21 11:31:55 +01:00
|
|
|
$('.buttons a.edit_comment#'+cancel_button.attr('id')).parent().parent().find('.cm-s-default.md_and_cm').html(data).find('code').each(function (code) { CodeMirrorRun(this); })
|
2012-09-18 19:42:22 +01:00
|
|
|
},
|
|
|
|
error: function(data){
|
2012-09-24 18:34:14 +01:00
|
|
|
form.before(data.responseText);
|
2012-09-18 19:42:22 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-10-04 19:40:12 +01:00
|
|
|
$('.add_line-comment').on('click', function() {
|
|
|
|
function ProcessData(data) {
|
|
|
|
var str = "<tr><td class='line_numbers line_comments' colspan='2'></td>"+"<td>"+data+"</td></tr>";
|
|
|
|
par.after(str);
|
|
|
|
line.addClass('new_comment_exists');
|
|
|
|
par.parent().find('#md_tabs.nav.nav-tabs').each(function(i) { $(this).find('a:first').tab('show') });
|
|
|
|
}
|
|
|
|
var line = $(this);
|
|
|
|
var par = line.parent().parent();
|
|
|
|
if(line.hasClass('new_comment_exists')) {
|
|
|
|
$('#open-comment.new_line_comment').parent().parent().show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#open-comment.new_line_comment').parent().parent().remove();
|
|
|
|
$.get(line.attr('href'), null, ProcessData);
|
|
|
|
}
|
|
|
|
$('#new_line_edit_input').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2012-09-18 19:42:22 +01:00
|
|
|
|
2012-10-04 19:40:12 +01:00
|
|
|
$(document).on('click', '.cancel_inline_comment.button', function() {
|
|
|
|
$(this).parent().parent().parent().parent().parent().hide();
|
|
|
|
return false;
|
|
|
|
});
|
2012-09-18 19:42:22 +01:00
|
|
|
});
|
2012-10-04 19:40:12 +01:00
|
|
|
|