2016-01-19 18:42:20 -05:00
|
|
|
CocoView = require 'views/core/CocoView'
|
2016-05-30 19:26:55 -04:00
|
|
|
utils = require 'core/utils'
|
2016-07-28 16:39:58 -04:00
|
|
|
urls = require 'core/urls'
|
2016-01-19 18:42:20 -05:00
|
|
|
|
|
|
|
module.exports = class ProgressView extends CocoView
|
2016-05-30 19:26:55 -04:00
|
|
|
|
2016-01-19 18:42:20 -05:00
|
|
|
id: 'progress-view'
|
|
|
|
className: 'modal-content'
|
|
|
|
template: require 'templates/play/level/modal/progress-view'
|
|
|
|
|
|
|
|
events:
|
|
|
|
'click #done-btn': 'onClickDoneButton'
|
|
|
|
'click #next-level-btn': 'onClickNextLevelButton'
|
2016-07-15 18:54:22 -04:00
|
|
|
'click #ladder-btn': 'onClickLadderButton'
|
2016-07-15 19:57:39 -04:00
|
|
|
'click #share-level-btn': 'onClickShareLevelButton'
|
2016-01-19 18:42:20 -05:00
|
|
|
|
|
|
|
initialize: (options) ->
|
|
|
|
@level = options.level
|
|
|
|
@course = options.course
|
2016-04-13 12:54:24 -04:00
|
|
|
@classroom = options.classroom
|
2016-01-19 18:42:20 -05:00
|
|
|
@nextLevel = options.nextLevel
|
|
|
|
@levelSessions = options.levelSessions
|
2016-07-15 23:03:12 -04:00
|
|
|
@session = options.session
|
2016-05-30 19:26:55 -04:00
|
|
|
# Translate and Markdownify level description, but take out any images (we don't have room for arena banners, etc.).
|
|
|
|
# Images in Markdown are like ![description](url)
|
2016-05-31 13:59:06 -04:00
|
|
|
@nextLevel.get('description', true) # Make sure the defaults are available
|
|
|
|
@nextLevelDescription = marked(utils.i18n(@nextLevel.attributesWithDefaults, 'description').replace(/!\[.*?\]\(.*?\)\n*/g, ''))
|
2016-07-16 02:26:43 -04:00
|
|
|
if @level.get('shareable') is 'project'
|
2016-07-28 16:39:58 -04:00
|
|
|
@shareURL = urls.playDevLevel({@level, @session, @course})
|
2016-01-19 18:42:20 -05:00
|
|
|
|
|
|
|
onClickDoneButton: ->
|
|
|
|
@trigger 'done'
|
|
|
|
|
|
|
|
onClickNextLevelButton: ->
|
2016-05-30 19:26:55 -04:00
|
|
|
@trigger 'next-level'
|
2016-07-15 18:54:22 -04:00
|
|
|
|
|
|
|
onClickLadderButton: ->
|
|
|
|
@trigger 'ladder'
|
2016-07-15 19:57:39 -04:00
|
|
|
|
|
|
|
onClickShareLevelButton: ->
|
2016-07-28 16:39:58 -04:00
|
|
|
if _.string.startsWith(@course.get('slug'), 'game-dev')
|
|
|
|
name = 'Student Game Dev - Copy URL'
|
|
|
|
category = 'GameDev'
|
|
|
|
else
|
|
|
|
name = 'Student Web Dev - Copy URL'
|
|
|
|
category = 'WebDev'
|
|
|
|
eventProperties = {
|
|
|
|
levelID: @level.id
|
|
|
|
levelSlug: @level.get('slug')
|
|
|
|
classroomID: @classroom.id
|
|
|
|
courseID: @course.id
|
|
|
|
category
|
|
|
|
}
|
|
|
|
window.tracker?.trackEvent name, eventProperties, ['MixPanel']
|
2016-07-15 23:03:12 -04:00
|
|
|
@$('#share-level-input').val(@shareURL).select()
|
2016-07-15 19:57:39 -04:00
|
|
|
@tryCopy()
|