Add a default size to the avatar placeholders

This removed the need to do an avatar request on the "empty" row in the
user settings.
This commit is contained in:
Roeland Jago Douma 2015-12-17 07:56:02 +01:00
parent 3818a055b9
commit 6248bad0f7
3 changed files with 7 additions and 7 deletions

View File

@ -2,8 +2,4 @@ $(document).ready(function(){
if (OC.currentUser) {
}
// User settings
$.each($('td.avatar .avatardiv'), function(i, element) {
$(element).avatar($(element).parent().parent().data('uid'), 32);
});
});

View File

@ -47,16 +47,20 @@
*/
(function ($) {
$.fn.imageplaceholder = function(seed, text) {
$.fn.imageplaceholder = function(seed, text, size) {
// set optional argument "text" to value of "seed" if undefined
text = text || seed;
var hash = md5(seed),
maxRange = parseInt('ffffffffffffffffffffffffffffffff', 16),
hue = parseInt(hash, 16) / maxRange * 256,
height = this.height();
height = this.height() || size || 32;
this.css('background-color', 'hsl(' + hue + ', 90%, 65%)');
// Placeholders are square
this.height(height);
this.width(height);
// CSS rules
this.css('color', '#fff');
this.css('font-weight', 'normal');

View File

@ -68,7 +68,7 @@ var UserList = {
if (user.isAvatarAvailable === true) {
$('div.avatardiv', $tr).avatar(user.name, 32, undefined, undefined, undefined, user.displayname);
} else {
$('div.avatardiv', $tr).imageplaceholder(user.displayname);
$('div.avatardiv', $tr).imageplaceholder(user.displayname, undefined, 32);
}
}