]> source.dussan.org Git - nextcloud-server.git/commitdiff
calculate fontsize and line-height
authorMorris Jobke <morris.jobke@gmail.com>
Wed, 28 Aug 2013 19:54:20 +0000 (21:54 +0200)
committerMorris Jobke <morris.jobke@gmail.com>
Wed, 28 Aug 2013 19:54:20 +0000 (21:54 +0200)
core/js/placeholder.js

index 6a1c653b587af7d7a792b1a8236714dea4fa55eb..318fe48ffa476719937a4c7120892ae833548a2d 100644 (file)
@@ -34,7 +34,7 @@
  *
  * Which will result in:
  *
- * <div id="albumart" style="background-color: rgb(123, 123, 123)">T</div>
+ * <div id="albumart" style="background-color: rgb(123, 123, 123); ... ">T</div>
  *
  */
 
@@ -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
                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());
                }