textarea_grow jquery plugin
[MojoFacets.git] / public / js / jquery.textarea_grow.js
diff --git a/public/js/jquery.textarea_grow.js b/public/js/jquery.textarea_grow.js
new file mode 100644 (file)
index 0000000..8a0ef57
--- /dev/null
@@ -0,0 +1,16 @@
+jQuery.fn.textarea_grow = function(){
+       return this.each(function(){
+               var rows = this.rows;
+               console.debug( 'textarea_grow', rows, this );
+               var grow = function(ta) {
+               var lines = ta.value.split('\n').length;
+                       if ( lines > rows ) {
+                               ta.rows = lines;
+                               //console.debug('keyup', lines, rows, ta );
+                       }
+               };
+               grow(this);
+               this.onkeyup = function() { grow(this) };
+       });
+};
+