From b9bf1f82399c1609c59d9ba432e46ce797137770 Mon Sep 17 00:00:00 2001 From: mzd Date: Tue, 29 Apr 2014 14:35:53 -0400 Subject: [PATCH] CRM-11864 add functionality for 'same as main contact' ---------------------------------------- * CRM-11864: Embed form-designer in event and contribution UIs https://issues.civicrm.org/jira/browse/CRM-11864 --- .../Event/Form/ManageEvent/Registration.tpl | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/templates/CRM/Event/Form/ManageEvent/Registration.tpl b/templates/CRM/Event/Form/ManageEvent/Registration.tpl index 5208c3e783..42a610d7b6 100644 --- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl @@ -364,7 +364,7 @@ invert = 0 urlPath = CRM.url('civicrm/event/manage/registration', { addProfileBottom: 1 , addProfileNum : profileBottomCount, snippet: 4 } ) ; } - $(this).closest('tbody').append(''); + $(this).closest('tbody').append(''); var $el = $(this).closest('tbody').find('tr:last'); $el.load(urlPath, function() { $(this).trigger('crmLoad') }); } @@ -376,6 +376,23 @@ invert = 0 $(e.target).parents('tr').hide(); } + var strSameAs = ' - '+ts('same as for main contact')+' - '; + var strSelect = ' - '+ts('select')+' - '; + + $('#crm-container').on('crmLoad', function() { + var $container = $("[id^='additional_profile_'],.additional_profile").not('.processed').addClass('processed'); + $container.find(".crm-profile-selector-select select").each( function() { + var $select = $(this); + var selected = $select.find(':selected').val(); //cache the default + $select.find('option[value=""]').remove(); + $select.prepend(''); + if ($select.closest('tr').is(':not([id*="_pre"])')) { + $select.prepend(''); + } + $select.find('option[value="'+selected+'"]').attr('selected', 'selected'); //restore default + }); + }); + $(function($) { showRuleFields( {/literal}{$ruleFields}{literal} ); @@ -402,6 +419,16 @@ $(function($) { $('#registration_blocks').on('click', '.crm-button-add-profile', addBottomProfile); $('#registration_blocks').on('click', '.crm-button-rem-profile', removeBottomProfile); + $('#crm-container').on('crmLoad', function(e) { + $('tr[id^="additional_profile"] input[id^="additional_custom_"]').change(function(e) { + $input = $(e.target); + if ( $input.val() == '') { + $selected = $input.closest('tr').find('.crm-profile-selector-select :selected'); + if ($selected.text() == strSelect) { $input.val('none'); } + } + }); + }); + }); // END onReady }(CRM.$, CRM._)); //Generic Closure {/literal} -- 2.25.1