summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-12 18:47:58 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-12 18:47:58 +0200
commit9c7d821cf752a98f8c7a40056816f6629ca1f734 (patch)
tree9bea6ddd06fb5c0bd649fa3d045db5ff42567f27
parent8fc9b5c0e26b05f88396cc896a2079b88325c4ce (diff)
downloadgitlab-ce-9c7d821cf752a98f8c7a40056816f6629ca1f734.tar.gz
Show selected attachment in comment form
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/assets/javascripts/notes.js.coffee15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 6501cf38a89..69e9e67f712 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -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