forked from jerryluk/jquery.autogrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.autogrow-min.js
1 lines (1 loc) · 1.09 KB
/
jquery.autogrow-min.js
1
(function(a){a.fn.autogrow=function(c){var g={expandTolerance:1};c=a.extend(g,c);var d=!(a.browser.msie||a.browser.opera);function b(l){var j=a(l.target||l),i=j.val().length,k=j.innerWidth();if(i!=j.data("autogrow-length")||k!=j.data("autogrow-width")){if(d&&(i<j.data("autogrow-length")||k!=j.data("autogrow-width"))){j.css("height","0px")}var h=Math.max(j.data("autogrow-min"),Math.ceil(Math.min(j.attr("scrollHeight")+c.expandTolerance*j.data("autogrow-line-height"),j.data("autogrow-max"))));j.css("overflow",(j.attr("scrollHeight")>h?"auto":"hidden"));j.css("height",h+"px")}return j}function f(h){var i=parseInt(h,10);return isNaN(i)?null:i}function e(h){h.data("autogrow-min",c.minHeight||f(h.css("min-height"))||0);h.data("autogrow-max",c.maxHeight||f(h.css("max-height"))||99999);h.data("autogrow-line-height",c.lineHeight||f(h.css("line-height")));b(h)}this.each(function(){var h=a(this);if(!h.data("autogrow-initialized")){h.css("padding-top",0).css("padding-bottom",0);h.bind("keyup",b).bind("focus",b);h.data("autogrow-initialized",true)}e(h);setTimeout(function(){e(h)},100)});return this}})(jQuery);