From 1cdbd31a72568c6d6fd5424503219d655d25eacd Mon Sep 17 00:00:00 2001 From: weiweitop Date: Wed, 19 Feb 2020 17:38:17 +0800 Subject: [PATCH] add an option [background] default false - true: apply color range to background color - false: apply color range to font color --- jquery.tagcloud.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jquery.tagcloud.js b/jquery.tagcloud.js index 4e5d5a3..66186ae 100644 --- a/jquery.tagcloud.js +++ b/jquery.tagcloud.js @@ -80,13 +80,19 @@ $(this).css({"font-size": opts.size.start + (weighting * fontIncr) + opts.size.unit}); } if (opts.color) { - $(this).css({"color": tagColor(opts.color, colorIncr, weighting)}); + if(opts.background){ + $(this).css({"backgroundColor": tagColor(opts.color, colorIncr, weighting)}); + }else{ + $(this).css({"color": tagColor(opts.color, colorIncr, weighting)}); + } + } }); }; $.fn.tagcloud.defaults = { - size: {start: 14, end: 18, unit: "pt"} + size: {start: 14, end: 18, unit: "pt"}, + background: false }; })(jQuery);