Index: trunk/extensions/WikiLove/modules/jquery.elastic/jquery.elastic.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /** |
3 | 3 | * @name Elastic |
4 | 4 | * @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically |
5 | | -* @version 1.6.10 |
| 5 | +* @version 1.6.11 |
6 | 6 | * @requires jQuery 1.2.6+ |
7 | 7 | * |
8 | 8 | * @author Jan Jarfalk |
— | — | @@ -9,12 +9,9 @@ |
10 | 10 | * @author-website http://www.unwrongest.com |
11 | 11 | * |
12 | 12 | * @licence MIT License - http://www.opensource.org/licenses/mit-license.php |
13 | | -* |
14 | | -* This file has been downloaded from http://unwrongest.com/projects/elastic/, please notify the author of |
15 | | -* any changes. |
16 | 13 | */ |
17 | 14 | |
18 | | -(function(jQuery){ |
| 15 | +(function($){ |
19 | 16 | jQuery.fn.extend({ |
20 | 17 | elastic: function() { |
21 | 18 | |
— | — | @@ -45,14 +42,19 @@ |
46 | 43 | ]; |
47 | 44 | |
48 | 45 | return this.each( function() { |
49 | | - |
| 46 | + |
50 | 47 | // Elastic only works on textareas |
51 | 48 | if ( this.type !== 'textarea' ) { |
52 | 49 | return false; |
53 | 50 | } |
54 | 51 | |
55 | 52 | var $textarea = jQuery(this), |
56 | | - $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}), |
| 53 | + $twin = jQuery('<div />').css({ |
| 54 | + 'position' : 'absolute', |
| 55 | + 'display' : 'none', |
| 56 | + 'word-wrap' : 'break-word', |
| 57 | + 'white-space' : 'pre-wrap' |
| 58 | + }), |
57 | 59 | lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), |
58 | 60 | minheight = parseInt($textarea.css('height'),10) || lineHeight*3, |
59 | 61 | maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, |
— | — | @@ -73,7 +75,7 @@ |
74 | 76 | |
75 | 77 | // Updates the width of the twin. (solution for textareas with widths in percent) |
76 | 78 | function setTwinWidth(){ |
77 | | - curatedWidth = Math.floor(parseInt($textarea.width(),10)); |
| 79 | + var curatedWidth = Math.floor(parseInt($textarea.width(),10)); |
78 | 80 | if($twin.width() !== curatedWidth){ |
79 | 81 | $twin.css({'width': curatedWidth + 'px'}); |
80 | 82 | |
— | — | @@ -84,14 +86,9 @@ |
85 | 87 | |
86 | 88 | // Sets a given height and overflow state on the textarea |
87 | 89 | function setHeightAndOverflow(height, overflow){ |
88 | | - |
89 | 90 | var curratedHeight = Math.floor(parseInt(height,10)); |
90 | 91 | if($textarea.height() !== curratedHeight){ |
91 | 92 | $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); |
92 | | - |
93 | | - // Fire the custom event resize |
94 | | - //$textarea.trigger('resize'); |
95 | | - |
96 | 93 | } |
97 | 94 | } |
98 | 95 | |