From 4561bd4d6a3188ad2999874ed4f78d473acb7d1b Mon Sep 17 00:00:00 2001 From: Scott Burkett Date: Tue, 9 Aug 2016 14:10:25 -0400 Subject: [PATCH] Added callback function Added callback function that be called once the tag cloud has been generated and rendered. --- jquery.tagcloud.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jquery.tagcloud.js b/jquery.tagcloud.js index 4e5d5a3..f8bb728 100644 --- a/jquery.tagcloud.js +++ b/jquery.tagcloud.js @@ -54,7 +54,7 @@ return toHex(rgb); }; - $.fn.tagcloud = function(options) { + $.fn.tagcloud = function(options, callback) { var opts = $.extend({}, $.fn.tagcloud.defaults, options); var tagWeights = this.map(function(){ @@ -74,7 +74,8 @@ if (opts.color) { colorIncr = colorIncrement (opts.color, range); } - return this.each(function() { + + this.each(function() { var weighting = $(this).attr("rel") - lowest; if (opts.size) { $(this).css({"font-size": opts.size.start + (weighting * fontIncr) + opts.size.unit}); @@ -83,6 +84,11 @@ $(this).css({"color": tagColor(opts.color, colorIncr, weighting)}); } }); + + // Make sure the callback is a function before calling it! + if (typeof callback === "function") { + callback(options); + } }; $.fn.tagcloud.defaults = {