From c97ab38e72b9c251a49f78f4fa01bdffab66b42a Mon Sep 17 00:00:00 2001 From: Tim Oxley Date: Sun, 30 Jun 2013 13:57:57 +0800 Subject: [PATCH 1/5] fix closing body tag in readme, add syntax highlighting --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 043a49e..d8f8dce 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,20 @@ FitText makes font-sizes flexible. Use this plugin script on your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element. ## How it works -If you have a small site and don't want to attach jQuery, just attach fittext.js and put this just before (responsive_headline is an header id). - - - +If you have a small site and don't want to attach jQuery, just attach fittext.js and put this just before `` (responsive_headline is an header id). +```html + +``` ### The Compressor The default setting works pretty well, but when it doesn't FitText has one setting you can adjust. If your text resizes poorly or is resizing all hurdy gurdy, you'll want to turn tweak up/down the compressor. It works a little like a guitar amp. - - window.fitText( document.getElementById("responsive_headline"), 1.2 ); // turn the compressor up (font will shrink a bit more aggressively) - window.fitText( document.getElementById("responsive_headline"), 0.8 ); // turn the compressor down (font will shrink less aggressively) - +```html +window.fitText( document.getElementById("responsive_headline"), 1.2 ); // turn the compressor up (font will shrink a bit more aggressively) +window.fitText( document.getElementById("responsive_headline"), 0.8 ); // turn the compressor down (font will shrink less aggressively) +``` This will hopefully give you a level of "control" that might not be pixel perfect, but scales smoothly & nicely. ### Thanks Thanks to Trent, Dave and Reagan for original FitText.js: https://github.com/davatron5000/FitText.js -http://fittextjs.com/ \ No newline at end of file +http://fittextjs.com/ From 8a2e4b540f69cba9fdaf4c891799c40565be7e46 Mon Sep 17 00:00:00 2001 From: Jason Delia Date: Tue, 13 Aug 2013 22:14:29 -0400 Subject: [PATCH 2/5] adding extend function and options for settings --- fittext.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fittext.js b/fittext.js index 966c689..5b1d127 100644 --- a/fittext.js +++ b/fittext.js @@ -19,13 +19,20 @@ else el.attachEvent('on'+type, fn); }; + + var extend = function(obj,ext){ + for(key in ext) + if(ext.hasOwnProperty(key)) + obj[key] = ext[key]; + return obj; + }; - window.fitText = function (el, kompressor) { + window.fitText = function (el, kompressor, options) { - var settings = { + var settings = extend({ 'minFontSize' : -1/0, 'maxFontSize' : 1/0 - }; + },options); var fit = function (el) { var compressor = kompressor || 1; @@ -52,4 +59,4 @@ // return set of elements return el; }; -})(); \ No newline at end of file +})(); From 3c65ae5e6cbb70c17a6594eee1902755b27ab792 Mon Sep 17 00:00:00 2001 From: Claudio Cicali Date: Fri, 12 Dec 2014 12:04:52 +0100 Subject: [PATCH 3/5] Fixes a global leak --- fittext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fittext.js b/fittext.js index 5b1d127..543ac50 100644 --- a/fittext.js +++ b/fittext.js @@ -21,7 +21,7 @@ }; var extend = function(obj,ext){ - for(key in ext) + for(var key in ext) if(ext.hasOwnProperty(key)) obj[key] = ext[key]; return obj; From 66162013966426b3185cf95d3c3beaa62a0d6942 Mon Sep 17 00:00:00 2001 From: Romain WEEGER Date: Sat, 9 May 2015 13:08:20 +0200 Subject: [PATCH 4/5] The css variable is not used --- fittext.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fittext.js b/fittext.js index 543ac50..b129ff5 100644 --- a/fittext.js +++ b/fittext.js @@ -9,10 +9,7 @@ * Date: Tue Aug 09 2011 10:45:54 GMT+0200 (CEST) */ (function(){ - var css = function (el, prop) { - return window.getComputedStyle ? getComputedStyle(el).getPropertyValue(prop) : el.currentStyle[prop]; - }; - + var addEvent = function (el, type, fn) { if (el.addEventListener) el.addEventListener(type, fn, false); From 7c1ceda4f1bc4f7dcb20063168900f839e741fd2 Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Fri, 10 Jul 2015 22:15:52 -0700 Subject: [PATCH 5/5] Support orientationchange event --- fittext.js | 1 + 1 file changed, 1 insertion(+) diff --git a/fittext.js b/fittext.js index 543ac50..3fb79e7 100644 --- a/fittext.js +++ b/fittext.js @@ -48,6 +48,7 @@ // If you have any js library which support Events, replace this part // and remove addEvent function (or use original jQuery version) addEvent(window, 'resize', resizer); + addEvent(window, 'orientationchange', resizer); }; if (el.length)