Projet

Général

Profil

Paste
Télécharger (2,5 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / calendar / js / calendar_overlap.js @ 62e0cc08

1
/*
2
 *  Create the splitter, set the viewport size, and set the position of the scrollbar to the first item.
3
 */
4
(function($){
5
  Drupal.behaviors.calendarSetScroll = {
6
  attach: function(context) {
7
    // Make multi-day resizable - stolen/borrowed from textarea.js
8
    $('.header-body-divider:not(.header-body-divider-processed)').each(function() {
9
      var divider = $(this).addClass('header-body-divider-processed');
10
      var start_y = divider.offset().top;
11

    
12
      // Add the grippie icon
13
      $(this).prepend('<div class="grippie"></div>').mousedown(startDrag);
14

    
15
      function startDrag(e) {
16
        start_y = divider.offset().top;
17
        $(document).mousemove(performDrag).mouseup(endDrag);
18
        return false;
19
      }
20

    
21
      function performDrag(e) {
22
        var offset = e.pageY - start_y;
23
        var mwc = $('#multi-day-container');
24
        var sdc = $('#single-day-container');
25
        var mwc_height = mwc.height();
26
        var sdc_height = sdc.height();
27
        var max_height = mwc_height + sdc_height;
28
        mwc.height(Math.min(max_height,Math.max(0,mwc_height + offset)));
29
        sdc.height(Math.min(max_height,Math.max(0,sdc_height - offset)));
30
        start_y = divider.offset().top;
31
        return false;
32
      }
33

    
34
      function endDrag(e) {
35
        $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
36
      }
37
     });
38

    
39
    $('.single-day-footer:not(.single-day-footer-processed)').each(function() {
40
      var divider = $(this).addClass('single-day-footer-processed');
41
      var start_y = divider.offset().top;
42

    
43
      // Add the grippie icon
44
      $(this).prepend('<div class="grippie"></div>').mousedown(startDrag);
45

    
46
      function startDrag(e) {
47
        start_y = divider.offset().top;
48
        $(document).mousemove(performDrag).mouseup(endDrag);
49
        return false;
50
      }
51

    
52
      function performDrag(e) {
53
        var offset = e.pageY - start_y;
54
        var sdc = $('#single-day-container');
55
        sdc.height(Math.max(0,sdc.height() + offset));
56
        start_y = divider.offset().top;
57
        return false;
58
      }
59

    
60
      function endDrag(e) {
61
        $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
62
      }
63
     });
64
    }
65
  };
66
})(jQuery);
67

    
68
// Scroll the viewport to the first item
69
function calendar_scrollToFirst($) {
70
   if ($('div.first_item').size() > 0 ) {
71
      var y = $('div.first_item').offset().top - $('#single-day-container').offset().top ;
72
      if ($('#single-day-container').length > 0) {
73
        var top = $('#single-day-container').offset().top;
74
      }
75
   }
76
}
77