mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 16:17:57 -05:00
36 lines
921 B
CoffeeScript
36 lines
921 B
CoffeeScript
View = require 'views/kinds/RootView'
|
|
template = require 'templates/account/profile'
|
|
User = require 'models/User'
|
|
|
|
module.exports = class ProfileView extends View
|
|
id: "profile-view"
|
|
template: template
|
|
loading: true
|
|
|
|
constructor: (options, @userID) ->
|
|
super options
|
|
@user = User.getByID(@userID)
|
|
@loading = false if 'gravatarProfile' of @user
|
|
@user.on('change', @userChanged)
|
|
@user.on('error', @userError)
|
|
|
|
userChanged: (user) =>
|
|
@loading = false if 'gravatarProfile' of user
|
|
@render()
|
|
|
|
userError: (user) =>
|
|
@loading = false
|
|
@render()
|
|
|
|
getRenderData: ->
|
|
context = super()
|
|
grav = @user.gravatarProfile
|
|
grav = grav.entry[0] if grav
|
|
addedContext =
|
|
user: @user
|
|
loading: @loading
|
|
myProfile: @user.id is context.me.id
|
|
grav: grav
|
|
photoURL: @user.getPhotoURL()
|
|
context[key] = addedContext[key] for key of addedContext
|
|
context
|