Merge pull request #8615 from bsilvern/crm-18805
[civicrm-core.git] / templates / CRM / common / customData.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2016 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
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. |
12 | |
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. |
17 | |
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 +--------------------------------------------------------------------+
25 *}
26 {literal}
27 <script type="text/javascript">
28 (function($) {
29 CRM.buildCustomData = function (type, subType, subName, cgCount, groupID, isMultiple) {
30 var dataUrl = CRM.url('civicrm/custom', {type: type}),
31 prevCount = 1,
32 fname = '#customData',
33 storage = {};
34
35 if (subType) {
36 dataUrl += '&subType=' + subType;
37 }
38
39 if (subName) {
40 dataUrl += '&subName=' + subName;
41 $('#customData' + subName).show();
42 }
43 else {
44 $('#customData').show();
45 }
46 if (groupID) {
47 dataUrl += '&groupID=' + groupID;
48 }
49
50 {/literal}
51 {if $groupID}
52 dataUrl += '&groupID=' + '{$groupID}';
53 {/if}
54 {if $entityID}
55 dataUrl += '&entityID=' + '{$entityID}';
56 {/if}
57 {literal}
58
59 if (!cgCount) {
60 cgCount = 1;
61 }
62 else if (cgCount >= 1) {
63 prevCount = cgCount;
64 cgCount++;
65 }
66
67 dataUrl += '&cgcount=' + cgCount;
68
69
70 if (isMultiple) {
71 fname = '#custom_group_' + groupID + '_' + prevCount;
72 if ($(".add-more-link-" + groupID + "-" + prevCount).length) {
73 $(".add-more-link-" + groupID + "-" + prevCount).hide();
74 }
75 else {
76 $("#add-more-link-" + prevCount).hide();
77 }
78 }
79 else if (subName && subName != 'null') {
80 fname += subName;
81 }
82
83 return CRM.loadPage(dataUrl, {target: fname});
84 };
85 })(CRM.$);
86 </script>
87 {/literal}