Skip to content

Commit

Permalink
Update the textarea mirror if the size of the original has been chang…
Browse files Browse the repository at this point in the history
…ed (e.g. via modern browser or jQuery resizeable).
  • Loading branch information
hryanjones committed Feb 22, 2013
1 parent 5511f87 commit 7d43b5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jquery.expandable.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
maxHeight = options.maxRows * rowSize;
}

// copy styles from textarea to mirror to mirror the textarea as best possible
// copy styles from textarea to mirror the textarea as best possible
$.each('borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth paddingTop paddingRight paddingBottom paddingLeft fontSize fontFamily fontWeight fontStyle fontStretch fontVariant wordSpacing lineHeight width'.split(' '), function(i,prop) {
$mirror.css(prop, $this.css(prop));
});
Expand All @@ -59,6 +59,12 @@
});

function check() {
//The size of the textarea may have changed because it's resizeable (due to jQuery,
//or allowable by the browser). Update the mirror size in this case.
$.each('borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth width'.split(' '), function(i,prop) {
$mirror.css(prop, $this.css(prop));
});

var text = $this.val(), newHeight, height, usedHeight, usedRows, availableRows;
// copy textarea value to the $mirror
// encode any html passed in and replace new lines with a <br>
Expand Down

0 comments on commit 7d43b5c

Please sign in to comment.