Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 *} | |
9545c40d | 27 | {literal} |
6a488035 | 28 | <style> |
f3c5f2ad CW |
29 | #tagtree .highlighted > span { |
30 | background-color: #fefca6; | |
9545c40d | 31 | } |
a0a03c43 CW |
32 | #tagtree .helpicon ins { |
33 | display: none; | |
34 | } | |
35 | #tagtree ins.jstree-icon { | |
36 | cursor: pointer; | |
37 | } | |
6a488035 TO |
38 | </style> |
39 | <script type="text/javascript"> | |
e4f4dc22 | 40 | (function($, _){{/literal} |
b50fdacc CW |
41 | var entityID={$entityID}, |
42 | entityTable='{$entityTable}', | |
43 | $form = $('form.{$form.formClass}'); | |
6a488035 | 44 | {literal} |
e4f4dc22 CW |
45 | CRM.updateContactSummaryTags = function() { |
46 | var tags = []; | |
f3c5f2ad | 47 | $('#tagtree input:checkbox:checked+span label').each(function() { |
e4f4dc22 CW |
48 | tags.push($(this).text()); |
49 | }); | |
50 | $('input.crm-contact-tagset').each(function() { | |
51 | var setTags = _.pluck($(this).select2('data'), 'label'); | |
52 | tags = tags.concat(setTags); | |
53 | }); | |
54 | // contact summary tabs and search forms both listen for this event | |
b50fdacc | 55 | $($form).closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length}); |
e4f4dc22 CW |
56 | // update summary tab |
57 | $("#contact-summary #tags").html(tags.join(', ')); | |
58 | }; | |
59 | ||
abc904f9 | 60 | $(function() { |
f3c5f2ad CW |
61 | function highlightSelected() { |
62 | $("ul input:not(:checked)", '#tagtree').each(function () { | |
63 | $(this).closest("li").removeClass('highlighted'); | |
64 | }); | |
65 | $("ul input:checked", '#tagtree').each(function () { | |
66 | $(this).parents("li[id^=tag]").addClass('highlighted'); | |
67 | }); | |
68 | } | |
69 | highlightSelected(); | |
6a488035 | 70 | |
abc904f9 | 71 | $("#tagtree input").change(function(){ |
b2703f3b CW |
72 | var tagid = this.id.replace("check_", ""); |
73 | var op = (this.checked) ? 'create' : 'delete'; | |
1b2475e1 | 74 | var api = CRM.api3('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: tagid}, true); |
f3c5f2ad | 75 | highlightSelected(); |
b2703f3b | 76 | CRM.updateContactSummaryTags(); |
6a488035 TO |
77 | }); |
78 | ||
79 | //load js tree. | |
abc904f9 | 80 | $("#tagtree").jstree({ |
a0a03c43 CW |
81 | plugins : ["themes", "html_data"], |
82 | themes: { | |
83 | "theme": 'classic', | |
84 | "dots": false, | |
85 | "icons": false, | |
86 | "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css' | |
87 | } | |
4441df69 | 88 | }); |
6a488035 TO |
89 | |
90 | {/literal} | |
91 | {if $permission neq 'edit'} | |
92 | {literal} | |
6f9cd76f | 93 | $("#tagtree input").prop('disabled', true); |
6a488035 TO |
94 | {/literal} |
95 | {/if} | |
96 | {literal} | |
b2703f3b | 97 | |
e4f4dc22 CW |
98 | $(document).on('change', 'input.crm-contact-tagset', CRM.updateContactSummaryTags); |
99 | }); | |
100 | })(CRM.$, CRM._); | |
6a488035 TO |
101 | {/literal} |
102 | </script> | |
103 | <div id="Tag" class="view-content"> | |
104 | <h3>{if !$hideContext}{ts}Tags{/ts}{/if}</h3> | |
6a488035 | 105 | <div id="tagtree"> |
f3c5f2ad | 106 | {include file="CRM/Tag/Form/Tagtree.tpl" level=1} |
6a488035 | 107 | </div> |
6a488035 | 108 | <br /> |
191279e0 | 109 | {include file="CRM/common/Tagset.tpl"} |
6a488035 | 110 | </div> |