Permalink
Browse files

changed version number to 1.3.0

  • Loading branch information...
1 parent 36f15a7 commit b63f52495e5eab285114f562e34f6237b7920034 @DanielHoffmann committed Jan 6, 2015
Showing with 21 additions and 21 deletions.
  1. +21 −21 jquery-bigtext.js
View
@@ -1,7 +1,7 @@
/*
-jQuery BigText v1.2.0, May 2014
+jQuery BigText v1.3.0, May 2014
-Usage:
+Usage:
$("#div").bigText({
rotateText: {Number}, (null)
fontSizeFactor: {Number}, (0.8)
@@ -43,7 +43,7 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
(function($){
- "use strict";
+ "use strict";
var defaultOptions= {
rotateText: null,
fontSizeFactor: 0.8,
@@ -54,16 +54,16 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
textAlign: "center",
whiteSpace: "nowrap"
};
-
+
$.fn.bigText= function(options) {
return this.each(function() {
options= $.extend({}, defaultOptions, options);
var $this= $(this);
var $parent= $this.parent();
-
+
//hides the element to prevent "flashing"
$this.css("visibility", "hidden");
-
+
$this.css({
display: "inline-block",
clear: "both",
@@ -78,14 +78,14 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
left: "50%",
top: "50%"
});
-
+
var parentPadding= {
left: parseInt($parent.css('padding-left')),
top: parseInt($parent.css('padding-top')),
right: parseInt($parent.css('padding-right')),
bottom: parseInt($parent.css('padding-bottom'))
};
-
+
var box= {
width: $this.outerWidth(),
height: $this.outerHeight()
@@ -108,43 +108,43 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
var cos= Math.abs(Math.cos(options.rotateText * Math.PI / 180));
box.width= $this.outerWidth() * cos + $this.outerHeight() * sin;
box.height= $this.outerWidth() * sin + $this.outerHeight() * cos;
- }
-
+ }
+
var widthFactor= ($parent.innerWidth() - parentPadding.left - parentPadding.right) / box.width;
var heightFactor= ($parent.innerHeight() - parentPadding.top - parentPadding.bottom) / box.height;
var lineHeight;
-
+
if (options.limitingDimension.toLowerCase() === "width") {
lineHeight= Math.floor(widthFactor * 1000);
$parent.height(lineHeight);
} else if (options.limitingDimension.toLowerCase() === "height") {
lineHeight= Math.floor(heightFactor * 1000);
} else if (widthFactor < heightFactor)
- lineHeight= Math.floor(widthFactor * 1000);
+ lineHeight= Math.floor(widthFactor * 1000);
else if (widthFactor >= heightFactor)
lineHeight= Math.floor(heightFactor * 1000);
-
+
var fontSize= lineHeight * options.fontSizeFactor;
if (options.maximumFontSize !== null && fontSize > options.maximumFontSize) {
fontSize= options.maximumFontSize;
lineHeight= fontSize / options.fontSizeFactor;
}
-
-
+
+
$this.css({
'font-size': Math.floor(fontSize) + "px",
'line-height': Math.ceil(lineHeight) + "px",
'margin-bottom': "0px",
'margin-right': "0px"
});
-
+
if (options.limitingDimension.toLowerCase() === "height") {
//this option needs the font-size to be set already so $this.width() returns the right size
//this +4 is to compensate the rounding erros that can occur due to the calls to Math.floor in the centering code
$parent.width(($this.width() + 4) + "px");
}
var endCSS= {};
-
+
switch(options.verticalAlign.toLowerCase()) {
case "top":
endCSS['top']= "0%";
@@ -157,7 +157,7 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
endCSS['margin-top']= Math.floor((-$this.innerHeight() / 2)) + "px";
break;
}
-
+
switch(options.horizontalAlign.toLowerCase()) {
case "left":
endCSS['left']= "0%";
@@ -170,11 +170,11 @@ Copyright (C) 2013 Daniel Hoffmann Bernardes, Ícaro Technologies
endCSS['margin-left']= Math.floor((-$this.innerWidth() / 2)) + "px";
break;
}
-
-
+
+
$this.css(endCSS);
//shows the element after the work is done
$this.css("visibility", "visible");
});
- }
+ }
})(jQuery);

0 comments on commit b63f524

Please sign in to comment.