Extract setting the avatar for the unknown user to its own function
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
ea10a1292a
commit
2131e95c61
1 changed files with 7 additions and 4 deletions
|
@ -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,8 +77,7 @@
|
|||
if (typeof(this.data('user')) !== 'undefined') {
|
||||
user = this.data('user');
|
||||
} else {
|
||||
this.imageplaceholder('?');
|
||||
this.css('background-color', '#b9b9b9');
|
||||
setAvatarForUnknownUser(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +117,7 @@
|
|||
$div.imageplaceholder(user, result.data.displayname);
|
||||
} else {
|
||||
// User does not exist
|
||||
$div.imageplaceholder('?');
|
||||
$div.css('background-color', '#b9b9b9');
|
||||
setAvatarForUnknownUser($div);
|
||||
}
|
||||
} else {
|
||||
$div.hide();
|
||||
|
|
Loading…
Reference in a new issue