http://www.mediawiki.org/wiki/Special:Code/MediaWiki/87686

Revision: 87686
Author:   janpaul123
Date:     2011-05-08 14:58:33 +0000 (Sun, 08 May 2011)
Log Message:
-----------
Reverted r87521 for now. Couldn't find any documentation that elastic textareas 
are available in jQuery UI.

Modified Paths:
--------------
    trunk/extensions/WikiLove/WikiLove.php
    trunk/extensions/WikiLove/wikiLove.js

Added Paths:
-----------
    trunk/extensions/WikiLove/jquery.elastic.js

Modified: trunk/extensions/WikiLove/WikiLove.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.php      2011-05-08 14:51:09 UTC (rev 
87685)
+++ trunk/extensions/WikiLove/WikiLove.php      2011-05-08 14:58:33 UTC (rev 
87686)
@@ -98,6 +98,10 @@
                ),
                'dependencies' => array(
                        'jquery.ui.dialog',
+                       'jquery.elastic',
                ),
        ),
+       'jquery.elastic' => $wikiLoveTpl + array(
+               'scripts' => 'jquery.elastic.js',
+       ),
 );

Copied: trunk/extensions/WikiLove/jquery.elastic.js (from rev 87520, 
trunk/extensions/WikiLove/jquery.elastic.js)
===================================================================
--- trunk/extensions/WikiLove/jquery.elastic.js                         (rev 0)
+++ trunk/extensions/WikiLove/jquery.elastic.js 2011-05-08 14:58:33 UTC (rev 
87686)
@@ -0,0 +1,6 @@
+(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;}
+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;}
+$twin.appendTo($textarea.parent());var 
i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));}
+function 
setHeightAndOverflow(height,overflow){curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});}}
+function update(){var 
textareaContent=$textarea.val().replace(/&/g,'&amp;').replace(/  
/g,'&nbsp;').replace(/<|>/g,'&gt;').replace(/\n/g,'<br />');var 
twinContent=$twin.html();if(textareaContent+'&nbsp;'!=twinContent){$twin.html(textareaContent+'&nbsp;');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');}}}}
+$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

Modified: trunk/extensions/WikiLove/wikiLove.js
===================================================================
--- trunk/extensions/WikiLove/wikiLove.js       2011-05-08 14:51:09 UTC (rev 
87685)
+++ trunk/extensions/WikiLove/wikiLove.js       2011-05-08 14:58:33 UTC (rev 
87686)
@@ -159,6 +159,7 @@
                        $( '#wlSubtype' ).change( $.wikiLove.changeSubtype );
                        $( '#wlPreviewForm' ).submit( $.wikiLove.submitPreview 
);
                        $( '#wlSendForm' ).click( $.wikiLove.submitSend );
+                       $( '#wlMessage' ).elastic(); // have the message 
textarea grow automatically
                }
                
                $.wikiLove.$dialog.dialog( 'open' );


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to