2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
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}
41 {$form.$blockSection.$blockId.$tElement.label}
42 {$form.$blockSection.$blockId.$tElement.html|crmAddClass:six}
46 {assign var='elementId' value=$form.$elementName.id}
48 {assign var="timeElement" value=$elementName|cat:'_time'}
49 {$form.$elementName.html}
52 {* CRM-15804 - CiviEvent Date Picker broken in modal dialog *}
53 {assign var='displayDate' value=$elementId|cat:"_display"|cat:"_$string"|uniqid}
56 <input type="text" name="{$displayDate}" id="{$displayDate}" class="dateplugin" autocomplete="off"/>
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}
65 {$form.$timeElement.html|crmAddClass:six}
69 <a href="#" class="crm-hover-button crm-clear-link" title="{ts}Clear{/ts}"><span class="icon ui-icon-close"></span></a>
72 <script type="text/javascript">
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)');
79 if (!$dateElement.length) {
84 var $timeElement = $dateElement.siblings("#{$timeElement}");
85 var time_format = $timeElement.attr('timeFormat');
87 $timeElement.timeEntry({ show24Hours : time_format, spinnerImage: '' });
90 var $timeElement = $();
92 var currentYear = new Date().getFullYear(),
93 $originalElement = $dateElement.siblings('#{$elementId}').hide(),
94 date_format = $originalElement.attr('format'),
95 altDateFormat = 'mm/dd/yy';
98 if ( !( ( date_format == 'M yy' ) || ( date_format == 'yy' ) || ( date_format == 'yy-mm' ) ) ) {
99 $dateElement.addClass( 'dpDate' );
102 var yearRange = (currentYear - parseInt($originalElement.attr('startOffset'))) +
103 ':' + currentYear + parseInt($originalElement.attr('endOffset')),
104 startRangeYr = currentYear - parseInt($originalElement.attr('startOffset')),
105 endRangeYr = currentYear + parseInt($originalElement.attr('endOffset'));
107 $dateElement.datepicker({
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)
119 // format display date
120 var displayDateValue = $.datepicker.formatDate(date_format, $.datepicker.parseDate(altDateFormat, $originalElement.val()));
121 //support unsaved-changes warning: CRM-14353
122 $dateElement.val(displayDateValue).data('crm-initial-value', displayDateValue);
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);
129 $originalElement.change();