Add jquery fading

Also using the level:session-will-save callback
This commit is contained in:
Philipp Hansch 2014-01-16 17:13:14 +01:00
parent ff5807adb8
commit 3a63428c0c

View file

@ -22,6 +22,7 @@ module.exports = class SpellView extends View
'tome:manual-cast': 'onManualCast'
'tome:reload-code': 'onCodeReload'
'tome:spell-changed': 'onSpellChanged'
'level:session-will-save': 'onSessionWillSave'
'modal-closed': 'focus'
'focus-editor': 'focus'
@ -318,7 +319,21 @@ module.exports = class SpellView extends View
# console.log "valid but not at end of line; recompile in", @autocastDelay + "ms"
onSpellChanged: (e) ->
@spellHasChanged = true
onSessionWillSave: (e) ->
setTimeout(->
if not @spellHasChanged
$('#spell-view #save-status').delay(3000).fadeOut(2000)
, 3000)
if @spellHasChanged
# Keep showing the text by stopping the fade animation
$('#spell-view #save-status').show('fast')
$('#spell-view #save-status').css('visibility', 'visible')
$('#spell-view #save-status').stop(true, true)
@spellHasChanged = false
onUserCodeProblem: (e) ->
return @onInfiniteLoop e if e.problem.id is "runtime_InfiniteLoop"