2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
28 {assign var='elementId' value=$form.field.$elementIndex.$elementName.id}
29 {assign var="tElement" value=$elementName|cat:"_time"}
30 {assign var="timeElement" value=field_`$elementIndex`_`$elementName`_time}
31 {$form.field.$elementIndex.$elementName.html}
32 {elseif $elementIndex}
33 {assign var='elementId' value=$form.$elementName.$elementIndex.id}
34 {assign var="timeElement" value=$elementName|cat:"_time.$elementIndex"}
35 {$form.$elementName.$elementIndex.html}
36 {elseif $blockId and $blockSection}
37 {assign var='elementId' value=$form.$blockSection.$blockId.$elementName.id}
38 {assign var="tElement" value=`$elementName`_time}
39 {$form.$blockSection.$blockId.$elementName.html}
40 {assign var="timeElement" value=`$blockSection`_`$blockId`_`$elementName`_time}
42 {$form.$blockSection.$blockId.$tElement.label}
43 {$form.$blockSection.$blockId.$tElement.html|crmAddClass:six}
47 {assign var='elementId' value=$form.$elementName.id}
49 {assign var="timeElement" value=$elementName|cat:'_time'}
50 {$form.$elementName.html}
53 {assign var='displayDate' value=$elementId|cat:"_display"}
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 close-icon"></span></a>
72 <script type="text/javascript">
76 var element_date = "#{$displayDate}";
77 var element_time = "#{$elementId}_time";
79 element_time = "#{$timeElement}";
80 var time_format = cj( element_time ).attr('timeFormat');
82 cj(element_time).timeEntry({ show24Hours : time_format, spinnerImage: '' });
85 var currentYear = new Date().getFullYear();
86 var alt_field = '#{$elementId}';
87 cj( alt_field ).hide();
88 var date_format = cj( alt_field ).attr('format');
90 var altDateFormat = 'mm/dd/yy';
92 switch ( date_format ) {
95 altDateFormat = 'mm/dd';
99 if ( !( ( date_format == 'M yy' ) || ( date_format == 'yy' ) || ( date_format == 'yy-mm' ) ) ) {
100 cj( element_date ).addClass( 'dpDate' );
104 var yearRange = currentYear - parseInt( cj( alt_field ).attr('startOffset') );
106 yearRange += currentYear + parseInt( cj( alt_field ).attr('endOffset' ) );
109 var startRangeYr = currentYear - parseInt( cj( alt_field ).attr('startOffset') );
110 var endRangeYr = currentYear + parseInt( cj( alt_field ).attr('endOffset' ) );
112 var lcMessage = {/literal}"{$config->lcMessages}"{literal};
113 var localisation = lcMessage.split('_');
114 var dateValue = cj(alt_field).val( );
115 cj(element_date).datepicker({
117 dateFormat : date_format,
120 altField : alt_field,
121 altFormat : altDateFormat,
122 yearRange : yearRange,
123 regional : localisation[0],
124 minDate : new Date(startRangeYr, 1 - 1, 1),
125 maxDate : new Date(endRangeYr, 12 - 1, 31)
128 // set default value to display field, setDefault param for datepicker
129 // is not working hence using below logic
131 var displayDateValue = cj.datepicker.parseDate( altDateFormat, dateValue );
133 // format date according to display field
134 displayDateValue = cj.datepicker.formatDate( date_format, displayDateValue );
135 cj( element_date).val( displayDateValue );
136 //support unsaved-changes warning: CRM-14353
137 cj( element_date).data('crm-initial-value', displayDateValue);
139 cj(element_date).click( function( ) {
142 cj('.ui-datepicker-trigger').click( function( ) {
143 hideYear( cj(this).prev() );
145 function hideYear( element ) {
146 var format = cj( element ).attr('format');
147 if ( format == 'dd-mm' || format == 'mm/dd' ) {
148 cj(".ui-datepicker-year").css('display', 'none');
151 cj(alt_field + ',' + element_date + ',' + element_time).on('blur change', function() {
152 var vis = cj(alt_field).val() || cj(element_time).val() ? '' : 'hidden';
153 cj(this).siblings('.crm-clear-link').css('visibility', vis);
155 cj(alt_field).change();