From 0d90eaed55175d4c070b116e87fc0b03a679684f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 14 Aug 2018 12:20:03 +0200 Subject: [PATCH] Set username as title/alt for avatar images --- app/modules/components/avatar/avatar.directive.coffee | 6 ++++-- app/modules/services/avatar.service.coffee | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/modules/components/avatar/avatar.directive.coffee b/app/modules/components/avatar/avatar.directive.coffee index 5656a8d4..05ea9d85 100644 --- a/app/modules/components/avatar/avatar.directive.coffee +++ b/app/modules/components/avatar/avatar.directive.coffee @@ -28,13 +28,15 @@ AvatarDirective = (avatarService) -> avatar = avatarService.getAvatar(user, attributeName) el.attr('src', avatar.url) + el.attr('title', "#{avatar.username}") + el.attr('alt', "#{avatar.username}") el.css('background', avatar.bg or "") return { link: link scope: { - avatar: "=tgAvatar" - avatarBig: "=tgAvatarBig" + avatar: "=tgAvatar" + avatarBig: "=tgAvatarBig" } } diff --git a/app/modules/services/avatar.service.coffee b/app/modules/services/avatar.service.coffee index 17657aeb..f20e7a1a 100644 --- a/app/modules/services/avatar.service.coffee +++ b/app/modules/services/avatar.service.coffee @@ -46,6 +46,7 @@ class AvatarService getUnnamed: () -> return { url: "/#{window._version}/images/unnamed.png" + username: '' } getAvatar: (user, type) -> @@ -61,9 +62,11 @@ class AvatarService if user instanceof Immutable.Map gravatar = user.get('gravatar_id') photo = user.get(avatarParamName) + username = "@#{user.get('username')}" else gravatar = user.gravatar_id photo = user[avatarParamName] + username = "@#{user.username}" return @.getUnnamed() if !gravatar @@ -77,7 +80,8 @@ class AvatarService return { url: root + logo.src, - bg: logo.color + bg: logo.color, + username: username } else root = location.protocol + '//' + location.host @@ -87,7 +91,8 @@ class AvatarService return { url: 'https://www.gravatar.com/avatar/' + gravatar + "?s=200&d=" + logoUrl, - bg: logo.color + bg: logo.color, + username: username } angular.module("taigaCommon").service("tgAvatarService", ["$tgConfig", AvatarService])