From b7ac17311d618ffa493a9cba051d3b7075b6577c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Zral=C3=BD?= Date: Sat, 14 Dec 2013 01:31:14 +0100 Subject: [PATCH] Possibility to set compressor ratios individually for every element By setting data-fittext-kompressor attribute. For example, data-fittext-kompressor="0.5" sets compressor value for the element to 0.5 --- jquery.fittext.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.fittext.js b/jquery.fittext.js index 080b82e..d04be28 100644 --- a/jquery.fittext.js +++ b/jquery.fittext.js @@ -24,10 +24,13 @@ // Store the object var $this = $(this); + + // Set particular compressor for the object according to its data value + var compressator = $this.data('fittext-kompressor') || compressor; // 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))); + $this.css('font-size', Math.max(Math.min($this.width() / (compressator*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize))); }; // Call once to set.