Merge pull request #591 from davecivicrm/CRM-12482
[civicrm-core.git] / templates / CRM / Contribute / Form / SoftCredit.js
CommitLineData
81bc499e
KJ
1// http://civicrm.org/licensing
2cj(function($) {
3 $('.crm-contribution-pcp-block').hide();
4 $('#showPCP, #showSoftCredit').click(function(){
5 return showHideSoftCreditAndPCP();
6 });
7
8 function showHideSoftCreditAndPCP() {
9 $('.crm-contribution-pcp-block').toggle();
10 $('.crm-contribution-pcp-block-link').toggle();
11 $('.crm-contribution-form-block-soft_credit_to').toggle();
12 return false;
13 }
14
65377546
KJ
15 $('#addMoreSoftCredit').click(function(){
16 $('.crm-soft-credit-block tr.hiddenElement :first').show().removeClass('hiddenElement');
17 if ( $('.crm-soft-credit-block tr.hiddenElement').length < 1 ) {
18 $('#addMoreSoftCredit').hide();
19 }
20 return false;
21 });
81bc499e
KJ
22});
23/*
24 var url = "{/literal}{$dataUrl}{literal}";
25
26 cj('#soft_credit_to').autocomplete( url, { width : 180, selectFirst : false, matchContains: true
27 }).result( function(event, data, formatted) {
28 cj( "#soft_contact_id" ).val( data[1] );
29 });
30 {/literal}
31
32// load form during form rule.
33{if $buildPriceSet}{literal}buildAmount( );{/literal}{/if}
34
35{if $siteHasPCPs}
36 {literal}
37 var pcpUrl = "{/literal}{$pcpDataUrl}{literal}";
38
39 cj('#pcp_made_through').autocomplete( pcpUrl, { width : 360, selectFirst : false, matchContains: true
40 }).result( function(event, data, formatted) {
41 cj( "#pcp_made_through_id" ).val( data[1] );
42 });
43{/literal}
44
45 {if $pcpLinked}
46 {literal}hideSoftCredit( );{/literal}{* hide soft credit on load if we have PCP linkage *}
47 {else}
48 {literal}cj('#pcpID').hide();{/literal}{* hide PCP section *}
49 {/if}
50
51 {literal}
52 function hideSoftCredit ( ){
53 cj("#softCreditID").hide();
54 }
55 function showPCP( ) {
56 cj('#pcpID').show();
57 cj("#softCreditID").hide();
58 }
59 function showSoftCredit( ) {
60 cj('#pcp_made_through_id').val('');
61 cj('#pcp_made_through').val('');
62 cj('#pcp_roll_nickname').val('');
63 cj('#pcp_personal_note').val('');
64 cj('#pcp_display_in_roll').attr('checked', false);
65 cj("#pcpID").hide();
66 cj('#softCreditID').show();
67 }
68 {/literal}
69{/if}
70</script>
71
72*/