Sha256: d2b4cfd9a0d18704d7e61474cbd73b591e9bc96707c0ecffb3fc4caa0db717a8

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

/*global jQuery */
/*!	
* FitText.js 1.0
*
* 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 );

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
survivalkit-1.0.beta.15 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.14 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.13 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.12 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.11 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.10 templates/project/sources/FitText/jquery.fittext.js
survivalkit-1.0.beta.9 templates/project/sources/FitText/jquery.fittext.js