| 1 |
// $Id: textarea.js,v 1.29 2009/04/27 20:19:35 webchick Exp $
|
| 2 |
(function ($) {
|
| 3 |
|
| 4 |
Drupal.behaviors.textarea = {
|
| 5 |
attach: function (context, settings) {
|
| 6 |
$('textarea.resizable', context).once('textarea', function () {
|
| 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 |
var staticOffset = null;
|
| 10 |
var textarea = $(this).wrap('<div class="resizable-textarea"><span></span></div>');
|
| 11 |
var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
|
| 12 |
|
| 13 |
grippie
|
| 14 |
.insertAfter(textarea)
|
| 15 |
.css('margin-right', grippie.width() - textarea.width());
|
| 16 |
|
| 17 |
function startDrag(e) {
|
| 18 |
staticOffset = textarea.height() - e.pageY;
|
| 19 |
textarea.css('opacity', 0.25);
|
| 20 |
$(document).mousemove(performDrag).mouseup(endDrag);
|
| 21 |
return false;
|
| 22 |
}
|
| 23 |
|
| 24 |
function performDrag(e) {
|
| 25 |
textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
|
| 26 |
return false;
|
| 27 |
}
|
| 28 |
|
| 29 |
function endDrag(e) {
|
| 30 |
$(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
|
| 31 |
textarea.css('opacity', 1);
|
| 32 |
}
|
| 33 |
});
|
| 34 |
}
|
| 35 |
};
|
| 36 |
|
| 37 |
})(jQuery);
|