Show selected attachment in comment form

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-01-12 18:47:58 +02:00
parent 8fc9b5c0e2
commit 9c7d821cf7
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
1 changed files with 15 additions and 0 deletions

View File

@ -37,6 +37,9 @@ class Notes
# attachment button
$(document).on "click", ".js-choose-note-attachment-button", @chooseNoteAttachment
# update the file name when an attachment is selected
$(document).on "change", ".js-note-attachment-input", @updateFormAttachment
# reply to diff/discussion notes
$(document).on "click", ".js-discussion-reply-button", @replyToDiscussionNote
@ -429,4 +432,16 @@ class Notes
updateVotes: ->
(new NotesVotes).updateVotes()
###
Called after an attachment file has been selected.
Updates the file name for the selected attachment.
###
updateFormAttachment: ->
form = $(this).closest("form")
# get only the basename
filename = $(this).val().replace(/^.*[\\\/]/, "")
form.find(".js-attachment-filename").text filename
@Notes = Notes