(function(){var b=angular.module("monospaced.elastic",[]),a=["paddingTop","paddingRight","paddingBottom","paddingLeft","fontSize","lineHeight","fontFamily","width","fontWeight","border-top-width","border-right-width","border-bottom-width","border-left-width","borderTopStyle","borderTopColor","borderRightStyle","borderRightColor","borderBottomStyle","borderBottomColor","borderLeftStyle","borderLeftColor"];b.directive("msdElastic",function(){return{restrict:"A, C",link:function(r,j){var d=j[0];if(d.nodeName!=="TEXTAREA"){return}var g=document.createElement("div"),e=angular.element(g).css({position:"absolute",visibility:"hidden","word-wrap":"break-word","white-space":"pre-wrap"}),c=getComputedStyle(d),m=parseInt(c.getPropertyValue("line-height"),10)||parseInt(c.getPropertyValue("font-size"),10),p=parseInt(c.getPropertyValue("height"),10)||m*3,o=parseInt(c.getPropertyValue("max-height"),10)||Number.MAX_VALUE,k=0;if(o<0){o=Number.MAX_VALUE}j.parent().append(e);var h=a.length,n;while(h--){n=a[h].toString();e.css(n,c.getPropertyValue(n))}function l(){var i=Math.floor(parseInt(d.offsetWidth,10));if(g.offsetWidth!==i){e.css({width:i+"px"});f(true)}}function q(i,t){var s=Math.floor(parseInt(i,10));if(d.offsetHeight!==s){j.css({height:s+"px",overflow:t})}}function f(u){var t=j.val().replace(/&/g,"&").replace(/ {2}/g," ").replace(/<|>/g,">").replace(/\n/g,"
");var s=e.html().replace(/
/ig,"
");if(u||t+" "!==s){e.html(t+" ");var v=g.offsetHeight;if(Math.abs((v+m)-d.offsetHeight)>3){var i=v+m;if(i>=o){q(o,"auto")}else{if(i<=p){q(p,"hidden")}else{q(i,"hidden")}}}}}j.css({overflow:"hidden"});j.bind("keyup change cut paste",function(){f()});angular.element(window).bind("resize",l);j.bind("resize",l);j.bind("update",f);j.bind("blur",function(){var i=g.offsetHeight;if(ip){j.css({height:i+"px"})}else{j.css({height:p+"px"})}}});j.bind("input paste",function(){setTimeout(f,250)});f()}}})})();