mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-13 17:21:19 -05:00
29 lines
933 B
CoffeeScript
29 lines
933 B
CoffeeScript
|
ModalView = require 'views/core/ModalView'
|
||
|
template = require 'templates/courses/join-class-modal'
|
||
|
Classroom = require 'models/Classroom'
|
||
|
User = require 'models/User'
|
||
|
|
||
|
module.exports = class JoinClassModal extends ModalView
|
||
|
id: 'join-class-modal'
|
||
|
template: template
|
||
|
|
||
|
events:
|
||
|
'click .join-class-btn': 'onClickJoinClassButton'
|
||
|
|
||
|
initialize: ({ @classCode }) ->
|
||
|
@classroom = new Classroom()
|
||
|
@teacher = new User()
|
||
|
jqxhr = @supermodel.trackRequest @classroom.fetchByCode(@classCode)
|
||
|
unless me.get('emailVerified')
|
||
|
@supermodel.trackRequest $.post("/db/user/#{me.id}/request-verify-email")
|
||
|
@listenTo @classroom, 'sync', ->
|
||
|
@render
|
||
|
@listenTo @classroom, 'join:success', ->
|
||
|
@trigger('join:success', @classroom)
|
||
|
@listenTo @classroom, 'join:error', ->
|
||
|
@trigger('join:error', @classroom, jqxhr)
|
||
|
# @close()
|
||
|
|
||
|
onClickJoinClassButton: ->
|
||
|
@classroom.joinWithCode(@classCode)
|