forked from jschr/textillate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan Schroter
committed
Jan 27, 2013
1 parent
ab7af6e
commit 3f01db3
Showing
3 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters