From 62367ce25681ac3478d340233b7ae053594f0961 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 19 Oct 2015 16:15:16 +0200 Subject: [PATCH] Added small comments. --- app/assets/javascripts/app/models/user.coffee | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/models/user.coffee b/app/assets/javascripts/app/models/user.coffee index 6edb71b68..9e22dee58 100644 --- a/app/assets/javascripts/app/models/user.coffee +++ b/app/assets/javascripts/app/models/user.coffee @@ -48,7 +48,7 @@ class App.User extends App.Model avatar: (size = 40, placement = '', cssClass = '', unique = false, avatar, type = undefined) -> size = parseInt(size, 10) - cssClass += " " if cssClass + cssClass += ' ' if cssClass cssClass += "size-#{ size }" if placement @@ -65,6 +65,7 @@ class App.User extends App.Model vip = false data = " data-avatar-id=\"#{avatar.id}\"" + # set vip flag, ignore if personal avatar is request vip = @vip if type is 'personal' vip = false @@ -74,7 +75,9 @@ class App.User extends App.Model # use system avatar for system actions if @id is 1 return App.view('avatar_system')() - else if !@image || @image is 'none' || unique + + # generate uniq avatar + if !@image || @image is 'none' || unique width = 300 height = 226 @@ -90,13 +93,14 @@ class App.User extends App.Model x: x y: y initials: @initials() - else - return App.view('avatar') - data: data - cssClass: cssClass - placement: placement - vip: vip - url: @imageUrl() + + # generate image based avatar + return App.view('avatar') + data: data + cssClass: cssClass + placement: placement + vip: vip + url: @imageUrl() imageUrl: -> return if !@image