From 4dafa050480c0b2cbb2d16b17f094ab493233d64 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 25 Sep 2014 01:11:42 +0200 Subject: [PATCH] Improved error handling. --- .../javascripts/app/models/user.js.coffee | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 198c33db4..486b2f1d5 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -37,16 +37,20 @@ class App.User extends App.Model "user icon" initials: -> - if @firstname[0] && @lastname[0] - @firstname[0] + @lastname[0] - else if @firstname[0] && !@lastname[0] - @firstname[0] + @firstname[1] - else if !@firstname[0] && @lastname[0] - @lastname[0] + @lastname[1] + if @firstname && @lastname && @firstname[0] && @lastname[0] + return @firstname[0] + @lastname[0] + else if @firstname && @firstname[0] && !@lastname + if @firstname[1] + return @firstname[0] + @firstname[1] + return @firstname[0] + else if !@firstname && @lastname && @lastname[0] + if @lastname[1] + return @lastname[0] + @lastname[1] + return @lastname[0] else if @email - @email[0] + @email[1] + return @email[0] + @email[1] else - '??' + return '??' avatar: (big = false, placement = '', cssClass = '') -> if big