user-credential-page.js.coffee 846 B

1234567891011121314151617181920212223242526
  1. class @UserCredentialPage
  2. constructor: ->
  3. editor = ace.edit("ace-credential-value")
  4. editor.getSession().setTabSize(2)
  5. editor.getSession().setUseSoftTabs(true)
  6. editor.getSession().setUseWrapMode(false)
  7. editor.setTheme("ace/theme/chrome")
  8. setMode = ->
  9. mode = $("#user_credential_mode").val()
  10. if mode == 'java_script'
  11. editor.getSession().setMode("ace/mode/javascript")
  12. else
  13. editor.getSession().setMode("ace/mode/text")
  14. setMode()
  15. $("#user_credential_mode").on 'change', setMode
  16. $textarea = $('#user_credential_credential_value').hide()
  17. editor.getSession().setValue($textarea.val())
  18. $textarea.closest('form').on 'submit', ->
  19. $textarea.val(editor.getSession().getValue())
  20. $ ->
  21. Utils.registerPage(UserCredentialPage, forPathsMatching: /^user_credentials\/\d+/)