Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -98,6 +98,10 @@ |
99 | 99 | ), |
100 | 100 | 'dependencies' => array( |
101 | 101 | 'jquery.ui.dialog', |
| 102 | + 'jquery.elastic', |
102 | 103 | ), |
103 | 104 | ), |
| 105 | + 'jquery.elastic' => $wikiLoveTpl + array( |
| 106 | + 'scripts' => 'jquery.elastic.js', |
| 107 | + ), |
104 | 108 | ); |
Index: trunk/extensions/WikiLove/wikiLove.js |
— | — | @@ -159,6 +159,7 @@ |
160 | 160 | $( '#wlSubtype' ).change( $.wikiLove.changeSubtype ); |
161 | 161 | $( '#wlPreviewForm' ).submit( $.wikiLove.submitPreview ); |
162 | 162 | $( '#wlSendForm' ).click( $.wikiLove.submitSend ); |
| 163 | + $( '#wlMessage' ).elastic(); // have the message textarea grow automatically |
163 | 164 | } |
164 | 165 | |
165 | 166 | $.wikiLove.$dialog.dialog( 'open' ); |
Index: trunk/extensions/WikiLove/jquery.elastic.js |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +(function(jQuery){jQuery.fn.extend({elastic:function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];return this.each(function(){if(this.type!='textarea'){return false;} |
| 3 | +var $textarea=jQuery(this),$twin=jQuery('<div />').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;if(maxheight<0){maxheight=Number.MAX_VALUE;} |
| 4 | +$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));} |
| 5 | +function setHeightAndOverflow(height,overflow){curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});}} |
| 6 | +function update(){var textareaContent=$textarea.val().replace(/&/g,'&').replace(/ /g,' ').replace(/<|>/g,'>').replace(/\n/g,'<br />');var twinContent=$twin.html();if(textareaContent+' '!=twinContent){$twin.html(textareaContent+' ');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto');}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden');}else{setHeightAndOverflow(goalheight,'hidden');}}}} |
| 7 | +$textarea.css({'overflow':'hidden'});$textarea.keyup(function(){update();});$textarea.live('input paste',function(e){setTimeout(update,250);});update();});}});})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/WikiLove/jquery.elastic.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 8 | + native |