Imported drupal-5.5
[drupal.git] / misc / textarea.js
blob6db68dfcd3e14aa86caa06ca5b4aa6ae6341523f
1 // $Id: textarea.js,v 1.11.2.1 2007/04/18 02:41:19 drumm Exp $
3 Drupal.textareaAttach = function() {
4   $('textarea.resizable:not(.processed)').each(function() {
5     var textarea = $(this).addClass('processed'), staticOffset = null;
7     // When wrapping the text area, work around an IE margin bug.  See:
8     // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
9     $(this).wrap('<div class="resizable-textarea"><span></span></div>')
10       .parent().append($('<div class="grippie"></div>').mousedown(startDrag));
12     var grippie = $('div.grippie', $(this).parent())[0];
13     grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
15     function startDrag(e) {
16       staticOffset = textarea.height() - Drupal.mousePosition(e).y;
17       textarea.css('opacity', 0.25);
18       $(document).mousemove(performDrag).mouseup(endDrag);
19       return false;
20     }
22     function performDrag(e) {
23       textarea.height(Math.max(32, staticOffset + Drupal.mousePosition(e).y) + 'px');
24       return false;
25     }
27     function endDrag(e) {
28       $(document).unmousemove(performDrag).unmouseup(endDrag);
29       textarea.css('opacity', 1);
30     }
31   });
34 if (Drupal.jsEnabled) {
35   $(document).ready(Drupal.textareaAttach);