From: Morris Jobke Date: Wed, 28 Aug 2013 19:54:20 +0000 (+0200) Subject: calculate fontsize and line-height X-Git-Tag: v6.0.0alpha2~252^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=067815099f909a20fd6cf79af451dedc53bf4c54;p=nextcloud-server.git calculate fontsize and line-height --- diff --git a/core/js/placeholder.js b/core/js/placeholder.js index 6a1c653b587..318fe48ffa4 100644 --- a/core/js/placeholder.js +++ b/core/js/placeholder.js @@ -34,7 +34,7 @@ * * Which will result in: * - *
T
+ *
T
* */ @@ -45,7 +45,8 @@ red = parseInt(hash.substr(0,10), 16) / maxRange * 256, green = parseInt(hash.substr(10,10), 16) / maxRange * 256, blue = parseInt(hash.substr(20,10), 16) / maxRange * 256, - rgb = [Math.floor(red), Math.floor(green), Math.floor(blue)]; + rgb = [Math.floor(red), Math.floor(green), Math.floor(blue)], + height = this.height(); this.css('background-color', 'rgb(' + rgb.join(',') + ')'); // CSS rules @@ -53,6 +54,10 @@ this.css('font-weight', 'bold'); this.css('text-align', 'center'); + // calculate the height + this.css('line-height', height + 'px'); + this.css('font-size', (height * 0.55) + 'px'); + if(seed !== null && seed.length) { this.html(seed[0].toUpperCase()); }