Projet

Général

Profil

Paste
Télécharger (920 octets) Statistiques
| Branche: | Révision:

root / htmltest / misc / textarea.js @ 85ad3d82

1
(function ($) {
2

    
3
Drupal.behaviors.textarea = {
4
  attach: function (context, settings) {
5
    $('.form-textarea-wrapper.resizable', context).once('textarea', function () {
6
      var staticOffset = null;
7
      var textarea = $(this).addClass('resizable-textarea').find('textarea');
8
      var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
9

    
10
      grippie.insertAfter(textarea);
11

    
12
      function startDrag(e) {
13
        staticOffset = textarea.height() - e.pageY;
14
        textarea.css('opacity', 0.25);
15
        $(document).mousemove(performDrag).mouseup(endDrag);
16
        return false;
17
      }
18

    
19
      function performDrag(e) {
20
        textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
21
        return false;
22
      }
23

    
24
      function endDrag(e) {
25
        $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
26
        textarea.css('opacity', 1);
27
      }
28
    });
29
  }
30
};
31

    
32
})(jQuery);