// Handle clear button for form elements
.on('click', 'a.crm-clear-link', function() {
$(this).css({visibility: 'hidden'}).siblings('.crm-form-radio:checked').prop('checked', false).change();
+ $(this).siblings('input:text').val('').change();
return false;
})
.on('change', 'input.crm-form-radio:checked', function() {
{/if}
{if $action neq 1028}
- <a href="#" class="crm-hover-button" title="{ts}Clear{/ts}" onclick="clearDateTime( '{$elementId}' ); return false;"><span class="icon close-icon"></span></a>
+ <a href="#" class="crm-hover-button crm-clear-link" title="{ts}Clear{/ts}"><span class="icon close-icon"></span></a>
{/if}
<script type="text/javascript">
cj( function() {
{/literal}
var element_date = "#{$displayDate}";
+ var element_time = "#{$elementId}_time";
{if $timeElement}
- var element_time = "#{$timeElement}";
+ element_time = "#{$timeElement}";
var time_format = cj( element_time ).attr('timeFormat');
{literal}
cj(element_time).timeEntry({ show24Hours : time_format, spinnerImage: '' });
cj('.ui-datepicker-trigger').click( function( ) {
hideYear( cj(this).prev() );
});
- });
-
- function hideYear( element ) {
+ function hideYear( element ) {
var format = cj( element ).attr('format');
if ( format == 'dd-mm' || format == 'mm/dd' ) {
- cj(".ui-datepicker-year").css( 'display', 'none' );
+ cj(".ui-datepicker-year").css('display', 'none');
}
- }
+ }
+ cj(alt_field + ',' + element_date + ',' + element_time).on('blur change', function() {
+ var vis = cj(alt_field).val() || cj(element_time).val() ? '' : 'hidden';
+ cj(this).siblings('.crm-clear-link').css('visibility', vis);
+ });
+ cj(alt_field).change();
+ });
- function clearDateTime( element ) {
- cj('input#' + element + ',input#' + element + '_time' + ',input#' + element + '_display').val('');
- }
{/literal}
</script>
{/strip}