Merge pull request #596 from kurund/CRM-12357
[civicrm-core.git] / templates / CRM / Contribute / Form / SoftCredit.js
1 // http://civicrm.org/licensing
2 cj(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
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 });
22
23 var pcpURL = CRM.url('civicrm/ajax/rest',
24 'className=CRM_Contact_Page_AJAX&fnName=getPCPList&json=1&context=contact&reset=1');
25 $('#pcp_made_through').autocomplete(pcpURL,
26 { width : 360, selectFirst : false, matchContains: true
27 }).result( function(event, data, formatted) {
28 cj( "#pcp_made_through_id" ).val( data[1] );
29 });
30 });