From 15c682fcb01807b8c7c857aba213f2f14904083d Mon Sep 17 00:00:00 2001
From: Robert Schilling <rschilling@student.tugraz.at>
Date: Mon, 4 Aug 2014 20:29:17 +0200
Subject: [PATCH] Disable 'Save changes' button if input is empty, fixes #6351

---
 app/assets/javascripts/notes.js.coffee   | 4 +++-
 app/views/projects/notes/_note.html.haml | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 607b109dc0b7..83b1bae0ea11 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -321,7 +321,9 @@ class Notes
     GitLab.GfmAutoComplete.setup()
     form = note.find(".note-edit-form")
     form.show()
-    form.find("textarea").focus()
+    textarea = form.find("textarea")
+    textarea.focus()
+    disableButtonIfEmptyField textarea, form.find(".js-comment-button")
 
   ###
   Called in response to clicking the edit note link
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index 2fd8cb6d489d..5e84aed0cc40 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -38,10 +38,10 @@
         = f.text_area :note, class: 'note_text js-note-text js-gfm-input turn-on'
 
         .form-actions.clearfix
-          = f.submit 'Save changes', class: "btn btn-primary btn-save"
+          = f.submit 'Save changes', class: "btn btn-primary btn-save js-comment-button"
 
           .note-form-option
-            %a.choose-btn.btn.btn-small.js-choose-note-attachment-button
+            %a.choose-btn.btn.js-choose-note-attachment-button
               %i.icon-paper-clip
               %span Choose File ...
             &nbsp;
-- 
GitLab