mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-26 13:06:41 +10:00
Prior, the value of the Ace editor was only being persisted if the user physically clicked the submit button, which the "quick submit" behavior doesn't do. Now the value will be properly transferred before any form is submitted.
44 lines
1.2 KiB
CoffeeScript
44 lines
1.2 KiB
CoffeeScript
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
|
|
|
|
# Before a form submission, move the content from the Ace editor into the
|
|
# submitted textarea
|
|
$('form').submit ->
|
|
$("#file-content").val(editor.getValue())
|
|
|
|
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
|