mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 00:28:31 -05:00
25 lines
831 B
CoffeeScript
25 lines
831 B
CoffeeScript
View = require 'views/kinds/CocoView'
|
|
template = require 'templates/play/level/gold'
|
|
|
|
module.exports = class GoldView extends View
|
|
id: "gold-view"
|
|
template: template
|
|
|
|
subscriptions:
|
|
'surface:gold-changed': 'onGoldChanged'
|
|
'level-set-letterbox': 'onSetLetterbox'
|
|
|
|
onGoldChanged: (e) ->
|
|
@$el.show()
|
|
goldEl = @$el.find('.gold-amount.team-' + e.team)
|
|
unless goldEl.length
|
|
teamEl = $("<div class='team-gold team-#{e.team}' title='Gold: #{e.team}'><img src='/images/level/prop_gold.png'> <div class='gold-amount team-#{e.team}'></div></div>")
|
|
@$el.append(teamEl)
|
|
goldEl = teamEl.find('.gold-amount.team-' + e.team)
|
|
text = '' + e.gold
|
|
if e.goldEarned and e.goldEarned > e.gold
|
|
text += " (#{e.goldEarned})"
|
|
goldEl.text text
|
|
|
|
onSetLetterbox: (e) ->
|
|
@$el.toggle not e.on
|