From ed30e90320ee3b4151c178e88c9eafc7242f67a0 Mon Sep 17 00:00:00 2001 From: Pistos Date: Fri, 15 Jun 2012 13:43:07 -0400 Subject: [PATCH] Whitespace cleanup. --- README.markdown | 4 ++-- jquery.expandable.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.markdown b/README.markdown index 33d14c0..421abed 100644 --- a/README.markdown +++ b/README.markdown @@ -8,7 +8,7 @@ A jQuery plugin that auto-expands textareas to fit the contents as a user types. The expandable plugin has 5 settings: * `duration` - The speed of the animation when expanding (or shrinking). Default is 'normal'. -* `init` - If true, the textarea will be resized to fit its content on initialization. +* `init` - If true, the textarea will be resized to fit its content on initialization. * `interval` - The interval at which it checks the textarea. Default is 750. * `within` - The number of rows left before expanding. Default is 1. * `by` - The number of rows to expand by. Default is 2. @@ -22,4 +22,4 @@ Copyright (c) 2010 [Brandon Aaron](http://brandonaaron.net) ## Contributors -Karl Swedberg \ No newline at end of file +Karl Swedberg diff --git a/jquery.expandable.js b/jquery.expandable.js index 8e43cdb..3c38d0c 100644 --- a/jquery.expandable.js +++ b/jquery.expandable.js @@ -18,7 +18,7 @@ $.fn.extend({ by: 2, init: false }, givenOptions); - + return this.filter('textarea').each(function() { var $this = $(this).css({ display: 'block', overflow: 'hidden' }), minHeight = $this.height(), @@ -29,12 +29,12 @@ $.fn.extend({ // white-space rules from: http://petesbloggerama.blogspot.com/2007/02/firefox-ie-word-wrap-word-break-tables.html $mirror = $('
').appendTo('body'), interval; - + // copy styles from textarea to mirror 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)); }); - + // setup events $this .bind('keypress', function(event) { if ( event.keyCode == '13' ) check(); }) @@ -49,12 +49,12 @@ $.fn.extend({ // encode any html passed in and replace new lines with a
// the   is to try and normalize browser behavior $mirror.html( encodeHTML(text).replace(/\n/g, ' 
') ); - + height = $this[0].offsetHeight - heightDiff; usedHeight = $mirror[0].offsetHeight - heightDiff; usedRows = Math.floor(usedHeight / rowSize); availableRows = Math.floor((height / rowSize) - usedRows); - + // adjust height if needed by either growing or shrinking the text area to within the specified bounds if ( availableRows <= options.within ) { newHeight = rowSize * (usedRows + Math.max(availableRows, 0) + options.by); @@ -68,7 +68,7 @@ $.fn.extend({ }).end(); } }); - + function encodeHTML(text) { var characters = { '<' : '<', @@ -83,4 +83,4 @@ function encodeHTML(text) { }); } -})(jQuery); \ No newline at end of file +})(jQuery);