From 6248bad0f7b23c16049045ea150a11948b0ebeb1 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 17 Dec 2015 07:56:02 +0100 Subject: [PATCH 1/2] 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. --- core/js/avatar.js | 4 ---- core/js/placeholder.js | 8 ++++++-- settings/js/users/users.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/js/avatar.js b/core/js/avatar.js index 10214c35fbe..78b8c2a8cf5 100644 --- a/core/js/avatar.js +++ b/core/js/avatar.js @@ -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); - }); }); diff --git a/core/js/placeholder.js b/core/js/placeholder.js index 74bb9b1881d..26eb3507d7b 100644 --- a/core/js/placeholder.js +++ b/core/js/placeholder.js @@ -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'); diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 9b95408dd0a..aea94053572 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -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); } } From c64e827f00a7958da57a7a6d5aa22eb0900c167b Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 17 Dec 2015 16:32:18 +0100 Subject: [PATCH 2/2] Since avatar.js is now essentially empty remove it --- core/js/avatar.js | 5 ----- lib/private/template.php | 1 - 2 files changed, 6 deletions(-) delete mode 100644 core/js/avatar.js diff --git a/core/js/avatar.js b/core/js/avatar.js deleted file mode 100644 index 78b8c2a8cf5..00000000000 --- a/core/js/avatar.js +++ /dev/null @@ -1,5 +0,0 @@ -$(document).ready(function(){ - if (OC.currentUser) { - - } -}); diff --git a/lib/private/template.php b/lib/private/template.php index 04d6a906880..c2528c26851 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -119,7 +119,6 @@ class OC_Template extends \OC\Template\Base { // avatars if (\OC::$server->getSystemConfig()->getValue('enable_avatars', true) === true) { - \OC_Util::addScript('avatar', null, true); \OC_Util::addScript('jquery.avatar', null, true); \OC_Util::addScript('placeholder', null, true); }