!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define("jqueryAutobox",o):(e="undefined"!=typeof globalThis?globalThis:e||self).jqueryAutobox=o()}(this,(function(){"use strict"; /** * Autogrow Textareas * jQuery.autobox * * https://github.com/duzun/jquery.autobox * * Copyright (c) 2021 Dumitru Uzun * * @license The MIT license. * @version 3.1.0 * @author DUzun.Me */var e="TEXTAREA",o="autoboxed",t=".dynSiz",r=["autobox","keypress","keyup","click","change","focusin","cut","paste"];function i(i){var n,a,s;function u(e,o){return(!e||(o=parseInt(e,10))&&o<18)&&(e="18px"),e}function f(o){return o.filter(e).add(o.find(e))}function d(e,o){var t=i(e),r=t.outerWidth(),u=t.outerHeight();if(e=t.get(0),o)n&&n!==e&&d(n),a=r,s=u,n=e;else if(n===e&&(s!=u||a!=r))return t.trigger("resize"),a=r,s=u,!0}function p(e){var o,t,r,n=this,a=i(n),s=a.data(),f=s._ab_origs,p=n.style,c=a.val(),h=c.split("\n"),l=a.prop("rows"),w=a.prop("cols"),b=0,g=e&&e.type&&e.data;for(d(a,!0),t=0,o=h.length;tb&&(b=r);if(f)delete(f=s._ab_origs).rest;else{if(a.is(":hidden"))return;if(a.stop(!0),(f=s._ab_origs=[l,w,p.height||a.css("height"),p.width||a.css("width"),a.css("overflow-y"),a.css("overflow-x"),a.css("resize")]).aw=a.attr("width"),f.ah=a.attr("height"),t=0,f.ah||(t|=1),f.aw||(t|=2),0===t||3===t)switch(g&&g.resize||a.prop("resize")||a.attr("resize")||f[6]){case"vertical":t=1;break;case"horizontal":t=2}if(f.ar=t){var x={resize:"none"};1===t&&(x["overflow-y"]="hidden",!f.aw&&(f.aw=f[3]),delete f.ah),2===t&&(x["overflow-x"]="hidden",!f.ah&&(f.ah=f[2]),delete f.aw),a.css(x)}a.data("_ab_origs",f)}c=c.length,h=f.ah||"auto",r=f.aw||"auto",f.nadj=1&~f.ar,b?(b+=5+(b>>4),((o+=l>2||o>1)>l||c0&&(a.prop("rows",Math.max(++l,(t*l/r>>0)-1,o)),s=(t=n.scrollHeight)-(r=n.offsetHeight),f!=n.rows&&u==r)){a.css("overflow-y",""),a.prop("rows",f);break}s>5&&u!=r&&setTimeout(e,16),d(a)}}()}function c(e){var o=i(this),t=e.data;(e=o.data("_ab_origs"))&&(e.rest=!0,setTimeout((function(){e.rest&&(d(o,!0),o.removeData("_ab_origs").prop("rows",e[0]).prop("cols",e[1]).prop("size",e[1]).css({"overflow-y":e[4],"overflow-x":e[5],resize:e[6]}),e={height:u(e[2]),width:e[3]},t.speed?o.animate(e,t.speed,(function(){d(o)})):d(o.css(e)))}),t.delay||250))}function h(e){var o=f(this);if(e){var t={type:"autobox",data:e};o.each((function(e,o){return p.call(o,t)}))}else o.each(p);return this}function l(e){var n=f(this);return e=i.extend({},i.autobox.options,e),n.addClass(o).off(t),i.each(r,(function(o,r){n.on(r+t,e,p)})),e.permanent||n.on("blur.dynSiz",e,c),this}i.fn.autobox=h,i.fn.autoboxOn=function(n,a){var s=this;return a=i.extend({},i.autobox.options,a),n||(n=e),s.off(t,n).addClass(o).on(r.join(".dynSiz ")+t,n,a,p),a.permanent||s.on("blur.dynSiz focusout.dynSiz",n,a,c),s},i.fn.autoboxBind=l,i.fn.bindAutobox=l,i.autobox=function(e,o){return o=i.extend({},i.autobox.options,o),i(e).call(h,o)},i.autobox.options={resize:void 0,permanent:!1,speed:0,delay:250},i.expr[":"].autobox=function(e){return i(e).hasClass(o)}}if("undefined"!=typeof window){var n=window.jQuery||window.Zepto;n&&i(n)}return i})); //# sourceMappingURL=jquery.autobox.min.js.map