Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
fee14197 | 3 | | CiviCRM version 5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
8c9251b3 | 5 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
6a488035 TO |
26 | {if $batchUpdate} |
27 | {assign var='elementId' value=$form.field.$elementIndex.$elementName.id} | |
28 | {assign var="tElement" value=$elementName|cat:"_time"} | |
29 | {assign var="timeElement" value=field_`$elementIndex`_`$elementName`_time} | |
30 | {$form.field.$elementIndex.$elementName.html} | |
31 | {elseif $elementIndex} | |
32 | {assign var='elementId' value=$form.$elementName.$elementIndex.id} | |
33 | {assign var="timeElement" value=$elementName|cat:"_time.$elementIndex"} | |
34 | {$form.$elementName.$elementIndex.html} | |
35 | {elseif $blockId and $blockSection} | |
36 | {assign var='elementId' value=$form.$blockSection.$blockId.$elementName.id} | |
37 | {assign var="tElement" value=`$elementName`_time} | |
38 | {$form.$blockSection.$blockId.$elementName.html} | |
39 | {assign var="timeElement" value=`$blockSection`_`$blockId`_`$elementName`_time} | |
40 | {if $tElement} | |
41 | {$form.$blockSection.$blockId.$tElement.label} | |
42 | {$form.$blockSection.$blockId.$tElement.html|crmAddClass:six} | |
43 | {/if} | |
44 | {else} | |
31e83de7 E |
45 | {if !$elementId} |
46 | {assign var='elementId' value=$form.$elementName.id} | |
47 | {/if} | |
6a488035 TO |
48 | {assign var="timeElement" value=$elementName|cat:'_time'} |
49 | {$form.$elementName.html} | |
50 | {/if} | |
51 | ||
d348460a | 52 | {* CRM-15804 - CiviEvent Date Picker broken in modal dialog *} |
9ea58cec | 53 | {assign var='displayDate' value=$elementId|cat:"_display"|cat:"_$string"|uniqid} |
6a488035 TO |
54 | |
55 | {if $action neq 1028} | |
56 | <input type="text" name="{$displayDate}" id="{$displayDate}" class="dateplugin" autocomplete="off"/> | |
57 | {/if} | |
58 | ||
59 | {if $batchUpdate AND $timeElement AND $tElement} | |
60 | {$form.field.$elementIndex.$tElement.label} {$form.field.$elementIndex.$tElement.html|crmAddClass:six} | |
61 | {elseif $timeElement AND !$tElement} | |
62 | {if $form.$timeElement.label} | |
63 | {$form.$timeElement.label} | |
64 | {/if} | |
65 | {$form.$timeElement.html|crmAddClass:six} | |
66 | {/if} | |
67 | ||
68 | {if $action neq 1028} | |
44f15f74 | 69 | <a href="#" class="crm-hover-button crm-clear-link" title="{ts}Clear{/ts}"><i class="crm-i fa-times"></i></a> |
6a488035 TO |
70 | {/if} |
71 | ||
72 | <script type="text/javascript"> | |
73 | {literal} | |
3cc60a06 | 74 | CRM.$(function($) { |
6a488035 | 75 | {/literal} |
7e34e265 CW |
76 | // Workaround for possible duplicate ids in the dom - select by name instead of id and exclude already initialized widgets |
77 | var $dateElement = $('input[name={$displayDate}].dateplugin:not(.hasDatepicker)'); | |
4466c37a CW |
78 | {literal} |
79 | if (!$dateElement.length) { | |
80 | return; | |
81 | } | |
82 | {/literal} | |
6a488035 | 83 | {if $timeElement} |
7e34e265 CW |
84 | var $timeElement = $dateElement.siblings("#{$timeElement}"); |
85 | var time_format = $timeElement.attr('timeFormat'); | |
6a488035 | 86 | {literal} |
7e34e265 | 87 | $timeElement.timeEntry({ show24Hours : time_format, spinnerImage: '' }); |
6a488035 | 88 | {/literal} |
7e34e265 CW |
89 | {else} |
90 | var $timeElement = $(); | |
6a488035 | 91 | {/if} |
7e34e265 CW |
92 | var currentYear = new Date().getFullYear(), |
93 | $originalElement = $dateElement.siblings('#{$elementId}').hide(), | |
94 | date_format = $originalElement.attr('format'), | |
95 | altDateFormat = 'mm/dd/yy'; | |
6a488035 | 96 | {literal} |
6a488035 TO |
97 | |
98 | if ( !( ( date_format == 'M yy' ) || ( date_format == 'yy' ) || ( date_format == 'yy-mm' ) ) ) { | |
7e34e265 | 99 | $dateElement.addClass( 'dpDate' ); |
6a488035 TO |
100 | } |
101 | ||
5243c4d2 CW |
102 | var yearRange = (currentYear - parseInt($originalElement.attr('startOffset'))) + |
103 | ':' + currentYear + parseInt($originalElement.attr('endOffset')), | |
104 | startRangeYr = currentYear - parseInt($originalElement.attr('startOffset')), | |
7e34e265 | 105 | endRangeYr = currentYear + parseInt($originalElement.attr('endOffset')); |
0e9d07d2 | 106 | |
7e34e265 | 107 | $dateElement.datepicker({ |
5243c4d2 CW |
108 | closeAtTop: true, |
109 | dateFormat: date_format, | |
110 | changeMonth: (date_format.indexOf('m') > -1), | |
111 | changeYear: (date_format.indexOf('y') > -1), | |
112 | altField: $originalElement, | |
113 | altFormat: altDateFormat, | |
114 | yearRange: yearRange, | |
115 | minDate: new Date(startRangeYr, 1 - 1, 1), | |
116 | maxDate: new Date(endRangeYr, 12 - 1, 31) | |
117 | }); | |
6a488035 | 118 | |
5243c4d2 CW |
119 | // format display date |
120 | var displayDateValue = $.datepicker.formatDate(date_format, $.datepicker.parseDate(altDateFormat, $originalElement.val())); | |
68d6459e | 121 | //support unsaved-changes warning: CRM-14353 |
5243c4d2 | 122 | $dateElement.val(displayDateValue).data('crm-initial-value', displayDateValue); |
6a488035 | 123 | |
7e34e265 CW |
124 | // Add clear button |
125 | $($timeElement).add($originalElement).add($dateElement).on('blur change', function() { | |
126 | var vis = $dateElement.val() || $timeElement.val() ? '' : 'hidden'; | |
127 | $dateElement.siblings('.crm-clear-link').css('visibility', vis); | |
bcb4280c | 128 | }); |
7e34e265 | 129 | $originalElement.change(); |
bcb4280c | 130 | }); |
6a488035 | 131 | |
6a488035 TO |
132 | {/literal} |
133 | </script> |