codecombat/app/views/play/level/level_loading_view.coffee

55 lines
1.7 KiB
CoffeeScript
Raw Normal View History

2014-03-14 20:06:08 -04:00
View = require 'views/kinds/CocoView'
template = require 'templates/play/level/level_loading'
2014-03-16 20:07:10 -04:00
tips = [
"Tip: you can shift+click a position on the map to insert it into the spell editor."
"You can toggle play/paused with ctrl+p."
"Pressing ctrl+[ and ctrl+] rewinds and fast-forwards."
2014-03-16 23:32:24 -04:00
"CodeCombat is 100% open source!"
"In the future, even babies will be Archmages."
"Loading will continue until morale improves."
"CodeCombat launched its beta in October, 2013."
"JavaScript is just the beginning."
"We believe in equal opportunities to learn programming for all species."
2014-03-16 20:07:10 -04:00
]
2014-03-14 20:06:08 -04:00
module.exports = class LevelLoadingView extends View
id: "level-loading-view"
template: template
subscriptions:
'level-loader:progress-changed': 'onLevelLoaderProgressChanged'
onLevelLoaderProgressChanged: (e) ->
@progress = e.progress
@updateProgressBar()
updateProgressBar: ->
#@text.text = "BUILDING" if @progress is 1
@$el.find('.progress-bar').css('width', (100 * @progress) + '%')
showReady: ->
2014-03-16 20:07:10 -04:00
@$el.find('h2').addClass('ready').text 'Ready!'
2014-03-14 20:06:08 -04:00
unveil: ->
2014-03-14 22:44:19 -04:00
_.delay @reallyUnveil, 1000
2014-03-14 20:06:08 -04:00
reallyUnveil: =>
return if @destroyed
loadingDetails = @$el.find('.loading-details')
duration = parseFloat loadingDetails.css 'transition-duration'
loadingDetails.css 'top', -loadingDetails.outerHeight(true)
2014-03-14 22:44:19 -04:00
@$el.find('.left-wing').css left: '-100%', backgroundPosition: 'right -400px top 0'
@$el.find('.right-wing').css right: '-100%', backgroundPosition: 'left -400px top 0'
2014-03-14 20:06:08 -04:00
_.delay @onUnveilEnded, duration * 1000
onUnveilEnded: =>
return if @destroyed
Backbone.Mediator.publish 'onLoadingViewUnveiled', view: @
getRenderData: (c={}) ->
super c
2014-03-16 20:07:10 -04:00
c.tip = _.sample tips
2014-03-14 20:06:08 -04:00
c