2006-03-09 23:20:24 +00:00
|
|
|
// $Id$
|
2009-04-27 20:19:38 +00:00
|
|
|
(function ($) {
|
2006-03-09 23:20:24 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
Drupal.behaviors.textarea = {
|
2009-04-27 20:19:38 +00:00
|
|
|
attach: function (context, settings) {
|
2009-08-31 05:51:08 +00:00
|
|
|
$('textarea.resizable', context).once('textarea', function () {
|
2008-12-20 18:24:41 +00:00
|
|
|
// When wrapping the text area, work around an IE margin bug. See:
|
2008-10-29 10:01:28 +00:00
|
|
|
// http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
|
2009-08-31 05:51:08 +00:00
|
|
|
var staticOffset = null;
|
|
|
|
var textarea = $(this).wrap('<div class="resizable-textarea"><span></span></div>');
|
|
|
|
var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
|
2006-08-31 23:31:25 +00:00
|
|
|
|
2009-08-31 05:51:08 +00:00
|
|
|
grippie
|
|
|
|
.insertAfter(textarea)
|
|
|
|
.css('margin-right', grippie.width() - textarea.width());
|
2006-08-31 23:31:25 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
function startDrag(e) {
|
|
|
|
staticOffset = textarea.height() - e.pageY;
|
|
|
|
textarea.css('opacity', 0.25);
|
|
|
|
$(document).mousemove(performDrag).mouseup(endDrag);
|
|
|
|
return false;
|
|
|
|
}
|
2005-12-29 03:59:30 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
function performDrag(e) {
|
|
|
|
textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
|
|
|
|
return false;
|
|
|
|
}
|
2005-12-29 03:59:30 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
function endDrag(e) {
|
2009-04-26 19:18:46 +00:00
|
|
|
$(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
|
2008-10-29 10:01:28 +00:00
|
|
|
textarea.css('opacity', 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2007-06-01 09:05:45 +00:00
|
|
|
};
|
2009-02-18 13:46:55 +00:00
|
|
|
|
|
|
|
})(jQuery);
|