summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/new_blob.js.coffee
blob: f4e06ad088bc1573c9383bd71fdd31c547e189db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class @NewBlob
  constructor: (assets_path, mode)->
    ace.config.set "modePath", assets_path + '/ace'
    ace.config.loadModule "ace/ext/searchbox"
    if mode
      ace_mode = mode
    editor = ace.edit("editor")
    editor.focus()
    @editor = editor

    if ace_mode
      editor.getSession().setMode "ace/mode/" + ace_mode

    $('#new_branch').keyup ->
      if $(this).val() != $('#original_branch').val()
        $('.form-group.destination').show()
      else
        $('.form-group.destination').hide()
        $('#create_merge_request').prop('checked', false)

    $(".js-commit-button").click ->
      $("#file-content").val editor.getValue()
      $(".file-editor form").submit()
      return false

  editor: ->
    return @editor