From 067815099f909a20fd6cf79af451dedc53bf4c54 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 28 Aug 2013 21:54:20 +0200 Subject: calculate fontsize and line-height --- core/js/placeholder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/js/placeholder.js') 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()); } -- cgit v1.2.3