mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-11 00:02:19 -05:00
32 lines
859 B
CoffeeScript
32 lines
859 B
CoffeeScript
|
app = require 'core/application'
|
||
|
RootView = require 'views/core/RootView'
|
||
|
template = require 'templates/courses/mock1/course-info'
|
||
|
|
||
|
module.exports = class CourseInfoView extends RootView
|
||
|
id: 'course-info-view'
|
||
|
template: template
|
||
|
|
||
|
events:
|
||
|
'click .btn-enroll': 'onClickEnroll'
|
||
|
|
||
|
constructor: (options, @courseID) ->
|
||
|
super options
|
||
|
@initData()
|
||
|
|
||
|
getRenderData: ->
|
||
|
context = super()
|
||
|
context.course = @course ? {}
|
||
|
context.courseID = @courseID
|
||
|
context.praise = @praise
|
||
|
context
|
||
|
|
||
|
initData: ->
|
||
|
mockData = require 'views/courses/mock1/CoursesMockData'
|
||
|
@course = mockData.courses[@courseID]
|
||
|
@praise = mockData.praise[_.random(0, mockData.praise.length - 1)]
|
||
|
|
||
|
onClickEnroll: (e) ->
|
||
|
courseID = $(e.target).data('course-id')
|
||
|
app.router.navigate "/courses/mock1/#{courseID}/enroll"
|
||
|
window.location.reload()
|