Contact summary tabs - simplify styling
[civicrm-core.git] / templates / CRM / Tag / Form / Tag.tpl
CommitLineData
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 *}
27<style>
28 .hit {ldelim}padding-left:10px;{rdelim}
29 .tree li {ldelim}padding-left:10px;{rdelim}
30 #Tag .tree .collapsable .hit {ldelim}background:url('{$config->resourceBase}i/menu-expanded.png') no-repeat left 8px;padding-left: 9px;cursor:pointer{rdelim}
31 #Tag .tree .expandable .hit {ldelim}background:url('{$config->resourceBase}i/menu-collapsed.png') no-repeat left 6px;padding-left: 9px;cursor:pointer{rdelim}
32 #Tag #tagtree .highlighted {ldelim}background-color:lightgrey;{rdelim}
33</style>
34<script type="text/javascript">
abc904f9 35 (function($){ldelim}
6a488035
TO
36 var entityID={$entityID};
37 var entityTable='{$entityTable}';
38 {literal}
abc904f9 39 $(function() {
6a488035 40 //unobsctructive elements are there to provide the function to those not having javascript, no need for the others
abc904f9 41 $(".unobstructive").hide();
6a488035 42
abc904f9
CW
43 $("#tagtree ul input:checked").each (function(){
44 $(this).parents("li").children(".jstree-icon").addClass('highlighted');
6a488035
TO
45 });
46
abc904f9 47 $("#tagtree input").change(function(){
b2703f3b
CW
48 var tagid = this.id.replace("check_", "");
49 var op = (this.checked) ? 'create' : 'delete';
50 CRM.api('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: tagid});
51 CRM.updateContactSummaryTags();
6a488035
TO
52 });
53
54 //load js tree.
abc904f9 55 $("#tagtree").jstree({
4441df69
CW
56 "plugins" : ["themes", "html_data"],
57 "themes": {"url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/default/style.css'}
58 });
6a488035
TO
59
60 {/literal}
61 {if $permission neq 'edit'}
62 {literal}
abc904f9 63 $("#tagtree input").attr('disabled', true);
6a488035
TO
64 {/literal}
65 {/if}
66 {literal}
abc904f9 67 });
b2703f3b
CW
68
69 CRM.updateContactSummaryTags = function() {
abc904f9
CW
70 var tags = [], $tab = $('#tab_tag');
71 $('.tag-section .token-input-token-facebook p, #tagtree input:checkbox:checked+label').each(function() {
72 tags.push($(this).text());
73 });
b2703f3b 74 // showing count of tags in summary tab
abc904f9 75 $('a em', $tab).html('' + tags.length);
a07afa53
CW
76 $tab
77 .removeClass($tab.attr('class').match(/(crm-count-\d+)/)[0])
78 .addClass('crm-count-' + tags.length);
b2703f3b 79 // update summary tab
abc904f9 80 $("#tags").html(tags.join(', '));
6a488035 81 };
abc904f9 82 })(cj);
6a488035
TO
83 {/literal}
84</script>
85<div id="Tag" class="view-content">
86 <h3>{if !$hideContext}{ts}Tags{/ts}{/if}</h3>
87 <p>
88 {if $action eq 16}
89 {if $permission EQ 'edit'}
90 {capture assign=crmURL}{crmURL p='civicrm/contact/view/tag' q='action=update'}{/capture}
91 <span class="unobstructive">{ts 1=$displayName 2=$crmURL}Current tags for <strong>%1</strong> are highlighted. You can add or remove tags from <a href='%2'>Edit Tags</a>.{/ts}</span>
92 {else}
93 {ts}Current tags are highlighted.{/ts}
94 {/if}
95 {else}
96 {if !$hideContext}
97 {ts}Mark or unmark the checkboxes, <span class="unobstructive">and click 'Update Tags' to modify tags.<span>{/ts}
98 {/if}
99 {/if}
100 </p>
101 <div id="tagtree">
102 <ul class="tree">
103 {foreach from=$tree item="node" key="id"}
104 <li id="tag_{$id}">
105 {if ! $node.children}<input name="tagList[{$id}]" id="check_{$id}" type="checkbox" {if $tagged[$id]}checked="checked"{/if}/>{/if}
106 {if $node.children}<input name="tagList[{$id}]" id="check_{$id}" type="checkbox" {if $tagged[$id]}checked="checked"{/if}/>{/if}
107 {if $node.children} <span class="hit"></span> {/if} <label for="check_{$id}" id="tagLabel_{$id}">{$node.name}</label>
108 {if $node.children}
109 <ul>
110 {foreach from=$node.children item="subnode" key="subid"}
111 <li id="tag_{$subid}">
112 <input id="check_{$subid}" name="tagList[{$subid}]" type="checkbox" {if $tagged[$subid]}checked="checked"{/if}/>
113 {if $subnode.children} <span class="hit"></span> {/if} <label for="check_{$subid}" id="tagLabel_{$subid}">{$subnode.name}</label>
114 {if $subnode.children}
115 <ul>
116 {foreach from=$subnode.children item="subsubnode" key="subsubid"}
117 <li id="tag_{$subsubid}">
118 <input id="check_{$subsubid}" name="tagList[{$subsubid}]" type="checkbox" {if $tagged[$subsubid]}checked="checked"{/if}/>
119 <label for="check_{$subsubid}" id="tagLabel_{$subsubid}">{$subsubnode.name}</label>
120 </li>
121 {/foreach}
122 </ul>
123 {/if}
124 </li>
125 {/foreach}
126 </ul>
127 {/if}
128 </li>
129 {/foreach}
130 </ul>
131 </div>
132
133{* Show Edit Tags link if in View mode *}
134{if $permission EQ 'edit' AND $action eq 16}
135 </fieldset>
136 <div class="action-link unobstructive">
137 <a accesskey="N" href="{crmURL p='civicrm/contact/view/tag' q='action=update'}" class="button"><span><div class="icon edit-icon"></div>{ts}Edit Tags{/ts}</span></a>
138 </div>
139 {else}
140 <div class="form-item unobstructive">{$form.buttons.html}</div>
141 </fieldset>
142{/if}
143 <br />
144{include file="CRM/common/Tag.tpl" context="contactTab"}
145</div>
146
147{if $action eq 1 or $action eq 2 }
148<script type="text/javascript">
149 {* this function is called to change the color of selected row(s) *}
150 on_load_init_check("{$form.formName}");
151</script>
152{/if}