| 1 |
Drupal.contemplate.divResizable = function() {
|
| 2 |
$('div.resizable:not(.processed)').each(function() {
|
| 3 |
var div = $(this).addClass('processed'), staticOffset = null;
|
| 4 |
|
| 5 |
$(this).wrap('<div class="resizable-textarea"></div>')
|
| 6 |
.parent().append($('<div class="grippie"></div>').mousedown(startDrag));
|
| 7 |
|
| 8 |
var grippie = $('div.grippie', $(this).parent())[0];
|
| 9 |
grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
|
| 10 |
|
| 11 |
function startDrag(e) {
|
| 12 |
staticOffset = div.height() - Drupal.mousePosition(e).y;
|
| 13 |
div.css('opacity', 0.25);
|
| 14 |
$(document).mousemove(performDrag).mouseup(endDrag);
|
| 15 |
return false;
|
| 16 |
}
|
| 17 |
|
| 18 |
function performDrag(e) {
|
| 19 |
div.height(Math.max(32, staticOffset + Drupal.mousePosition(e).y) + 'px');
|
| 20 |
return false;
|
| 21 |
}
|
| 22 |
|
| 23 |
function endDrag(e) {
|
| 24 |
$(document).unmousemove(performDrag).unmouseup(endDrag);
|
| 25 |
div.css('opacity', 1);
|
| 26 |
}
|
| 27 |
});
|
| 28 |
}
|
| 29 |
|
| 30 |
if (Drupal.jsEnabled) {
|
| 31 |
$(document).ready(Drupal.contemplate.divResizable);
|
| 32 |
}
|