2014-01-03 13:32:13 -05:00
|
|
|
View = require 'views/kinds/ModalView'
|
|
|
|
template = require 'templates/play/level/modal/multiplayer'
|
|
|
|
|
|
|
|
module.exports = class MultiplayerModal extends View
|
|
|
|
id: 'level-multiplayer-modal'
|
|
|
|
template: template
|
|
|
|
|
|
|
|
events:
|
|
|
|
'click textarea': 'onClickLink'
|
|
|
|
'change #multiplayer': 'updateLinkSection'
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
constructor: (options) ->
|
|
|
|
super(options)
|
|
|
|
@session = options.session
|
|
|
|
@session.on 'change:multiplayer', @updateLinkSection
|
|
|
|
|
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
c.joinLink = (document.location.href.replace(/\?.*/, '').replace('#', '') +
|
|
|
|
'?session=' +
|
|
|
|
@session.id)
|
|
|
|
c.multiplayer = @session.get('multiplayer')
|
|
|
|
c
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
afterRender: ->
|
|
|
|
super()
|
|
|
|
@updateLinkSection()
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
onClickLink: (e) =>
|
|
|
|
e.target.select()
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
updateLinkSection: =>
|
2014-01-04 18:49:13 -05:00
|
|
|
multiplayer = @$el.find('#multiplayer').prop('checked')
|
2014-01-03 13:32:13 -05:00
|
|
|
la = @$el.find('#link-area')
|
|
|
|
if multiplayer then la.show() else la.hide()
|
2014-01-04 18:49:13 -05:00
|
|
|
true
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
onHidden: ->
|
2014-01-04 18:49:13 -05:00
|
|
|
multiplayer = Boolean(@$el.find('#multiplayer').prop('checked'))
|
|
|
|
@session.set('multiplayer', multiplayer)
|