Commit e5adca1b813bf1646a08bbc239acc75a844c366d
1 parent
b9b63fc3
Exists in
master
and in
4 other branches
Preview as button. Disable note submit unless content
Showing
2 changed files
with
16 additions
and
4 deletions
Show diff stats
app/assets/javascripts/note.js
... | ... | @@ -24,6 +24,16 @@ init: |
24 | 24 | $('.delete-note').live('ajax:success', function() { |
25 | 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 | 37 | $("#new_note").live("ajax:before", function(){ |
28 | 38 | $(".submit_note").attr("disabled", "disabled"); |
29 | 39 | }) |
... | ... | @@ -35,6 +45,7 @@ init: |
35 | 45 | $("#note_note").live("focus", function(){ |
36 | 46 | $(this).css("height", "80px"); |
37 | 47 | $('.note_advanced_opts').show(); |
48 | + $(this).closest("form").find(".submit_note").attr("disabled", "disabled"); | |
38 | 49 | }); |
39 | 50 | |
40 | 51 | $("#note_attachment").change(function(e){ | ... | ... |
app/views/notes/_form.html.haml
... | ... | @@ -10,12 +10,13 @@ |
10 | 10 | = f.text_area :note, size: 255 |
11 | 11 | #preview-note.well.hide |
12 | 12 | .hint |
13 | - = link_to 'Preview', preview_project_notes_path(@project), id: 'preview-link' | |
14 | 13 | .right Comments are parsed with #{link_to "Gitlab Flavored Markdown", help_markdown_path, target: '_blank'}. |
14 | + .clearfix | |
15 | 15 | |
16 | 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 | 20 | .span4.notify_opts |
20 | 21 | %h6.left Notify via email: |
21 | 22 | = label_tag :notify do |
... | ... | @@ -26,7 +27,7 @@ |
26 | 27 | = label_tag :notify_author do |
27 | 28 | = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit" |
28 | 29 | %span Commit author |
29 | - .span6.attachments | |
30 | + .span5.attachments | |
30 | 31 | %h6.left Attachment: |
31 | 32 | %span.file_name File name... |
32 | 33 | ... | ... |