summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob/new_blob.js.coffee
blob: c2d6c7acfefc4819c3f5e21ca4dcd72322502686 (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)

    # Before a form submission, move the content from the Ace editor into the
    # submitted textarea
    $('form').submit ->
      $("#file-content").val(editor.getValue())

  editor: ->
    return @editor