Welcome to mirror list, hosted at ThFree Co, Russian Federation.

edit_blob.js.coffee « blob « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2e91a06daa8b900eda0d91f1721ce26a30d842be (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class @EditBlob
  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

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

    editModePanes = $(".js-edit-mode-pane")
    editModeLinks = $(".js-edit-mode a")
    editModeLinks.click (event) ->
      event.preventDefault()
      currentLink = $(this)
      paneId = currentLink.attr("href")
      currentPane = editModePanes.filter(paneId)
      editModeLinks.parent().removeClass "active hover"
      currentLink.parent().addClass "active hover"
      editModePanes.hide()
      if paneId is "#preview"
        currentPane.fadeIn 200
        $.post currentLink.data("preview-url"),
          content: editor.getValue()
        , (response) ->
          currentPane.empty().append response
          return

      else
        currentPane.fadeIn 200
        editor.focus()
      return

  editor: ->
    return @editor