summaryrefslogtreecommitdiffstats
path: root/client/components/users/userAvatar.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-06-10 17:10:32 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-06-10 17:10:32 +0200
commit765b0168eaaeb28550dfb698de0b6cec9f9c2113 (patch)
treee9e7c6545e35042e3086262684a8128e95f5666f /client/components/users/userAvatar.js
parent0b6c229b6cec2329752013393e83ebd122e3d2eb (diff)
downloadwekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.tar.gz
wekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.tar.bz2
wekan-765b0168eaaeb28550dfb698de0b6cec9f9c2113.zip
(Re-)implement default avatar using user initials
We use a embedded svg to scale the initials text to its container size. The user is free to overwrite its initials in the profile form.
Diffstat (limited to 'client/components/users/userAvatar.js')
-rw-r--r--client/components/users/userAvatar.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js
index deae01cf..a02646c1 100644
--- a/client/components/users/userAvatar.js
+++ b/client/components/users/userAvatar.js
@@ -26,6 +26,18 @@ Template.userAvatar.helpers({
}
});
+Template.userAvatarInitials.helpers({
+ initials: function() {
+ var user = Users.findOne(this.userId);
+ return user && user.getInitials();
+ },
+
+ viewPortWidth: function() {
+ var user = Users.findOne(this.userId);
+ return (user && user.getInitials().length || 1) * 12;
+ }
+});
+
BlazeComponent.extendComponent({
template: function() {
return 'changeAvatarPopup';
@@ -49,6 +61,12 @@ BlazeComponent.extendComponent({
return avatarUrl === currentAvatarUrl;
},
+ noAvatarUrl: function() {
+ var userProfile = Meteor.user().profile;
+ var avatarUrl = userProfile && userProfile.avatarUrl;
+ return ! avatarUrl;
+ },
+
setAvatar: function(avatarUrl) {
Meteor.users.update(Meteor.userId(), {
$set: {
@@ -84,6 +102,9 @@ BlazeComponent.extendComponent({
var avatarUrl = this.currentData().url(this.avatarUrlOptions());
this.setAvatar(avatarUrl);
},
+ 'click .js-select-initials': function() {
+ this.setAvatar('');
+ },
'click .js-delete-avatar': function() {
Avatars.remove(this.currentData()._id);
}