Improved generation of avatar (removed double classes).

This commit is contained in:
Martin Edenhofer 2015-02-08 14:18:13 +01:00
parent 7ade40308d
commit 0cb3055441
2 changed files with 9 additions and 12 deletions

View file

@ -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"
"<span class=\"avatar user-popover #{cssClass}\" data-id=\"#{@id}\" style=\"background-image: url(#{ @imageUrl })\" #{placement}></span>"
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"
"<span class=\"avatar unique #{cssClass}\" #{data} style=\"background-position: -#{ x }px -#{ y }px;\" #{placement}>#{ @initials() }</span>"
@_fillUp: (data) ->

View file

@ -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: %>
<span class="avatar size-50 <% if avatar.default: %>is-active<% end %>" data-avatar-id="<%- avatar.id %>" style="background-image: url(<%- avatar.content %>)"></span>
<% if avatar.deletable: %>