mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 00:28:31 -05:00
30e8fc2397
Courses will now use campaign levels instead of mock data if available. At the moment only the first intro course has a campaign specified (‘intro’).
50 lines
1.4 KiB
CoffeeScript
50 lines
1.4 KiB
CoffeeScript
app = require 'core/application'
|
|
RootView = require 'views/core/RootView'
|
|
template = require 'templates/courses/mock1/courses'
|
|
|
|
module.exports = class CoursesView extends RootView
|
|
id: 'courses-view'
|
|
template: template
|
|
|
|
events:
|
|
'click .btn-enter': 'onClickEnter'
|
|
'click .btn-have-code': 'onClickHaveCode'
|
|
'click .btn-more-info': 'onClickMoreInfo'
|
|
|
|
constructor: (options) ->
|
|
super options
|
|
@initData()
|
|
|
|
getRenderData: ->
|
|
context = super()
|
|
context.courses = @courses ? []
|
|
context
|
|
|
|
initData: ->
|
|
mockData = require 'views/courses/mock1/CoursesMockData'
|
|
@courses = mockData.courses
|
|
for course, i in @courses
|
|
if _.random(0, 3) is 0
|
|
course.unlocked = true
|
|
else
|
|
break
|
|
|
|
onClickEnter: (e) ->
|
|
courseID = $(e.target).data('course-id')
|
|
app.router.navigate "/courses/mock1/#{courseID}"
|
|
window.location.reload()
|
|
|
|
onClickHaveCode: (e) ->
|
|
courseID = $(e.target).data('course-id')
|
|
alert 'TODO: Popup for entering prepaid code to unlock this course'
|
|
|
|
# TODO: would just navigate instead of rendering unlock here in practice
|
|
@courses[courseID].unlocked = true
|
|
@render?()
|
|
# app.router.navigate "/courses/mock1/#{courseID}"
|
|
# window.location.reload()
|
|
|
|
onClickMoreInfo: (e) ->
|
|
courseID = $(e.target).data('course-id')
|
|
app.router.navigate "/courses/mock1/#{courseID}/info"
|
|
window.location.reload()
|