Mercurial > defr > drupal > core
annotate misc/textarea.js @ 1:c1f4ac30525a 6.0
Drupal 6.0
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:28:28 +0100 |
parents | |
children |
rev | line source |
---|---|
webmaster@1 | 1 // $Id: textarea.js,v 1.22 2008/01/17 19:31:56 goba Exp $ |
webmaster@1 | 2 |
webmaster@1 | 3 Drupal.behaviors.textarea = function(context) { |
webmaster@1 | 4 $('textarea.resizable:not(.textarea-processed)', context).each(function() { |
webmaster@1 | 5 // Avoid non-processed teasers. |
webmaster@1 | 6 if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) { |
webmaster@1 | 7 return false; |
webmaster@1 | 8 } |
webmaster@1 | 9 var textarea = $(this).addClass('textarea-processed'), staticOffset = null; |
webmaster@1 | 10 |
webmaster@1 | 11 // When wrapping the text area, work around an IE margin bug. See: |
webmaster@1 | 12 // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout |
webmaster@1 | 13 $(this).wrap('<div class="resizable-textarea"><span></span></div>') |
webmaster@1 | 14 .parent().append($('<div class="grippie"></div>').mousedown(startDrag)); |
webmaster@1 | 15 |
webmaster@1 | 16 var grippie = $('div.grippie', $(this).parent())[0]; |
webmaster@1 | 17 grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; |
webmaster@1 | 18 |
webmaster@1 | 19 function startDrag(e) { |
webmaster@1 | 20 staticOffset = textarea.height() - e.pageY; |
webmaster@1 | 21 textarea.css('opacity', 0.25); |
webmaster@1 | 22 $(document).mousemove(performDrag).mouseup(endDrag); |
webmaster@1 | 23 return false; |
webmaster@1 | 24 } |
webmaster@1 | 25 |
webmaster@1 | 26 function performDrag(e) { |
webmaster@1 | 27 textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); |
webmaster@1 | 28 return false; |
webmaster@1 | 29 } |
webmaster@1 | 30 |
webmaster@1 | 31 function endDrag(e) { |
webmaster@1 | 32 $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag); |
webmaster@1 | 33 textarea.css('opacity', 1); |
webmaster@1 | 34 } |
webmaster@1 | 35 }); |
webmaster@1 | 36 }; |