Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
232624b1 | 3 | | CiviCRM version 4.4 | |
6a488035 TO |
4 | +--------------------------------------------------------------------+ |
5 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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> |
9545c40d CW |
29 | #tagtree .highlighted > label { |
30 | background-color: #FEFD7B; | |
31 | } | |
6a488035 TO |
32 | </style> |
33 | <script type="text/javascript"> | |
9545c40d | 34 | (function($){{/literal} |
6a488035 TO |
35 | var entityID={$entityID}; |
36 | var entityTable='{$entityTable}'; | |
37 | {literal} | |
abc904f9 | 38 | $(function() { |
abc904f9 | 39 | $("#tagtree ul input:checked").each (function(){ |
9545c40d | 40 | $(this).closest("li").addClass('highlighted'); |
6a488035 TO |
41 | }); |
42 | ||
abc904f9 | 43 | $("#tagtree input").change(function(){ |
b2703f3b CW |
44 | var tagid = this.id.replace("check_", ""); |
45 | var op = (this.checked) ? 'create' : 'delete'; | |
48b2a002 CW |
46 | var api = CRM.api3('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: tagid}); |
47 | CRM.status({/literal}'{ts escape="js"}Saving...{/ts}', '{ts escape="js"}Saved{/ts}'{literal}, api); | |
9545c40d | 48 | $(this).closest("li").toggleClass('highlighted'); |
b2703f3b | 49 | CRM.updateContactSummaryTags(); |
6a488035 TO |
50 | }); |
51 | ||
52 | //load js tree. | |
abc904f9 | 53 | $("#tagtree").jstree({ |
4441df69 CW |
54 | "plugins" : ["themes", "html_data"], |
55 | "themes": {"url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/default/style.css'} | |
56 | }); | |
6a488035 TO |
57 | |
58 | {/literal} | |
59 | {if $permission neq 'edit'} | |
60 | {literal} | |
6f9cd76f | 61 | $("#tagtree input").prop('disabled', true); |
6a488035 TO |
62 | {/literal} |
63 | {/if} | |
64 | {literal} | |
abc904f9 | 65 | }); |
b2703f3b CW |
66 | |
67 | CRM.updateContactSummaryTags = function() { | |
58b65bf6 | 68 | var tags = []; |
abc904f9 CW |
69 | $('.tag-section .token-input-token-facebook p, #tagtree input:checkbox:checked+label').each(function() { |
70 | tags.push($(this).text()); | |
71 | }); | |
8e4ec1f5 CW |
72 | // contact summary tabs and search forms both listen for this event |
73 | $('#Tag').closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length}); | |
b2703f3b | 74 | // update summary tab |
8e4ec1f5 | 75 | $("#contact-summary #tags").html(tags.join(', ')); |
6a488035 | 76 | }; |
abc904f9 | 77 | })(cj); |
6a488035 TO |
78 | {/literal} |
79 | </script> | |
80 | <div id="Tag" class="view-content"> | |
81 | <h3>{if !$hideContext}{ts}Tags{/ts}{/if}</h3> | |
6a488035 TO |
82 | <div id="tagtree"> |
83 | <ul class="tree"> | |
84 | {foreach from=$tree item="node" key="id"} | |
85 | <li id="tag_{$id}"> | |
86 | {if ! $node.children}<input name="tagList[{$id}]" id="check_{$id}" type="checkbox" {if $tagged[$id]}checked="checked"{/if}/>{/if} | |
87 | {if $node.children}<input name="tagList[{$id}]" id="check_{$id}" type="checkbox" {if $tagged[$id]}checked="checked"{/if}/>{/if} | |
88 | {if $node.children} <span class="hit"></span> {/if} <label for="check_{$id}" id="tagLabel_{$id}">{$node.name}</label> | |
89 | {if $node.children} | |
90 | <ul> | |
91 | {foreach from=$node.children item="subnode" key="subid"} | |
92 | <li id="tag_{$subid}"> | |
93 | <input id="check_{$subid}" name="tagList[{$subid}]" type="checkbox" {if $tagged[$subid]}checked="checked"{/if}/> | |
94 | {if $subnode.children} <span class="hit"></span> {/if} <label for="check_{$subid}" id="tagLabel_{$subid}">{$subnode.name}</label> | |
95 | {if $subnode.children} | |
96 | <ul> | |
97 | {foreach from=$subnode.children item="subsubnode" key="subsubid"} | |
98 | <li id="tag_{$subsubid}"> | |
99 | <input id="check_{$subsubid}" name="tagList[{$subsubid}]" type="checkbox" {if $tagged[$subsubid]}checked="checked"{/if}/> | |
100 | <label for="check_{$subsubid}" id="tagLabel_{$subsubid}">{$subsubnode.name}</label> | |
101 | </li> | |
102 | {/foreach} | |
103 | </ul> | |
104 | {/if} | |
105 | </li> | |
106 | {/foreach} | |
107 | </ul> | |
108 | {/if} | |
109 | </li> | |
110 | {/foreach} | |
111 | </ul> | |
112 | </div> | |
6a488035 TO |
113 | <br /> |
114 | {include file="CRM/common/Tag.tpl" context="contactTab"} | |
115 | </div> |