- content_for :javascripts do
  = javascript_include_tag 'provider/codemirror'

= form.inputs do
  = form.input :name
  - if @api_docs_service.new_record?
    = form.input :system_name
  - else
    = form.input :system_name, input_html: { :disabled => true }
  = form.input :published, label: 'Publish?'
  = form.input :description, input_html: {rows: 3}
  = form.input :body, label: 'API JSON Spec', inline_errors: :list
  = form.semantic_errors :base_path
  = form.input :skip_swagger_validations, as: :boolean
= form.buttons do
  = form.commit_button

css:
  #api_docs_service_body_input .CodeMirror {
    clear: both;
  }

javascript:
  (function(){
    var textarea = document.getElementById("api_docs_service_body")
    var editor = CodeMirror.fromTextArea(textarea, {
      matchBrackets: true,
      autoCloseBrackets: true,
      mode: "application/json",
      lineWrapping: true,
      lineNumbers: true,
      theme: "neat"
    })
    $(textarea).on('change', function(){ editor.setValue(textarea.value); })
  }())

