summaryrefslogtreecommitdiffstats
path: root/jquery.expandable.js
diff options
context:
space:
mode:
authorPistos <github.pistos@purepistos.net>2012-06-15 13:43:19 -0400
committerPistos <github.pistos@purepistos.net>2012-06-15 13:43:19 -0400
commit8d835d10d7ab6ee6ed6aa88f982a3ee3cf74c860 (patch)
treec7447207f954fb1b0a84fddd90ddfc199593ca11 /jquery.expandable.js
parented30e90320ee3b4151c178e88c9eafc7242f67a0 (diff)
downloadjquery-expandable-8d835d10d7ab6ee6ed6aa88f982a3ee3cf74c860.zip
jquery-expandable-8d835d10d7ab6ee6ed6aa88f982a3ee3cf74c860.tar.gz
jquery-expandable-8d835d10d7ab6ee6ed6aa88f982a3ee3cf74c860.tar.bz2
maxRows option.
Diffstat (limited to 'jquery.expandable.js')
-rw-r--r--jquery.expandable.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/jquery.expandable.js b/jquery.expandable.js
index 3c38d0c..4b7b50a 100644
--- a/jquery.expandable.js
+++ b/jquery.expandable.js
@@ -16,7 +16,8 @@ $.fn.extend({
interval: 750,
within: 1,
by: 2,
- init: false
+ maxRows: 20,
+ init: false
}, givenOptions);
return this.filter('textarea').each(function() {
@@ -57,7 +58,11 @@ $.fn.extend({
// adjust height if needed by either growing or shrinking the text area to within the specified bounds
if ( availableRows <= options.within ) {
- newHeight = rowSize * (usedRows + Math.max(availableRows, 0) + options.by);
+ var numRows = usedRows + Math.max(availableRows, 0) + options.by;
+ if( numRows > options.maxRows ) {
+ numRows = options.maxRows;
+ }
+ newHeight = rowSize * numRows;
$this.stop().animate({ height: newHeight }, options.duration);
} else if ( availableRows > options.by + options.within ) {
newHeight = Math.max( height - (rowSize * (availableRows - (options.by + options.within))), minHeight );