]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make it possible to have a different color than the username for placeholder
authorkondou <kondou@ts.unde.re>
Wed, 25 Sep 2013 10:57:41 +0000 (12:57 +0200)
committerkondou <kondou@ts.unde.re>
Wed, 25 Sep 2013 10:57:41 +0000 (12:57 +0200)
core/js/placeholder.js

index d63730547d7986324f33e5dc15577bea2748feb7..3c7b11ef468eaa27d56dd5a8df5526a7e8a541b0 100644 (file)
  *
  * <div id="albumart" style="background-color: hsl(123, 90%, 65%); ... ">T</div>
  *
+ * You may also call it like this, to have a different background, than the seed:
+ *
+ * $('#albumart').placeholder('The Album Title', 'Album Title');
+ *
+ * Resulting in:
+ *
+ * <div id="albumart" style="background-color: hsl(123, 90%, 65%); ... ">A</div>
+ *
  */
 
 (function ($) {
-       $.fn.placeholder = function(seed) {
+       $.fn.placeholder = function(seed, text) {
+               if (typeof(text) === "undefined") {
+                       text = seed;
+               }
+
                var hash = md5(seed),
                        maxRange = parseInt('ffffffffffffffffffffffffffffffff', 16),
                        hue = parseInt(hash, 16) / maxRange * 256,
@@ -56,7 +68,7 @@
                this.css('font-size', (height * 0.55) + 'px');
 
                if(seed !== null && seed.length) {
-                       this.html(seed[0].toUpperCase());
+                       this.html(text[0].toUpperCase());
                }
        };
 }(jQuery));