Commit d412abd10886c76968278d655ac3a0c01fef0329

Authored by Valeriy Sizov
2 parents b339c747 98e938bd

Merge pull request #2000 from riyad/fix-editor

Fix editor
app/assets/stylesheets/sections/editor.scss
1 .file-editor { 1 .file-editor {
2 #editor{ 2 #editor{
  3 + border: none;
  4 + border-radius: 0;
3 height: 500px; 5 height: 500px;
4 - width: 100%; 6 + margin: 0;
  7 + padding: 0;
5 position: relative; 8 position: relative;
  9 + width: 100%;
6 } 10 }
7 - .editor-commit-comment {  
8 - padding-top:20px; 11 +
  12 + .cancel-btn {
  13 + color: #B94A48;
  14 + &:hover {
  15 + color: #B94A48;
  16 + }
  17 + }
  18 + .commit-button-annotation {
  19 + @extend .alert;
  20 + @extend .alert-info;
  21 + display: inline-block;
  22 + margin: 0;
  23 + padding: 2px;
  24 +
  25 + > * {
  26 + float: left;
  27 + }
  28 +
  29 + .commit-btn {
  30 + @extend .save-btn;
  31 + }
  32 + .message {
  33 + display: inline-block;
  34 + margin: 5px 8px 0 8px;
  35 + }
  36 + }
  37 + .commit_message-group {
  38 + margin-top: 20px;
  39 +
  40 + label {
  41 + font-size: 16px;
  42 + line-height: 20px;
  43 + }
9 textarea { 44 textarea {
10 - width: 50%;  
11 - margin-left: 20px; 45 + @extend .span8;
12 } 46 }
13 } 47 }
14 } 48 }
app/views/tree/edit.html.haml
1 .file-editor 1 .file-editor
2 - = form_tag(project_tree_path(@project, @id), :method => :put) do 2 + = form_tag(project_tree_path(@project, @id), method: :put, class: "form-horizontal") do
3 .file_holder 3 .file_holder
4 .file_title 4 .file_title
5 %i.icon-file 5 %i.icon-file
6 %span.file_name 6 %span.file_name
7 - = "#{@tree.path} (#{@ref})" 7 + = @tree.path
  8 + %small
  9 + on
  10 + %strong= @ref
  11 + %span.options
  12 + .btn-group.tree-btn-group
  13 + = link_to "Cancel", project_tree_path(@project, @id), class: "btn very_small cancel-btn", confirm: "Are you sure?"
8 .file_content.code 14 .file_content.code
9 - #editor= @tree.data 15 + %pre#editor= @tree.data
10 16
11 - .editor-commit-comment  
12 - = label_tag 'commit_message' do  
13 - %p.slead Commit message  
14 - = text_area_tag 'commit_message', '', :required => true 17 + .control-group.commit_message-group
  18 + = label_tag 'commit_message', class: "control-label" do
  19 + Commit message
  20 + .controls
  21 + = text_area_tag 'commit_message', '', placeholder: "Update #{@tree.name}", required: true, rows: 3
15 .form-actions 22 .form-actions
16 = hidden_field_tag 'last_commit', @last_commit 23 = hidden_field_tag 'last_commit', @last_commit
17 - = hidden_field_tag 'content', '', :id => :file_content  
18 - = button_tag "Commit", class: 'btn save-btn' 24 + = hidden_field_tag 'content', '', id: :file_content
  25 + .commit-button-annotation
  26 + = button_tag "Commit", class: 'btn commit-btn js-commit-button'
  27 + .message
  28 + to branch
  29 + %strong= @ref
19 = link_to "Cancel", project_tree_path(@project, @id), class: "btn cancel-btn", confirm: "Are you sure?" 30 = link_to "Cancel", project_tree_path(@project, @id), class: "btn cancel-btn", confirm: "Are you sure?"
20 31
21 :javascript 32 :javascript
  33 + var ace_mode = "#{@tree.language.try(:ace_mode)}";
22 var editor = ace.edit("editor"); 34 var editor = ace.edit("editor");
23 - editor.getSession().setMode("ace/mode/javascript"); 35 + if (ace_mode) {
  36 + editor.getSession().setMode('ace/mode/' + ace_mode);
  37 + }
24 38
25 - $(".save-btn").click(function(){ 39 + disableButtonIfEmptyField("#commit_message", ".js-commit-button");
  40 +
  41 + $(".js-commit-button").click(function(){
26 $("#file_content").val(editor.getValue()); 42 $("#file_content").val(editor.getValue());
27 - $(".form_editor form").submit(); 43 + $(".file-editor form").submit();
28 }); 44 });