Merge pull request #3828 from johanv/CRM-15104-line_item_issues_participant_api
[civicrm-core.git] / templates / CRM / Tag / Form / Tag.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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 {* this template is used for adding/editing tags *}
27 {literal}
28 <style>
29 #tagtree .highlighted > label {
30 background-color: #FEFD7B;
31 }
32 #tagtree .helpicon ins {
33 display: none;
34 }
35 #tagtree ins.jstree-icon {
36 cursor: pointer;
37 }
38 </style>
39 <script type="text/javascript">
40 (function($, _){{/literal}
41 var entityID={$entityID};
42 var entityTable='{$entityTable}';
43 {literal}
44 CRM.updateContactSummaryTags = function() {
45 var tags = [];
46 $('#tagtree input:checkbox:checked+label').each(function() {
47 tags.push($(this).text());
48 });
49 $('input.crm-contact-tagset').each(function() {
50 var setTags = _.pluck($(this).select2('data'), 'label');
51 tags = tags.concat(setTags);
52 });
53 // contact summary tabs and search forms both listen for this event
54 $('#Tag').closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
55 // update summary tab
56 $("#contact-summary #tags").html(tags.join(', '));
57 };
58
59 $(function() {
60 $("#tagtree ul input:checked").each (function(){
61 $(this).closest("li").addClass('highlighted');
62 });
63
64 $("#tagtree input").change(function(){
65 var tagid = this.id.replace("check_", "");
66 var op = (this.checked) ? 'create' : 'delete';
67 var api = CRM.api3('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: tagid}, true);
68 $(this).closest("li").toggleClass('highlighted');
69 CRM.updateContactSummaryTags();
70 });
71
72 //load js tree.
73 $("#tagtree").jstree({
74 plugins : ["themes", "html_data"],
75 themes: {
76 "theme": 'classic',
77 "dots": false,
78 "icons": false,
79 "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
80 }
81 });
82
83 {/literal}
84 {if $permission neq 'edit'}
85 {literal}
86 $("#tagtree input").prop('disabled', true);
87 {/literal}
88 {/if}
89 {literal}
90
91 $(document).on('change', 'input.crm-contact-tagset', CRM.updateContactSummaryTags);
92 });
93 })(CRM.$, CRM._);
94 {/literal}
95 </script>
96 <div id="Tag" class="view-content">
97 <h3>{if !$hideContext}{ts}Tags{/ts}{/if}</h3>
98 <div id="tagtree">
99 {include file="CRM/Tag/Form/Tagtree.tpl"}
100 </div>
101 <br />
102 {include file="CRM/common/Tagset.tpl"}
103 </div>