2015-09-10 13:37:32 -04:00
|
|
|
app = require 'core/application'
|
2015-10-09 12:32:46 -04:00
|
|
|
AuthModal = require 'views/core/AuthModal'
|
2015-09-10 13:37:32 -04:00
|
|
|
RootView = require 'views/core/RootView'
|
2015-11-03 19:41:06 -05:00
|
|
|
template = require 'templates/courses/courses-view'
|
2015-11-21 14:38:34 -05:00
|
|
|
StudentLogInModal = require 'views/courses/StudentLogInModal'
|
|
|
|
StudentSignUpModal = require 'views/courses/StudentSignUpModal'
|
|
|
|
CourseInstance = require 'models/CourseInstance'
|
2015-10-12 19:25:23 -04:00
|
|
|
|
2015-08-29 10:15:35 -04:00
|
|
|
module.exports = class CoursesView extends RootView
|
|
|
|
id: 'courses-view'
|
|
|
|
template: template
|
2015-11-21 14:38:34 -05:00
|
|
|
|
|
|
|
events:
|
|
|
|
'click #log-in-btn': 'onClickLogInButton'
|
|
|
|
'click #start-new-game-btn': 'onClickStartNewGameButton'
|
|
|
|
|
|
|
|
onClickStartNewGameButton: ->
|
|
|
|
@openSignUpModal()
|
|
|
|
|
|
|
|
onClickLogInButton: ->
|
|
|
|
modal = new StudentLogInModal()
|
|
|
|
@openModalView(modal)
|
|
|
|
modal.on 'want-to-create-account', @openSignUpModal, @
|
|
|
|
|
|
|
|
openSignUpModal: ->
|
|
|
|
modal = new StudentSignUpModal({ willPlay: true })
|
|
|
|
@openModalView(modal)
|
|
|
|
modal.once 'click-skip-link', @startHourOfCodePlay, @
|
|
|
|
|
|
|
|
startHourOfCodePlay: ->
|
|
|
|
@$('#main-content').hide()
|
|
|
|
@$('#begin-hoc-area').removeClass('hide')
|
|
|
|
hocCourseInstance = new CourseInstance()
|
|
|
|
hocCourseInstance.upsertForHOC()
|
|
|
|
@listenToOnce hocCourseInstance, 'sync', ->
|
|
|
|
url = hocCourseInstance.firstLevelURL()
|
|
|
|
app.router.navigate(url, { trigger: true })
|