2  * Autogrow Textarea Plugin Version v2.0
 
   3  * http://www.technoreply.com/autogrow-textarea-plugin-version-2-0
 
   5  * Copyright 2011, Jevin O. Sewaruth
 
   9 jQuery.fn.autoGrow = function(){
 
  10         return this.each(function(){
 
  12                 var colsDefault = this.cols;
 
  13                 var rowsDefault = this.rows;
 
  16                 var grow = function() {
 
  20                 var growByRef = function(obj) {
 
  22                         var lines = obj.value.split('\n');
 
  24                         for (var i=lines.length-1; i>=0; --i)
 
  26                                 linesCount += Math.floor((lines[i].length / colsDefault) + 1);
 
  29                         if (linesCount >= rowsDefault)
 
  30                                 obj.rows = linesCount + 1;
 
  32                                 obj.rows = rowsDefault;
 
  35                 var characterWidth = function (obj){
 
  36                         var characterWidth = 0;
 
  39                         var tempCols = obj.cols;
 
  42                         temp1 = obj.offsetWidth;
 
  44                         temp2 = obj.offsetWidth;
 
  45                         characterWidth = temp2 - temp1;
 
  48                         return characterWidth;
 
  52                 this.style.width = "auto";
 
  53                 this.style.height = "auto";
 
  54                 this.style.overflow = "hidden";
 
  55                 this.style.width = ((characterWidth(this) * this.cols) + 6) + "px";