summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/notes.js.coffee45
1 files changed, 24 insertions, 21 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index d0aca50b514..7c1d943667b 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -106,30 +106,33 @@ class @Notes
$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])
+ switch e.which
+ when 38
+ return unless $textarea.val() is ''
- # 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?')
+ 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])
- @removeDiscussionNoteForm(discussionNoteForm)
- return
+ # Cancel creating diff note or editing any note when ESCAPE is hit
+ when 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?')
- 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?')
+ @removeDiscussionNoteForm(discussionNoteForm)
+ return
- @removeNoteEditForm(editNote)
+ 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)
isMetaKey = (e) ->
@@ -427,7 +430,7 @@ class @Notes
###
cancelEdit: (e) =>
e.preventDefault()
- note = $(e.target).closest(".note")
+ note = $(e.target).closest('.note')
@removeNoteEditForm(note)
removeNoteEditForm: (note) ->