mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
changed name of event triggered when config is changed and introduced new event when language is changed
This commit is contained in:
parent
ce6533de59
commit
6a983dcb8c
4 changed files with 23 additions and 3 deletions
|
@ -54,13 +54,15 @@ module.exports = class EditorConfigModal extends View
|
|||
super()
|
||||
|
||||
onHidden: ->
|
||||
oldLanguage = @aceConfig.language
|
||||
@aceConfig.language = @$el.find('#tome-language').val()
|
||||
@aceConfig.invisibles = @$el.find('#tome-invisibles').prop('checked')
|
||||
@aceConfig.keyBindings = @$el.find('#tome-key-bindings').val()
|
||||
@aceConfig.indentGuides = @$el.find('#tome-indent-guides').prop('checked')
|
||||
@aceConfig.behaviors = @$el.find('#tome-behaviors').prop('checked')
|
||||
me.set 'aceConfig', @aceConfig
|
||||
Backbone.Mediator.publish 'change:editor-config'
|
||||
Backbone.Mediator.publish 'tome:change-config'
|
||||
Backbone.Mediator.publish 'tome:change-language' unless @aceConfig.language is oldLanguage
|
||||
me.save()
|
||||
|
||||
destroy: ->
|
||||
|
|
|
@ -85,11 +85,13 @@ module.exports = class Spell
|
|||
aether.hasChangedSignificantly (newSource ? @originalSource), (currentSource ? @source), true, true
|
||||
|
||||
createAether: (thang) ->
|
||||
aceConfig = me.get 'aceConfig' ? {}
|
||||
aetherOptions =
|
||||
problems:
|
||||
jshint_W040: {level: "ignore"}
|
||||
jshint_W030: {level: "ignore"} # aether_NoEffect instead
|
||||
aether_MissingThis: {level: (if thang.requiresThis then 'error' else 'warning')}
|
||||
language: aceConfig.language ? 'javascript'
|
||||
functionName: @name
|
||||
functionParameters: @parameters
|
||||
yieldConditionally: thang.plan?
|
||||
|
@ -107,5 +109,12 @@ module.exports = class Spell
|
|||
aether = new Aether aetherOptions
|
||||
aether
|
||||
|
||||
updateLanguageAether: ->
|
||||
aceConfig = me.get 'aceConfig' ? {}
|
||||
for thangId, spellThang of @thangs
|
||||
spellThang.aether?.setLanguage (aceConfig.language ? 'javascript')
|
||||
spellThang.castAether = null
|
||||
@transpile()
|
||||
|
||||
toString: ->
|
||||
"<Spell: #{@spellKey}>"
|
||||
|
|
|
@ -38,8 +38,9 @@ module.exports = class SpellView extends View
|
|||
'modal-closed': 'focus'
|
||||
'focus-editor': 'focus'
|
||||
'tome:spell-statement-index-updated': 'onStatementIndexUpdated'
|
||||
'tome:change-language': 'onChangeLanguage'
|
||||
'tome:change-config': 'onChangeEditorConfig'
|
||||
'spell-beautify': 'onSpellBeautify'
|
||||
'change:editor-config': 'onChangeEditorConfig'
|
||||
|
||||
events:
|
||||
'mouseout': 'onMouseOut'
|
||||
|
@ -566,10 +567,14 @@ module.exports = class SpellView extends View
|
|||
onChangeEditorConfig: (e) ->
|
||||
aceConfig = me.get 'aceConfig'
|
||||
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
|
||||
@ace.setShowInvisibles # default false
|
||||
@ace.setShowInvisibles aceConfig.invisibles # default false
|
||||
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
|
||||
@aceSession.setMode @editModes[aceConfig.language ? 'javascript']
|
||||
|
||||
onChangeLanguage: (e) ->
|
||||
aceConfig = me.get 'aceConfig'
|
||||
@aceSession.setMode @editModes[aceConfig.language ? 'javascript']
|
||||
|
||||
dismiss: ->
|
||||
@recompile() if @spell.hasChangedSignificantly @getSource()
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ module.exports = class TomeView extends View
|
|||
'tome:spell-loaded': "onSpellLoaded"
|
||||
'tome:cast-spell': "onCastSpell"
|
||||
'tome:toggle-spell-list': 'onToggleSpellList'
|
||||
'tome:change-language': 'updateLanguageForAllSpells'
|
||||
'surface:sprite-selected': 'onSpriteSelected'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
|
||||
|
@ -217,6 +218,9 @@ module.exports = class TomeView extends View
|
|||
spell.view.reloadCode false for spellKey, spell of @spells
|
||||
Backbone.Mediator.publish 'tome:cast-spells', spells: @spells
|
||||
|
||||
updateLanguageForAllSpells: ->
|
||||
spell.updateLanguageAether for spellKey, spell of @spells
|
||||
|
||||
destroy: ->
|
||||
spell.destroy() for spellKey, spell of @spells
|
||||
@worker?._close()
|
||||
|
|
Loading…
Reference in a new issue