From 0cb3055441ff8b685e46d9aca377f7a0abd56b6e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 8 Feb 2015 14:18:13 +0100 Subject: [PATCH] Improved generation of avatar (removed double classes). --- .../javascripts/app/models/user.js.coffee | 19 ++++++++----------- .../app/views/profile/avatar.jst.eco | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 6071bb35a..3f0685336 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -52,23 +52,20 @@ class App.User extends App.Model else return '??' - avatar: (size = 40, placement = '', cssClass = '') -> - cssClass += " size-#{ size }" + avatar: (size = 40, placement = '', cssClass = '', unique = false, avatar) -> + cssClass += " size-#{size}" if placement placement = "data-placement=\"#{placement}\"" - if !@image || @image is 'none' - return @uniqueAvatar(size, placement, cssClass) + if !@image || @image is 'none' || unique + return @uniqueAvatar(size, placement, cssClass, avatar) else if @vip - cssClass += "#{cssClass} vip" + cssClass += " vip" "" - uniqueAvatar: (size = 40, placement = '', cssClass = '', avatar) -> - if size - cssClass += " size-#{ size }" - + uniqueAvatar: (size, placement = '', cssClass = '', avatar) -> width = 300 height = 226 size = parseInt(size, 10) @@ -78,13 +75,13 @@ class App.User extends App.Model y = rng() * (height - size) if !avatar - cssClass += "#{cssClass} user-popover" + cssClass += " user-popover" data = "data-id=\"#{@id}\"" else data = "data-avatar-id=\"#{avatar.id}\"" if @vip - cssClass += "#{cssClass} vip" + cssClass += " vip" "#{ @initials() }" @_fillUp: (data) -> diff --git a/app/assets/javascripts/app/views/profile/avatar.jst.eco b/app/assets/javascripts/app/views/profile/avatar.jst.eco index 3f7637e20..cb060495f 100644 --- a/app/assets/javascripts/app/views/profile/avatar.jst.eco +++ b/app/assets/javascripts/app/views/profile/avatar.jst.eco @@ -17,7 +17,7 @@ <% if avatar.default: %> <% cssClass = 'is-active' %> <% end %> - <%- App.Session.get().uniqueAvatar('50', '', cssClass, avatar) %> + <%- App.Session.get().avatar('50', '', cssClass, true, avatar) %> <% else: %> <% if avatar.deletable: %>