Drupal.behaviors.iframe = function(context) {
$('iframe.resizable:not(.iframe-processed)', context).each(function() {
var iframe = $(this).addClass('iframe-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('
')
.parent().append($('').mousedown(startDrag));
var grippie = $('div.grippie', $(this).parent())[0];
grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
grippie.style.height = "30px"; // Making the grippie larger to avoid overlapping with the iFrame when draggin it up.
grippie.style.backgroundPosition = "center 13px";
function startDrag(e) {
staticOffset = iframe.height() - e.pageY;
iframe.css('opacity', 0.25);
$(document).mousemove(performDrag).mouseup(endDrag);
return false;
}
function performDrag(e) {
iframe.height(Math.max(32, staticOffset + e.pageY) + 'px');
return false;
}
function endDrag(e) {
$(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
iframe.css('opacity', 1);
}
});
};