diff options
Diffstat (limited to 'misc/textarea.js')
-rw-r--r-- | misc/textarea.js | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/misc/textarea.js b/misc/textarea.js index 75fb3f520..a1860c6c8 100644 --- a/misc/textarea.js +++ b/misc/textarea.js @@ -1,36 +1,38 @@ // $Id$ -Drupal.behaviors.textarea = function(context) { - $('textarea.resizable:not(.textarea-processed)', context).each(function() { - // Avoid non-processed teasers. - if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) { - return false; - } - var textarea = $(this).addClass('textarea-processed'), staticOffset = null; +Drupal.behaviors.textarea = { + attach: function(context) { + $('textarea.resizable:not(.textarea-processed)', context).each(function() { + // Avoid non-processed teasers. + if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) { + return false; + } + var textarea = $(this).addClass('textarea-processed'), staticOffset = null; - // When wrapping the text area, work around an IE margin bug. See: - // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout - $(this).wrap('<div class="resizable-textarea"><span></span></div>') - .parent().append($('<div class="grippie"></div>').mousedown(startDrag)); + // When wrapping the text area, work around an IE margin bug. See: + // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout + $(this).wrap('<div class="resizable-textarea"><span></span></div>') + .parent().append($('<div class="grippie"></div>').mousedown(startDrag)); - var grippie = $('div.grippie', $(this).parent())[0]; - grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; + var grippie = $('div.grippie', $(this).parent())[0]; + grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; - function startDrag(e) { - staticOffset = textarea.height() - e.pageY; - textarea.css('opacity', 0.25); - $(document).mousemove(performDrag).mouseup(endDrag); - return false; - } + function startDrag(e) { + staticOffset = textarea.height() - e.pageY; + textarea.css('opacity', 0.25); + $(document).mousemove(performDrag).mouseup(endDrag); + return false; + } - function performDrag(e) { - textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); - return false; - } + function performDrag(e) { + textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); + return false; + } - function endDrag(e) { - $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag); - textarea.css('opacity', 1); - } - }); + function endDrag(e) { + $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag); + textarea.css('opacity', 1); + } + }); + } }; |