diff --git a/autosize.jquery.json b/autosize.jquery.json
index 43c9cda..659ead1 100644
--- a/autosize.jquery.json
+++ b/autosize.jquery.json
@@ -7,7 +7,7 @@
"textarea",
"ui"
],
- "version": "1.16.16",
+ "version": "1.16.17",
"author": {
"name": "Jack Moore",
"url": "http://www.jacklmoore.com",
diff --git a/component.json b/component.json
index 15f0713..2b5c5bf 100644
--- a/component.json
+++ b/component.json
@@ -1,6 +1,6 @@
{
"name": "jquery-autosize",
- "version": "1.16.16",
+ "version": "1.16.17",
"main": "./jquery.autosize.js",
"dependencies": {
"jquery": ">=1.7"
diff --git a/jquery.autosize-min.js b/jquery.autosize-min.js
index 55f3909..78d6d11 100644
--- a/jquery.autosize-min.js
+++ b/jquery.autosize-min.js
@@ -1,7 +1,7 @@
/*!
- jQuery Autosize v1.16.16
+ jQuery Autosize v1.16.17
(c) 2013 Jack Moore - jacklmoore.com
- updated: 2013-06-11
+ updated: 2013-06-12
license: http://www.opensource.org/licenses/mit-license.php
*/
-(function(t){var e,i,o={className:"autosizejs",append:"",callback:!1,resizeDelay:10},n="hidden",s="border-box",a="lineHeight",r='',l=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],c="oninput",d="onpropertychange",h=t(r).data("autosize",!0)[0];h.style.lineHeight="99px","99px"===t(h).css(a)&&l.push(a),h.style.lineHeight="",e=void 0!==h.getBoundingClientRect().width,t.fn.autosize=function(a){return a=t.extend({},o,a||{}),h.parentNode!==document.body&&t(document.body).append(h),this.each(function(){function o(){if(i=w,h.className=a.className,u=parseInt(f.css("maxHeight"),10),t.each(l,function(t,e){h.style[e]=f.css(e)}),c in w){var e=w.style.width;w.style.width="0px",w.offsetWidth,w.style.width=e}}function r(){var s,r,l,c;i!==w&&o(),h.value=w.value+a.append,h.style.overflowY=w.style.overflowY,l=parseInt(w.style.height,10),e?(c=w.getBoundingClientRect().width,t.each(t(w).css(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"]),function(){c-=parseInt(this,10)}),h.style.width=c+"px"):h.style.width=Math.max(f.width(),0)+"px",h.scrollTop=0,h.scrollTop=9e4,s=h.scrollTop,u&&s>u?(s=u,r="scroll"):p>s&&(s=p),s+=b,w.style.overflowY=r||n,l!==s&&(w.style.height=s+"px",x&&a.callback.call(w,w))}var p,u,g,w=this,f=t(w),b=0,x=t.isFunction(a.callback);if(!f.data("autosize")){if((f.css("box-sizing")===s||f.css("-moz-box-sizing")===s||f.css("-webkit-box-sizing")===s)&&(b=f.outerHeight()-f.height()),p=Math.max(parseInt(f.css("minHeight"),10)-b||0,f.height()),g="none"===f.css("resize")||"vertical"===f.css("resize")?"none":"horizontal",f.css({overflow:n,overflowY:n,wordWrap:"break-word",resize:g}).data("autosize",!0),d in w?c in w?w[c]=w.onkeyup=r:w[d]=function(){"value"===event.propertyName&&r()}:w[c]=r,a.resizeDelay!==!1){var y,z=t(w).width();t(window).on("resize.autosize",function(){clearTimeout(y),y=setTimeout(function(){t(w).width()!==z&&r()},parseInt(a.resizeDelay,10))})}f.on("autosize",r),r()}})}})(window.jQuery||window.Zepto);
\ No newline at end of file
+(function(e){var t,i={className:"autosizejs",append:"",callback:!1,resizeDelay:10},o="hidden",n="border-box",s="lineHeight",a=void 0!==window.getComputedStyle,r='',l=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],d="oninput",c="onpropertychange",h=e(r).data("autosize",!0)[0];h.style.lineHeight="99px","99px"===e(h).css(s)&&l.push(s),h.style.lineHeight="",e.fn.autosize=function(s){return s=e.extend({},i,s||{}),h.parentNode!==document.body&&e(document.body).append(h),this.each(function(){function i(){if(t=g,h.className=s.className,u=parseInt(f.css("maxHeight"),10),e.each(l,function(e,t){h.style[t]=f.css(t)}),d in g){var i=g.style.width;g.style.width="0px",g.offsetWidth,g.style.width=i}}function r(){var n,r,l,d,c;t!==g&&i(),h.value=g.value+s.append,h.style.overflowY=g.style.overflowY,l=parseInt(g.style.height,10),a?(c=window.getComputedStyle(g),d=g.getBoundingClientRect().width,e.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(e,t){d-=parseInt(c[t],10)}),h.style.width=d+"px"):h.style.width=Math.max(f.width(),0)+"px",h.scrollTop=0,h.scrollTop=9e4,n=h.scrollTop,u&&n>u?(n=u,r="scroll"):p>n&&(n=p),n+=b,g.style.overflowY=r||o,l!==n&&(g.style.height=n+"px",y&&s.callback.call(g,g))}var p,u,w,g=this,f=e(g),b=0,y=e.isFunction(s.callback);if(!f.data("autosize")){if((f.css("box-sizing")===n||f.css("-moz-box-sizing")===n||f.css("-webkit-box-sizing")===n)&&(b=f.outerHeight()-f.height()),p=Math.max(parseInt(f.css("minHeight"),10)-b||0,f.height()),w="none"===f.css("resize")||"vertical"===f.css("resize")?"none":"horizontal",f.css({overflow:o,overflowY:o,wordWrap:"break-word",resize:w}).data("autosize",!0),c in g?d in g?g[d]=g.onkeyup=r:g[c]=function(){"value"===event.propertyName&&r()}:g[d]=r,s.resizeDelay!==!1){var x,z=e(g).width();e(window).on("resize.autosize",function(){clearTimeout(x),x=setTimeout(function(){e(g).width()!==z&&r()},parseInt(s.resizeDelay,10))})}f.on("autosize",r),r()}})}})(window.jQuery||window.Zepto);
\ No newline at end of file
diff --git a/jquery.autosize.js b/jquery.autosize.js
index f41e1d7..1b0a816 100644
--- a/jquery.autosize.js
+++ b/jquery.autosize.js
@@ -1,7 +1,7 @@
/*!
- jQuery Autosize v1.16.16
+ jQuery Autosize v1.16.17
(c) 2013 Jack Moore - jacklmoore.com
- updated: 2013-06-11
+ updated: 2013-06-12
license: http://www.opensource.org/licenses/mit-license.php
*/
(function ($) {
@@ -15,7 +15,7 @@
hidden = 'hidden',
borderBox = 'border-box',
lineHeight = 'lineHeight',
- useSubpixels,
+ useSubpixels = window.getComputedStyle !== undefined,
// border:0 is unnecessary, but avoids a bug in FireFox on OSX
copy = '',
@@ -47,9 +47,6 @@
}
mirror.style.lineHeight = '';
- // test for subpixel rendering
- useSubpixels = mirror.getBoundingClientRect().width !== undefined;
-
$.fn.autosize = function (options) {
options = $.extend({}, defaults, options || {});
@@ -115,7 +112,7 @@
// Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient.
function adjust() {
- var height, overflow, original, width;
+ var height, overflow, original, width, style;
if (mirrored !== ta) {
initMirror();
@@ -126,10 +123,11 @@
original = parseInt(ta.style.height,10);
if (useSubpixels) {
+ style = window.getComputedStyle(ta);
// The mirror width much exactly match the textarea width, so using getBoundingClientRect because it doesn't round the subpixel value.
width = ta.getBoundingClientRect().width;
- $.each($(ta).css(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth']), function(){
- width -= parseInt(this, 10);
+ $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,property){
+ width -= parseInt(style[property], 10);
});
mirror.style.width = width + 'px';
}
diff --git a/readme.md b/readme.md
index 13cd26e..03d6d67 100644
--- a/readme.md
+++ b/readme.md
@@ -4,6 +4,9 @@ Small jQuery plugin to allow dynamic resizing of textarea height, so that it gro
## Changelog
+### v1.16.17 - 2013/6/12
+* Fixed a compatability issue with jQuery versions before 1.9 introduced in the previous update.
+
### v1.16.16 - 2013/6/11
* Fixed an issue where the calculated height might be slightly off in modern browsers when the width of the textarea has a subpixel value.