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) {
|
|
|
|
$('textarea.resizable:not(.textarea-processed)', context).each(function () {
|
2008-10-29 10:01:28 +00:00
|
|
|
// Avoid non-processed teasers.
|
|
|
|
if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var textarea = $(this).addClass('textarea-processed'), staticOffset = null;
|
2006-09-07 08:05:31 +00:00
|
|
|
|
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
|
|
|
|
$(this).wrap('<div class="resizable-textarea"><span></span></div>')
|
|
|
|
.parent().append($('<div class="grippie"></div>').mousedown(startDrag));
|
2006-08-31 23:31:25 +00:00
|
|
|
|
2008-10-29 10:01:28 +00:00
|
|
|
var grippie = $('div.grippie', $(this).parent())[0];
|
2009-04-26 19:18:46 +00:00
|
|
|
grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) + 'px';
|
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);
|