Skip to content

Commit

Permalink
Added event for removing autosize from a textarea element:
Browse files Browse the repository at this point in the history
	$('textarea.example').trigger('autosize.destroy');
  • Loading branch information
jackmoore committed Jun 18, 2013
1 parent 1b6ff59 commit 78f8220
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion autosize.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"textarea",
"ui"
],
"version": "1.16.18",
"version": "1.16.19",
"author": {
"name": "Jack Moore",
"url": "http://www.jacklmoore.com",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-autosize",
"version": "1.16.18",
"version": "1.16.19",
"main": "./jquery.autosize.js",
"dependencies": {
"jquery": ">=1.7"
Expand Down
4 changes: 2 additions & 2 deletions jquery.autosize-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 22 additions & 6 deletions jquery.autosize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
jQuery Autosize v1.16.18
jQuery Autosize v1.16.19
(c) 2013 Jack Moore - jacklmoore.com
updated: 2013-06-18
license: http://www.opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -168,18 +168,18 @@
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those occasions. There is no way that I
// know of to detect something like 'cut' in IE9.
ta.oninput = ta.onkeyup = adjust;
$ta.on('input.autosize keyup.autosize', adjust);
} else {
// IE7 / IE8
ta.onpropertychange = function(){
$ta.on('propertychange.autosize', function(){
if(event.propertyName === 'value'){
adjust();
}
};
});
}
} else {
// Modern Browsers
ta.oninput = adjust;
$ta.on('input.autosize', adjust);
}

// Set options.resizeDelay to false if using fixed-width textarea elements.
Expand All @@ -203,7 +203,23 @@

// Event for manual triggering that also forces the styles to update as well.
// Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
$ta.on('autosize.includeStyle', function() { mirrored = null; adjust(); });
$ta.on('autosize.includeStyle', function() {
mirrored = null;
adjust();
});

$ta.on('autosize.destroy', function(){
mirrored = null;
$ta
.off('autosize')
.off('.autosize')
.removeData('autosize')
.css({
overflow: '',
overflowY: '',
height: minHeight
});
});

// Call adjust in case the textarea already contains text.
adjust();
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Small jQuery plugin to allow dynamic resizing of textarea height, so that it gro

## Changelog

### v1.16.19 - 2013/6/18
* Added event for removing autosize from a textarea element:
$('textarea.example').trigger('autosize.destroy');

### v1.16.18 - 2013/6/18
* Added an event for manually triggering resize that also accounts for typographic styles that have changed on the textarea element. Example:
* Added event for manually triggering resize that also accounts for typographic styles that have changed on the textarea element. Example:
$('textarea.example').css('text-indent', 25);
$('textarea.example').trigger('autosize.includeStyle');
* Minor optimization
Expand Down

0 comments on commit 78f8220

Please sign in to comment.