/*global jquery */ /*! * fittext.js 1.1 * * copyright 2011, dave rupert http://daverupert.com * released under the wtfpl license * http://sam.zoy.org/wtfpl/ * * date: thu may 05 14:23:00 2011 -0600 */ (function( $ ){ $.fn.fittext = function( kompressor, options ) { // setup options var compressor = kompressor || 1, settings = $.extend({ 'minfontsize' : number.negative_infinity, 'maxfontsize' : number.positive_infinity }, options); return this.each(function(){ // store the object var $this = $(this); // resizer() resizes items based on the object width divided by the compressor * 10 var resizer = function () { $this.css('font-size', math.max(math.min($this.width() / (compressor*10), parsefloat(settings.maxfontsize)), parsefloat(settings.minfontsize))); }; // call once to set. resizer(); // call on resize. opera debounces their resize by default. $(window).on('resize', resizer); }); }; })( jquery );