show.html.haml 1.5 KB
Newer Older
V
Valeriy Sizov 已提交
1
.file-editor
2
  = form_tag(project_edit_tree_path(@project, @id), method: :put, class: "form-horizontal") do
D
Dmitriy Zaporozhets 已提交
3 4 5
    .file_holder
      .file_title
        %i.icon-file
6
        %span.file_name
7
          = @path
R
Riyad Preukschas 已提交
8 9 10 11 12
          %small
            on
            %strong= @ref
        %span.options
          .btn-group.tree-btn-group
13
            = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: "Are you sure?"
D
Dmitriy Zaporozhets 已提交
14
      .file_content.code
15
        %pre#editor= @blob.data
D
Dmitriy Zaporozhets 已提交
16

R
Riyad Preukschas 已提交
17 18 19 20
    .control-group.commit_message-group
      = label_tag 'commit_message', class: "control-label" do
        Commit message
      .controls
21
        = text_area_tag 'commit_message', '', placeholder: "Update #{@blob.name}", required: true, rows: 3
D
Dmitriy Zaporozhets 已提交
22
    .form-actions
V
Valeriy Sizov 已提交
23
      = hidden_field_tag 'last_commit', @last_commit
R
Riyad Preukschas 已提交
24 25 26 27 28 29
      = hidden_field_tag 'content', '', id: :file_content
      .commit-button-annotation
        = button_tag "Commit", class: 'btn commit-btn js-commit-button'
        .message
          to branch
          %strong= @ref
D
Dmitriy Zaporozhets 已提交
30
      = link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-cancel", confirm: "Are you sure?"
V
Valeriy Sizov 已提交
31 32

:javascript
33
  var ace_mode = "#{@blob.language.try(:ace_mode)}";
V
Valeriy Sizov 已提交
34
  var editor = ace.edit("editor");
R
Riyad Preukschas 已提交
35 36 37
  if (ace_mode) {
    editor.getSession().setMode('ace/mode/' + ace_mode);
  }
V
Valeriy Sizov 已提交
38

R
Riyad Preukschas 已提交
39 40 41
  disableButtonIfEmptyField("#commit_message", ".js-commit-button");

  $(".js-commit-button").click(function(){
V
Valeriy Sizov 已提交
42
    $("#file_content").val(editor.getValue());
R
Riyad Preukschas 已提交
43
    $(".file-editor form").submit();
V
Valeriy Sizov 已提交
44
  });