This is my first jQuery plugin. Can I get some pointers? It's currently not working...
; (function($) {
$.fn.tagCloud = function(options) {
options = options || {};
var maxPercent = options['maxPercent'] || 150;
var minPercent = options['minPercent'] || 100;
var retrieveCount = options['retrieveCount'] || function(element) { return $(element).attr('rel'); };
var apply = options['apply'] || function(element, size) { $(element).attr('style', 'font-size:' + size + '%;'); };
var max = null;
var min = null;
var tagElements = this;
tagElements.each(function(element) {
count = retrieveCount(element);
max = (max == null || count > max ? count : max);
min = (min == null || min > count ? count : min);
});
var multiplier = (maxPercent - minPercent) / (max - min);
tagElements.each(function(element) {
count = retrieveCount(count);
size = (minPercent + (count - min) * multiplier);
apply(element, size);
});
}
})(jQuery);
Usage: $('a.tag').tagCloud();