2014-07-17 20:20:11 -04:00
|
|
|
CocoView = require 'views/kinds/CocoView'
|
2014-01-03 13:32:13 -05:00
|
|
|
template = require 'templates/play/level/tome/problem_alert'
|
|
|
|
{me} = require 'lib/auth'
|
|
|
|
|
2014-07-17 20:20:11 -04:00
|
|
|
module.exports = class ProblemAlertView extends CocoView
|
2014-01-03 13:32:13 -05:00
|
|
|
className: 'problem-alert'
|
|
|
|
template: template
|
|
|
|
|
|
|
|
subscriptions: {}
|
|
|
|
|
|
|
|
events:
|
2014-06-30 22:16:26 -04:00
|
|
|
'click .close': 'onRemoveClicked'
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
constructor: (options) ->
|
|
|
|
super options
|
|
|
|
@problem = options.problem
|
|
|
|
|
2014-02-11 17:58:45 -05:00
|
|
|
getRenderData: (context={}) ->
|
2014-01-03 13:32:13 -05:00
|
|
|
context = super context
|
2014-05-15 16:11:26 -04:00
|
|
|
format = (s) -> s?.replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br>')
|
2014-11-06 18:03:39 -05:00
|
|
|
context.message = format @problem.aetherProblem.message
|
2014-02-14 19:52:50 -05:00
|
|
|
context.hint = format @problem.aetherProblem.hint
|
2014-01-03 13:32:13 -05:00
|
|
|
context
|
|
|
|
|
|
|
|
afterRender: ->
|
|
|
|
super()
|
2014-03-28 20:06:21 -04:00
|
|
|
@$el.addClass('alert').addClass("alert-#{@problem.aetherProblem.level}").hide().fadeIn('slow')
|
2014-08-04 23:16:12 -04:00
|
|
|
@$el.addClass('no-hint') unless @problem.aetherProblem.hint
|
2014-08-27 15:24:03 -04:00
|
|
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'error_appear', volume: 1.0
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
onRemoveClicked: ->
|
|
|
|
@$el.remove()
|
|
|
|
@destroy()
|
|
|
|
#@problem.destroy() # let's try leaving the annotations / marker ranges alone
|