mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Merge pull request #3374 from taptapdan/issue-3138-CastButtonView
Refactor CastButtonView to use view in template
This commit is contained in:
commit
95e627f346
2 changed files with 17 additions and 16 deletions
|
@ -1,11 +1,11 @@
|
|||
button.btn.btn-lg.btn-illustrated.cast-button(title=castVerbose)
|
||||
button.btn.btn-lg.btn-illustrated.cast-button(title=view.castVerbose())
|
||||
span(data-i18n="play_level.tome_run_button_ran") Ran
|
||||
|
||||
if !observing
|
||||
if mirror
|
||||
if !view.observing
|
||||
if view.mirror
|
||||
.ladder-submission-view
|
||||
else
|
||||
button.btn.btn-lg.btn-illustrated.submit-button(title=castRealTimeVerbose)
|
||||
button.btn.btn-lg.btn-illustrated.submit-button(title=view.castRealTimeVerbose())
|
||||
span(data-i18n="play_level.tome_submit_button") Submit
|
||||
span.spl.secret.submit-again-time
|
||||
|
||||
|
|
|
@ -32,24 +32,13 @@ module.exports = class CastButtonView extends CocoView
|
|||
@updateReplayabilityInterval = setInterval @updateReplayability, 1000
|
||||
@observing = options.session.get('creator') isnt me.id
|
||||
@loadMirrorSession() if @options.level.get('slug') in ['ace-of-coders', 'elemental-wars']
|
||||
@mirror = @mirrorSession?
|
||||
@autoSubmitsToLadder = @options.level.get('slug') in ['wakka-maul']
|
||||
|
||||
destroy: ->
|
||||
clearInterval @updateReplayabilityInterval
|
||||
super()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
shift = $.i18n.t 'keyboard_shortcuts.shift'
|
||||
enter = $.i18n.t 'keyboard_shortcuts.enter'
|
||||
castShortcutVerbose = "#{shift}+#{enter}"
|
||||
castRealTimeShortcutVerbose = (if @isMac() then 'Cmd' else 'Ctrl') + '+' + castShortcutVerbose
|
||||
context.castVerbose = castShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_code')
|
||||
context.castRealTimeVerbose = castRealTimeShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_real_time')
|
||||
context.observing = @observing
|
||||
context.mirror = @mirrorSession?
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
@castButton = $('.cast-button', @$el)
|
||||
|
@ -66,6 +55,18 @@ module.exports = class CastButtonView extends CocoView
|
|||
attachTo: (spellView) ->
|
||||
@$el.detach().prependTo(spellView.toolbarView.$el).show()
|
||||
|
||||
castShortcutVerbose: ->
|
||||
shift = $.i18n.t 'keyboard_shortcuts.shift'
|
||||
enter = $.i18n.t 'keyboard_shortcuts.enter'
|
||||
"#{shift}+#{enter}"
|
||||
|
||||
castVerbose: ->
|
||||
@castShortcutVerbose() + ': ' + $.i18n.t('keyboard_shortcuts.run_code')
|
||||
|
||||
castRealTimeVerbose: ->
|
||||
castRealTimeShortcutVerbose = (if @isMac() then 'Cmd' else 'Ctrl') + '+' + @castShortcutVerbose()
|
||||
castRealTimeShortcutVerbose + ': ' + $.i18n.t('keyboard_shortcuts.run_real_time')
|
||||
|
||||
onCastButtonClick: (e) ->
|
||||
Backbone.Mediator.publish 'tome:manual-cast', {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue