Commit e5adca1b813bf1646a08bbc239acc75a844c366d

Authored by randx
1 parent b9b63fc3

Preview as button. Disable note submit unless content

app/assets/javascripts/note.js
@@ -24,6 +24,16 @@ init: @@ -24,6 +24,16 @@ init:
24 $('.delete-note').live('ajax:success', function() { 24 $('.delete-note').live('ajax:success', function() {
25 $(this).closest('li').fadeOut(); }); 25 $(this).closest('li').fadeOut(); });
26 26
  27 + $('#note_note').on('keyup', function(){
  28 + var field = $(this);
  29 + var closest_submit = field.closest("form").find(".submit_note");
  30 + if(field.val() == "") {
  31 + closest_submit.attr("disabled", "disabled").addClass("disabled");
  32 + } else {
  33 + closest_submit.removeAttr("disabled").removeClass("disabled");
  34 + }
  35 + })
  36 +
27 $("#new_note").live("ajax:before", function(){ 37 $("#new_note").live("ajax:before", function(){
28 $(".submit_note").attr("disabled", "disabled"); 38 $(".submit_note").attr("disabled", "disabled");
29 }) 39 })
@@ -35,6 +45,7 @@ init: @@ -35,6 +45,7 @@ init:
35 $("#note_note").live("focus", function(){ 45 $("#note_note").live("focus", function(){
36 $(this).css("height", "80px"); 46 $(this).css("height", "80px");
37 $('.note_advanced_opts').show(); 47 $('.note_advanced_opts').show();
  48 + $(this).closest("form").find(".submit_note").attr("disabled", "disabled");
38 }); 49 });
39 50
40 $("#note_attachment").change(function(e){ 51 $("#note_attachment").change(function(e){
app/views/notes/_form.html.haml
@@ -10,12 +10,13 @@ @@ -10,12 +10,13 @@
10 = f.text_area :note, size: 255 10 = f.text_area :note, size: 255
11 #preview-note.well.hide 11 #preview-note.well.hide
12 .hint 12 .hint
13 - = link_to 'Preview', preview_project_notes_path(@project), id: 'preview-link'  
14 .right Comments are parsed with #{link_to "Gitlab Flavored Markdown", help_markdown_path, target: '_blank'}. 13 .right Comments are parsed with #{link_to "Gitlab Flavored Markdown", help_markdown_path, target: '_blank'}.
  14 + .clearfix
15 15
16 .row.note_advanced_opts.hide 16 .row.note_advanced_opts.hide
17 - .span2  
18 - = f.submit 'Add Comment', class: "btn primary submit_note", id: "submit_note" 17 + .span3
  18 + = f.submit 'Add Comment', class: "btn primary submit_note grouped", id: "submit_note"
  19 + = link_to 'Preview', preview_project_notes_path(@project), class: 'btn grouped', id: 'preview-link'
19 .span4.notify_opts 20 .span4.notify_opts
20 %h6.left Notify via email: 21 %h6.left Notify via email:
21 = label_tag :notify do 22 = label_tag :notify do
@@ -26,7 +27,7 @@ @@ -26,7 +27,7 @@
26 = label_tag :notify_author do 27 = label_tag :notify_author do
27 = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit" 28 = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
28 %span Commit author 29 %span Commit author
29 - .span6.attachments 30 + .span5.attachments
30 %h6.left Attachment: 31 %h6.left Attachment:
31 %span.file_name File name... 32 %span.file_name File name...
32 33