Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-11-14 23:12:51 +0300
committerFatih Acet <acetfatih@gmail.com>2017-01-04 23:37:54 +0300
commit3e779f07b29aafcb8a143134723415fa8304ba5e (patch)
tree0197617768f7fff550d1ca8515a3ebc64852c31b /app/assets/javascripts/notes.js
parent41a24230303ca558b34335541603bd5095b8d782 (diff)
Fix single comment edit form issues.
Diffstat (limited to 'app/assets/javascripts/notes.js')
-rw-r--r--app/assets/javascripts/notes.js42
1 files changed, 20 insertions, 22 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index 1f30368472d..1087fbe9c17 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -466,9 +466,7 @@
var $html, $note_li;
// Convert returned HTML to a jQuery object so we can modify it further
$html = $(note.html);
-
- $('.note-edit-form').insertBefore('.notes-form');
-
+ this.revertNoteEditForm();
gl.utils.localTimeAgo($('.js-timeago', $html));
$html.renderGFM();
$html.find('.js-task-list-container').taskList('enable');
@@ -528,28 +526,21 @@
}
}
- var note = $(e.target).closest('.note');
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 postUrl = $originalContentEl.data('post-url');
- var form = note.find('.note-edit-form');
- 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);
+ $note.addClass('is-editting');
$editForm.find('form').attr('action', postUrl);
-
- form.addClass('current-note-edit-form');
- note.find('.js-note-attachment-delete').show(); // Show the attachment delete link
- new GLForm(form);
-
- $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);
+ $editForm.addClass('current-note-edit-form');
+ $note.find('.js-note-attachment-delete').show(); // Show the attachment delete link
+ new GLForm($editForm.find('form'));
+ $editForm.find('.js-note-text').focus().val(originalContent);
};
@@ -564,10 +555,17 @@
var note = $(e.target).closest('.note');
note.find('.js-edit-warning').hide();
note.find('.js-md-write-button').trigger('click');
- $('.note-edit-form').insertBefore('.notes-form');
+ this.revertNoteEditForm();
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) {
var form = note.find(".current-note-edit-form");