author | cavaliet@caf4f556-3d62-0410-8435-a86758001935 |
Fri, 21 Aug 2009 16:30:15 +0000 | |
branch | drupal |
changeset 75 | a34abe7498a6 |
parent 74 | 0ff3ba646492 |
permissions | -rw-r--r-- |
74
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
1 |
// $Id: textarea.js,v 1.22 2008/01/17 19:31:56 goba Exp $ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
2 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
3 |
Drupal.behaviors.textarea = function(context) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
4 |
$('textarea.resizable:not(.textarea-processed)', context).each(function() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
5 |
// Avoid non-processed teasers. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
6 |
if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
7 |
return false; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
8 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
9 |
var textarea = $(this).addClass('textarea-processed'), staticOffset = null; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
10 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
11 |
// When wrapping the text area, work around an IE margin bug. See: |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
12 |
// http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
13 |
$(this).wrap('<div class="resizable-textarea"><span></span></div>') |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
14 |
.parent().append($('<div class="grippie"></div>').mousedown(startDrag)); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
15 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
16 |
var grippie = $('div.grippie', $(this).parent())[0]; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
17 |
grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
18 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
19 |
function startDrag(e) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
20 |
staticOffset = textarea.height() - e.pageY; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
21 |
textarea.css('opacity', 0.25); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
22 |
$(document).mousemove(performDrag).mouseup(endDrag); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
23 |
return false; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
24 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
25 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
26 |
function performDrag(e) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
27 |
textarea.height(Math.max(32, staticOffset + e.pageY) + 'px'); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
28 |
return false; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
29 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
30 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
31 |
function endDrag(e) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
32 |
$(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
33 |
textarea.css('opacity', 1); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
34 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
35 |
}); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
36 |
}; |