Projet

Général

Profil

Révision b720ea3e

Ajouté par Assos Assos il y a plus de 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date_popup/date_popup.js
1 1
/**
2 2
 * Attaches the calendar behavior to all required fields
3 3
 */
4
(function ($) {
5
Drupal.behaviors.date_popup = {
6
  attach: function (context) {
7
  for (var id in Drupal.settings.datePopup) {
8
    $('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) {
9
      if (!$(this).hasClass('date-popup-init')) {
10
        var datePopup = e.data;
11
        // Explicitely filter the methods we accept.
12
        switch (datePopup.func) {
13
          case 'datepicker':
14
            $(this)
15
              .datepicker(datePopup.settings)
16
              .addClass('date-popup-init')
17
            $(this).click(function(){
18
              $(this).focus();
19
            });
20
            break;
4
(function($) {
5
  function makeFocusHandler(e) {
6
    if (!$(this).hasClass('date-popup-init')) {
7
      var datePopup = e.data;
8
      // Explicitely filter the methods we accept.
9
      switch (datePopup.func) {
10
        case 'datepicker':
11
          $(this)
12
            .datepicker(datePopup.settings)
13
            .addClass('date-popup-init');
14
          $(this).click(function(){
15
            $(this).focus();
16
          });
17
          break;
21 18

  
22
          case 'timeEntry':
23
            $(this)
24
              .timeEntry(datePopup.settings)
25
              .addClass('date-popup-init')
26
            $(this).click(function(){
27
              $(this).focus();
28
            });
29
            break;
30
          case 'timepicker':
31
            // Translate the PHP date format into the style the timepicker uses.
32
            datePopup.settings.timeFormat = datePopup.settings.timeFormat
33
              // 12-hour, leading zero,
34
              .replace('h', 'hh')
35
              // 12-hour, no leading zero.
36
              .replace('g', 'h')
37
              // 24-hour, leading zero.
38
              .replace('H', 'HH')
39
              // 24-hour, no leading zero.
40
              .replace('G', 'H')
41
              // AM/PM.
42
              .replace('A', 'p')
43
              // Minutes with leading zero.
44
              .replace('i', 'mm')
45
              // Seconds with leading zero.
46
              .replace('s', 'ss');
19
        case 'timeEntry':
20
          $(this)
21
            .timeEntry(datePopup.settings)
22
            .addClass('date-popup-init');
23
          $(this).click(function(){
24
            $(this).focus();
25
          });
26
          break;
47 27

  
48
            datePopup.settings.startTime = new Date(datePopup.settings.startTime);
49
            $(this)
50
              .timepicker(datePopup.settings)
51
              .addClass('date-popup-init');
52
            $(this).click(function(){
53
              $(this).focus();
54
            });
55
            break;
56
        }
28
        case 'timepicker':
29
          // Translate the PHP date format into the style the timepicker uses.
30
          datePopup.settings.timeFormat = datePopup.settings.timeFormat
31
            // 12-hour, leading zero,
32
            .replace('h', 'hh')
33
            // 12-hour, no leading zero.
34
            .replace('g', 'h')
35
            // 24-hour, leading zero.
36
            .replace('H', 'HH')
37
            // 24-hour, no leading zero.
38
            .replace('G', 'H')
39
            // AM/PM.
40
            .replace('A', 'p')
41
            // Minutes with leading zero.
42
            .replace('i', 'mm')
43
            // Seconds with leading zero.
44
            .replace('s', 'ss');
45

  
46
          datePopup.settings.startTime = new Date(datePopup.settings.startTime);
47
          $(this)
48
            .timepicker(datePopup.settings)
49
            .addClass('date-popup-init');
50
          $(this).click(function(){
51
            $(this).focus();
52
          });
53
          break;
57 54
      }
58
    });
59
  }
55
    }
60 56
  }
61
};
57

  
58
  Drupal.behaviors.date_popup = {
59
    attach: function (context) {
60
      for (var id in Drupal.settings.datePopup) {
61
        $('#'+ id).bind('focus', Drupal.settings.datePopup[id], makeFocusHandler);
62
      }
63
    }
64
  };
62 65
})(jQuery);

Formats disponibles : Unified diff