Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
09c85ccb
Commit
09c85ccb
authored
Jul 05, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use switch/when statement
parent
0deec938
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
+24
-21
app/assets/javascripts/notes.js.coffee
app/assets/javascripts/notes.js.coffee
+24
-21
No files found.
app/assets/javascripts/notes.js.coffee
View file @
09c85ccb
...
@@ -106,30 +106,33 @@ class @Notes
...
@@ -106,30 +106,33 @@ class @Notes
$textarea
=
$
(
e
.
target
)
$textarea
=
$
(
e
.
target
)
# Edit previous note when UP arrow is hit
# Edit previous note when UP arrow is hit
if
$textarea
.
val
()
is
''
and
e
.
which
is
38
switch
e
.
which
myLastNote
=
$
(
"li.note[data-author-id='
#{
gon
.
current_user_id
}
'][data-editable]:last"
)
when
38
if
myLastNote
.
length
return
unless
$textarea
.
val
()
is
''
myLastNoteEditBtn
=
myLastNote
.
find
(
'.js-note-edit'
)
myLastNoteEditBtn
.
trigger
(
'click'
,
[
true
,
myLastNote
])
# Cancel creating diff note or editing any note when ESCAPE is hit
myLastNote
=
$
(
"li.note[data-author-id='
#{
gon
.
current_user_id
}
'][data-editable]:last"
)
if
e
.
which
is
27
if
myLastNote
.
length
discussionNoteForm
=
$textarea
.
closest
(
'.js-discussion-note-form'
)
myLastNoteEditBtn
=
myLastNote
.
find
(
'.js-note-edit'
)
if
discussionNoteForm
.
length
myLastNoteEditBtn
.
trigger
(
'click'
,
[
true
,
myLastNote
])
if
$textarea
.
val
()
isnt
''
return
unless
confirm
(
'Are you sure you want to cancel creating this comment?'
)
@
removeDiscussionNoteForm
(
discussionNoteForm
)
# Cancel creating diff note or editing any note when ESCAPE is hit
return
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"
)
@
removeDiscussionNoteForm
(
discussionNoteForm
)
if
editNote
.
length
return
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
)
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
)
->
isMetaKey
=
(
e
)
->
...
@@ -427,7 +430,7 @@ class @Notes
...
@@ -427,7 +430,7 @@ class @Notes
###
###
cancelEdit
:
(
e
)
=>
cancelEdit
:
(
e
)
=>
e
.
preventDefault
()
e
.
preventDefault
()
note
=
$
(
e
.
target
).
closest
(
".note"
)
note
=
$
(
e
.
target
).
closest
(
'.note'
)
@
removeNoteEditForm
(
note
)
@
removeNoteEditForm
(
note
)
removeNoteEditForm
:
(
note
)
->
removeNoteEditForm
:
(
note
)
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment