/[drupal]/drupal/misc/textarea.js
ViewVC logotype

Contents of /drupal/misc/textarea.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.30 - (show annotations) (download) (as text)
Mon Aug 31 05:51:08 2009 UTC (2 months, 3 weeks ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-9, HEAD
Changes since 1.29: +9 -13 lines
File MIME type: text/javascript
- Patch #444344 by kkaefer, sun, Rob Loach: this change introduces a jQuery .once() method which streamlines the way behavior functions work. Previously, we had to manually ensure that an element is only initialized once. Usually, this happens by adding classes and selecting only those elements which do not have that class. However, this process can be separated out into a jQuery ‘filtering’ function which does all the grunt work.
1 // $Id: textarea.js,v 1.29 2009/04/27 20:19:35 webchick Exp $
2 (function ($) {
3
4 Drupal.behaviors.textarea = {
5 attach: function (context, settings) {
6 $('textarea.resizable', context).once('textarea', function () {
7 // When wrapping the text area, work around an IE margin bug. See:
8 // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
9 var staticOffset = null;
10 var textarea = $(this).wrap('<div class="resizable-textarea"><span></span></div>');
11 var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
12
13 grippie
14 .insertAfter(textarea)
15 .css('margin-right', grippie.width() - textarea.width());
16
17 function startDrag(e) {
18 staticOffset = textarea.height() - e.pageY;
19 textarea.css('opacity', 0.25);
20 $(document).mousemove(performDrag).mouseup(endDrag);
21 return false;
22 }
23
24 function performDrag(e) {
25 textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
26 return false;
27 }
28
29 function endDrag(e) {
30 $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
31 textarea.css('opacity', 1);
32 }
33 });
34 }
35 };
36
37 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2