(function($) { /** * Auto-growing textareas; technique ripped from Facebook * * * http://github.com/jaz303/jquery-grab-bag/tree/master/javascripts/jquery.autogrow-textarea.js */ $.fn.autogrow = function(options) { return this.filter('textarea').each(function() { var self = this; var $self = $(self); var minHeight = $self.height(); var noFlickerPad = $self.hasClass('autogrow-short') ? 0 : parseInt($self.css('lineHeight')) || 0; var settings = $.extend({ preGrowCallback: null, postGrowCallback: null }, options); var shadow = $("div.autogrow-shadow"); if (!shadow.length) { shadow = $('
').addClass("autogrow-shadow").appendTo(document.body); } shadow.css({ width: $self.width(), fontSize: $self.css('fontSize'), fontFamily: $self.css('fontFamily'), fontWeight: $self.css('fontWeight'), lineHeight: $self.css('lineHeight'), resize: 'none', wordWrap: 'break-word' }); var update = function(event) { var times = function(string, number) { for (var i = 0, r = ''; i < number; i++) r += string; return r; }; var val = self.value.replace(//g, '>') .replace(/&/g, '&') .replace(/\n$/, '