diff options
author | Brandon Aaron <brandon.aaron@gmail.com> | 2013-04-03 13:14:58 -0500 |
---|---|---|
committer | Brandon Aaron <brandon.aaron@gmail.com> | 2013-04-03 13:14:58 -0500 |
commit | 2c1d38b9021c6a93262cc320260088e529ea0260 (patch) | |
tree | ef240fecd54b254a34169e4c4801afca94ee4bfd /jquery.expandable.js | |
parent | 44390d5f7af419c334797930010117164f6d9ed4 (diff) | |
download | jquery-expandable-master.zip jquery-expandable-master.tar.gz jquery-expandable-master.tar.bz2 |
Add update event that can be triggered to force a recheck of the textarea. Prevent re-running the plugin multiple times for one textarea. Bump version 1.1.4.HEAD1.1.4origin/masterorigin/HEADmaster
Diffstat (limited to 'jquery.expandable.js')
-rw-r--r-- | jquery.expandable.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/jquery.expandable.js b/jquery.expandable.js index ba7f44e..f4179a6 100644 --- a/jquery.expandable.js +++ b/jquery.expandable.js @@ -1,7 +1,7 @@ /*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * - * Version 1.1.3 + * Version 1.1.4 * * Contributions by: * - Karl Swedberg @@ -30,8 +30,14 @@ }, givenOptions); return this.filter('textarea').each(function() { - var $this = $(this).css({ display: 'block', overflow: 'hidden' }), - minHeight = $this.height(), + var $this = $(this); + + if ($this.data('expandable') === true) { return; } // already setup this textarea + + // Set some initial style requirements + $this.css({ display: 'block', overflow: 'hidden' }); + + var minHeight = $this.height(), heightDiff = this.offsetHeight - minHeight, rowSize = ( parseInt($this.css('lineHeight'), 10) || parseInt($this.css('fontSize'), 10) ), // $mirror is used for determining the height of the text within the textarea @@ -48,8 +54,15 @@ // copy styles from textarea to mirror to mirror the textarea as best possible mirror($this, $mirror); - // setup events $this + // set data so we know we've already setup on this + .data('expandable', true) + // setup events + // custom event to force a recheck programatically + // use by calling $('textarea').trigger('update'); + .bind('update.expandable', function(event) { + check(); + }) .bind('mouseup', function(event) { // check if width has changed if ($this.width() !== $mirror.width()) { |