2014-01-03 13:32:13 -05:00
|
|
|
View = require 'views/kinds/RootView'
|
|
|
|
template = require 'templates/home'
|
|
|
|
WizardSprite = require 'lib/surface/WizardSprite'
|
|
|
|
ThangType = require 'models/ThangType'
|
2014-02-14 18:50:42 -05:00
|
|
|
Simulator = require 'lib/simulator/Simulator'
|
2014-03-16 19:59:48 -04:00
|
|
|
{me} = require '/lib/auth'
|
2014-04-13 23:31:23 -04:00
|
|
|
application = require 'application'
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
module.exports = class HomeView extends View
|
|
|
|
id: 'home-view'
|
|
|
|
template: template
|
2014-03-21 20:42:13 -04:00
|
|
|
|
2014-03-03 13:42:11 -05:00
|
|
|
constructor: ->
|
|
|
|
super(arguments...)
|
|
|
|
ThangType.loadUniversalWizard()
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
if $.browser
|
2014-04-13 23:31:23 -04:00
|
|
|
majorVersion = $.browser.versionNumber
|
2014-01-03 13:32:13 -05:00
|
|
|
c.isOldBrowser = true if $.browser.mozilla && majorVersion < 21
|
|
|
|
c.isOldBrowser = true if $.browser.chrome && majorVersion < 17
|
|
|
|
c.isOldBrowser = true if $.browser.safari && majorVersion < 536
|
|
|
|
else
|
|
|
|
console.warn 'no more jquery browser version...'
|
2014-03-16 19:59:48 -04:00
|
|
|
c.isEnglish = (me.get('preferredLanguage') or 'en').startsWith 'en'
|
2014-04-09 01:50:13 -04:00
|
|
|
c.languageName = me.get('preferredLanguage')
|
2014-04-13 23:31:23 -04:00
|
|
|
# A/B test: https://github.com/codecombat/codecombat/issues/769
|
|
|
|
c.frontPageContent = {0: "video", 1: "screenshot", 2: "nothing"}[me.get('testGroupNumber') % 3]
|
|
|
|
application.tracker.identify frontPageContent: c.frontPageContent
|
|
|
|
application.tracker.trackEvent 'Front Page Content', frontPageContent: c.frontPageContent
|
2014-01-03 13:32:13 -05:00
|
|
|
c
|
|
|
|
|
|
|
|
afterRender: ->
|
|
|
|
super()
|
2014-01-30 19:36:36 -05:00
|
|
|
@$el.find('.modal').on 'shown.bs.modal', ->
|
2014-01-03 13:32:13 -05:00
|
|
|
$('input:visible:first', @).focus()
|
|
|
|
|
2014-01-19 02:15:59 -05:00
|
|
|
# Try to find latest level and set "Play" link to go to that level
|
2014-03-21 19:49:30 -04:00
|
|
|
lastLevel = me.get("lastLevel")
|
2014-03-21 20:42:13 -04:00
|
|
|
lastLevel ?= localStorage?["lastLevel"] # Temp, until it's migrated to user property
|
|
|
|
if lastLevel
|
2014-03-21 19:49:30 -04:00
|
|
|
playLink = @$el.find("#beginner-campaign")
|
|
|
|
if playLink[0]?
|
|
|
|
href = playLink.attr("href").split("/")
|
|
|
|
href[href.length-1] = lastLevel if href.length isnt 0
|
|
|
|
href = href.join("/")
|
2014-04-13 23:31:23 -04:00
|
|
|
playLink.attr("href", href)
|