summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-09-24 13:12:58 +0200
committerGitHub <noreply@github.com>2017-09-24 13:12:58 +0200
commit4ee731c1ab20b3fb62c9e46abcc3ed717b891e59 (patch)
tree954dc6a2063d3492fdcc051699d496d48ff85cbc
parent24a881f75e1f701f9313a8c497e9b34169b01ee6 (diff)
parent2131e95c6157c5614e3412f5b2fa22395c4ea03d (diff)
downloadnextcloud-server-4ee731c1ab20b3fb62c9e46abcc3ed717b891e59.tar.gz
nextcloud-server-4ee731c1ab20b3fb62c9e46abcc3ed717b891e59.zip
Merge pull request #6591 from nextcloud/unify-appearance-of-avatars-for-undefined-and-unknown-users
Unify appearance of avatars for undefined and unknown users
-rw-r--r--core/js/jquery.avatar.js10
-rw-r--r--core/js/tests/specs/jquery.avatarSpec.js6
2 files changed, 12 insertions, 4 deletions
diff --git a/core/js/jquery.avatar.js b/core/js/jquery.avatar.js
index 29d019baea7..fae100fda21 100644
--- a/core/js/jquery.avatar.js
+++ b/core/js/jquery.avatar.js
@@ -48,6 +48,11 @@
(function ($) {
$.fn.avatar = function(user, size, ie8fix, hidedefault, callback, displayname) {
+ var setAvatarForUnknownUser = function(target) {
+ target.imageplaceholder('?');
+ target.css('background-color', '#b9b9b9');
+ };
+
if (typeof(user) !== 'undefined') {
user = String(user);
}
@@ -72,7 +77,7 @@
if (typeof(this.data('user')) !== 'undefined') {
user = this.data('user');
} else {
- this.imageplaceholder('?');
+ setAvatarForUnknownUser(this);
return;
}
}
@@ -112,8 +117,7 @@
$div.imageplaceholder(user, result.data.displayname);
} else {
// User does not exist
- $div.imageplaceholder(user, '?');
- $div.css('background-color', '#b9b9b9');
+ setAvatarForUnknownUser($div);
}
} else {
$div.hide();
diff --git a/core/js/tests/specs/jquery.avatarSpec.js b/core/js/tests/specs/jquery.avatarSpec.js
index dab78500d0b..d7305736690 100644
--- a/core/js/tests/specs/jquery.avatarSpec.js
+++ b/core/js/tests/specs/jquery.avatarSpec.js
@@ -62,10 +62,12 @@ describe('jquery.avatar tests', function() {
it('undefined user', function() {
spyOn($div, 'imageplaceholder');
+ spyOn($div, 'css');
$div.avatar();
expect($div.imageplaceholder).toHaveBeenCalledWith('?');
+ expect($div.css).toHaveBeenCalledWith('background-color', '#b9b9b9');
});
describe('no avatar', function() {
@@ -86,6 +88,7 @@ describe('jquery.avatar tests', function() {
it('show placeholder for non existing user', function() {
spyOn($div, 'imageplaceholder');
+ spyOn($div, 'css');
$div.avatar('foo');
fakeServer.requests[0].respond(
@@ -96,7 +99,8 @@ describe('jquery.avatar tests', function() {
})
);
- expect($div.imageplaceholder).toHaveBeenCalledWith('foo', '?');
+ expect($div.imageplaceholder).toHaveBeenCalledWith('?');
+ expect($div.css).toHaveBeenCalledWith('background-color', '#b9b9b9');
});
it('show no placeholder', function() {