mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 18:15:52 -05:00
53 lines
1.5 KiB
CoffeeScript
53 lines
1.5 KiB
CoffeeScript
View = require 'views/kinds/ModalView'
|
|
template = require 'templates/play/level/modal/editor_config'
|
|
{me} = require('lib/auth')
|
|
|
|
module.exports = class EditorConfigModal extends View
|
|
id: 'level-editor-config-modal'
|
|
template: template
|
|
aceConfig: {}
|
|
|
|
defaultConfig:
|
|
keyBindings: 'default'
|
|
invisibles: false
|
|
indentGuides: false
|
|
|
|
events:
|
|
'change #invisibles': 'updateInvisiblesSelection'
|
|
'change #keyBindings': 'updateKeyBindingsSelection'
|
|
'change #indentGuides': 'updateIndentGuides'
|
|
|
|
constructor: (options) ->
|
|
super(options)
|
|
|
|
getRenderData: ->
|
|
@aceConfig = _.cloneDeep me.get('aceConfig') ? {}
|
|
@aceConfig = _.defaults @aceConfig, @defaultConfig
|
|
c = super()
|
|
c.keyBindings = @aceConfig.keyBindings
|
|
c.invisibles = @aceConfig.invisibles
|
|
c.indentGuides = @aceConfig.indentGuides
|
|
c
|
|
|
|
updateInvisiblesSelection: ->
|
|
@aceConfig.invisibles = @$el.find('#invisibles').prop('checked')
|
|
|
|
updateKeyBindingsSelection: ->
|
|
@aceConfig.keyBindings = @$el.find('#keyBindings').val()
|
|
|
|
updateIndentGuides: ->
|
|
@aceConfig.indentGuides = @$el.find('#indentGuides').prop('checked')
|
|
|
|
afterRender: ->
|
|
super()
|
|
|
|
onHidden: ->
|
|
@aceConfig.invisibles = @$el.find('#invisibles').prop('checked')
|
|
@aceConfig.keyBindings = @$el.find('#keyBindings').val()
|
|
@aceConfig.indentGuides = @$el.find('#indentGuides').prop('checked')
|
|
me.set 'aceConfig', @aceConfig
|
|
Backbone.Mediator.publish 'change:editor-config'
|
|
me.save()
|
|
|
|
destroy: ->
|
|
super()
|