diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-04 13:54:58 -0400 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-04 13:54:58 -0400 |
commit | 7e1c91e0d6c9fe7d8c7a392d09225aa76c254c47 (patch) | |
tree | aef75038fb99580be7f67ace90fa4ca3d304e6b3 | |
parent | 88889d164de2d0fed05ccaee8013dffaa127cd19 (diff) | |
download | gitlab-ce-7e1c91e0d6c9fe7d8c7a392d09225aa76c254c47.tar.gz |
Add confirmation when canceling creating/editing with changes
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 1881162addb..63f0738031c 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -104,19 +104,31 @@ class @Notes return if isMetaKey e $textarea = $(e.target) + + # Edit previous note when UP arrow is hit if $textarea.val() is '' and e.which is 38 myLastNote = $("li.note[data-author-id='#{gon.current_user_id}'][data-editable]:last") if myLastNote.length myLastNoteEditBtn = myLastNote.find('.js-note-edit') myLastNoteEditBtn.trigger('click', [true, myLastNote]) + + # Cancel creating diff note or editing any note when ESCAPE is hit if e.which is 27 discussionNoteForm = $textarea.closest(".js-discussion-note-form") if discussionNoteForm.length + if $textarea.val() isnt '' + return unless confirm('Are you sure you want to cancel creating this comment?') + @removeDiscussionNoteForm(discussionNoteForm) return editNote = $textarea.closest(".note") if editNote.length + originalText = $textarea.closest('form').data('original-note') + newText = $textarea.val() + if originalText isnt newText + return unless confirm('Are you sure you want to cancel editing this comment?') + @removeNoteEditForm(editNote) |