Commit 3e779f07 authored by Fatih Acet's avatar Fatih Acet

Fix single comment edit form issues.

parent 41a24230
...@@ -466,9 +466,7 @@ ...@@ -466,9 +466,7 @@
var $html, $note_li; var $html, $note_li;
// Convert returned HTML to a jQuery object so we can modify it further // Convert returned HTML to a jQuery object so we can modify it further
$html = $(note.html); $html = $(note.html);
this.revertNoteEditForm();
$('.note-edit-form').insertBefore('.notes-form');
gl.utils.localTimeAgo($('.js-timeago', $html)); gl.utils.localTimeAgo($('.js-timeago', $html));
$html.renderGFM(); $html.renderGFM();
$html.find('.js-task-list-container').taskList('enable'); $html.find('.js-task-list-container').taskList('enable');
...@@ -528,28 +526,21 @@ ...@@ -528,28 +526,21 @@
} }
} }
var note = $(e.target).closest('.note');
var $editForm = $('.note-edit-form'); var $editForm = $('.note-edit-form');
var $originalContentEl = note.find('.original-note-content'); var $note = $(e.target).closest('.note');
$editForm.insertAfter($note.find('.note-text'));
var $noteText = $editForm.find('.js-note-text');
var $originalContentEl = $note.find('.original-note-content');
var originalContent = $originalContentEl.text().trim(); var originalContent = $originalContentEl.text().trim();
var postUrl = $originalContentEl.data('post-url'); var postUrl = $originalContentEl.data('post-url');
var form = note.find('.note-edit-form'); $note.addClass('is-editting');
var $noteText = form.find('.js-note-text');
var noteTextVal = $noteText.val(); // Neat little trick to put the cursor at the end
note.addClass('is-editting');
$editForm.insertAfter(note.find('.note-text'));
$editForm.find('.js-note-text').val(originalContent);
$editForm.find('form').attr('action', postUrl); $editForm.find('form').attr('action', postUrl);
$editForm.addClass('current-note-edit-form');
form.addClass('current-note-edit-form'); $note.find('.js-note-attachment-delete').show(); // Show the attachment delete link
note.find('.js-note-attachment-delete').show(); // Show the attachment delete link new GLForm($editForm.find('form'));
new GLForm(form); $editForm.find('.js-note-text').focus().val(originalContent);
$noteText.focus();
// Store the original note text in a data attribute to retrieve if a user cancels edit.
form.find('form.edit-note').data('original-note', noteTextVal);
$noteText.val('').val(noteTextVal);
}; };
...@@ -564,10 +555,17 @@ ...@@ -564,10 +555,17 @@
var note = $(e.target).closest('.note'); var note = $(e.target).closest('.note');
note.find('.js-edit-warning').hide(); note.find('.js-edit-warning').hide();
note.find('.js-md-write-button').trigger('click'); note.find('.js-md-write-button').trigger('click');
$('.note-edit-form').insertBefore('.notes-form'); this.revertNoteEditForm();
return this.removeNoteEditForm(note); return this.removeNoteEditForm(note);
}; };
Notes.prototype.revertNoteEditForm = function() {
var $editForm = $('.note-edit-form');
$editForm.insertBefore('.notes-form');
$editForm.find('.js-comment-button').enable();
}
Notes.prototype.removeNoteEditForm = function(note) { Notes.prototype.removeNoteEditForm = function(note) {
var form = note.find(".current-note-edit-form"); var form = note.find(".current-note-edit-form");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment