Merge pull request #6591 from nextcloud/unify-appearance-of-avatars-for-undefined-and-unknown-users

Unify appearance of avatars for undefined and unknown users
This commit is contained in:
Roeland Jago Douma 2017-09-24 13:12:58 +02:00 committed by GitHub
commit 4ee731c1ab
2 changed files with 12 additions and 4 deletions

View File

@ -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();

View File

@ -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() {