]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add a default size to the avatar placeholders
authorRoeland Jago Douma <rullzer@owncloud.com>
Thu, 17 Dec 2015 06:56:02 +0000 (07:56 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Thu, 17 Dec 2015 15:30:23 +0000 (16:30 +0100)
This removed the need to do an avatar request on the "empty" row in the
user settings.

core/js/avatar.js
core/js/placeholder.js
settings/js/users/users.js

index 10214c35fbe55f18955fac1892e280c8853e6aa2..78b8c2a8cf5f97edeece9cf3dfc185bed8dbaeaa 100644 (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);
-       });
 });
index 74bb9b1881d0a3f08fa2ecef6876c6e34e40f575..26eb3507d7b21659ca5f5db0d3bba8708526773c 100644 (file)
  */
 
 (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');
index 9b95408dd0a8958e2db1c22d9215d449fd81abe9..aea940535722d15b61203cc0cc9931fba6012a11 100644 (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);
                        }
                }