root / drupal7 / sites / all / modules / date / date_popup / date_popup.js @ 74f6bef0
1 | 85ad3d82 | Assos Assos | /**
|
---|---|---|---|
2 | * Attaches the calendar behavior to all required fields
|
||
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;
|
||
21 | |||
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'); |
||
47 | |||
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 | } |
||
57 | } |
||
58 | }); |
||
59 | } |
||
60 | } |
||
61 | }; |
||
62 | })(jQuery); |