Skip to content

Commit

Permalink
minor code organization change
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmoore committed Jun 18, 2013
1 parent 17f6fa9 commit 3f15434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion jquery.autosize-min.js

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

21 changes: 10 additions & 11 deletions jquery.autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@
maxHeight,
minHeight,
boxOffset = 0,
callback = $.isFunction(options.callback);
callback = $.isFunction(options.callback),
originalStyles = {
height: ta.style.height,
overflow: ta.style.overflow,
overflowY: ta.style.overflowY,
wordWrap: ta.style.wordWrap,
resize: ta.style.resize
};

if ($ta.data('autosize')) {
// exit if autosize has already been applied, or if the textarea is the mirror element.
return;
}
$ta.data('autosize', true);

if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
boxOffset = $ta.outerHeight() - $ta.height();
Expand All @@ -69,15 +77,6 @@
// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());

// Save the original styles in case autosize is removed
$ta.data('autosize', {
height: ta.style.height,
overflow: ta.style.overflow,
overflowY: ta.style.overflowY,
wordWrap: ta.style.wordWrap,
resize: ta.style.resize
});

$ta.css({
overflow: 'hidden',
overflowY: 'hidden',
Expand Down Expand Up @@ -219,7 +218,7 @@
$ta
.off('autosize')
.off('.autosize')
.css($ta.data('autosize'))
.css(originalStyles)
.removeData('autosize');
});

Expand Down

0 comments on commit 3f15434

Please sign in to comment.