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 | {* Advanced Search Criteria Fieldset *} | |
27 | {literal} | |
28 | <script type="text/javascript"> | |
3cc60a06 | 29 | CRM.$(function($) { |
d2c45957 CW |
30 | // Bind first click of accordion header to load crm-accordion-body with snippet |
31 | // everything else is taken care of by crmAccordions() | |
32 | $('.crm-search_criteria_basic-accordion .crm-accordion-header').addClass('active'); | |
33 | $('.crm-ajax-accordion').on('click', '.crm-accordion-header:not(.active)', function() { | |
34 | loadPanes($(this).attr('id')); | |
6a488035 | 35 | }); |
d2c45957 CW |
36 | $('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function() { |
37 | loadPanes($(this).attr('id')); | |
38 | }); | |
39 | $('.crm-ajax-accordion').on('click', '.crm-close-accordion', function() { | |
40 | var header = $(this).parent(); | |
41 | header.next().html(''); | |
42 | header.removeClass('active'); | |
43 | header.parent('.crm-ajax-accordion:not(.collapsed)').crmAccordionToggle(); | |
44 | // Reset results-display mode if it depends on this pane | |
45 | var mode = modes[$('#component_mode').val()] || null; | |
46 | if (mode && header.attr('id') == mode) { | |
47 | var oldMode = $('#component_mode :selected').text(); | |
48 | $('#component_mode').val('1'); | |
49 | {/literal} | |
50 | var msg = '{ts escape="js"}Displaying results as "%1" is not available without search criteria from the pane you just closed.{/ts}'; | |
51 | msg = msg.replace('%1', oldMode); | |
52 | CRM.alert(msg, '{ts escape="js"}Display Results have been Reset{/ts}'); | |
53 | {literal} | |
54 | } | |
55 | $(this).remove(); | |
56 | return false; | |
57 | }); | |
58 | // TODO: Why are the modes numeric? If they used the string there would be no need for this map | |
59 | var modes = { | |
60 | '2': 'CiviContribute', | |
61 | '3': 'CiviEvent', | |
62 | '4': 'activity', | |
63 | '5': 'CiviMember', | |
64 | '6': 'CiviCase', | |
2cc569f2 | 65 | '8': 'CiviMail' |
d2c45957 CW |
66 | }; |
67 | // Handle change of results mode | |
68 | $('#component_mode').change(function() { | |
69 | // Reset task dropdown | |
70 | $('#task').val(''); | |
71 | var mode = modes[$('#component_mode').val()] || null; | |
72 | if (mode) { | |
73 | $('.crm-' + mode + '-accordion.collapsed').crmAccordionToggle(); | |
74 | loadPanes(mode); | |
75 | } | |
76 | if ($('#component_mode').val() == '7') { | |
77 | $('#crm-display_relationship_type').show(); | |
78 | } | |
79 | else { | |
80 | $('#display_relationship_type').val(''); | |
81 | $('#crm-display_relationship_type').hide(); | |
82 | } | |
83 | }).change(); | |
84 | /** | |
85 | * Loads snippet based on id of crm-accordion-header | |
86 | */ | |
6a488035 | 87 | function loadPanes(id) { |
02ddf039 | 88 | var url = "{/literal}{crmURL p='civicrm/contact/search/advanced' q="qfKey=`$qfKey`&searchPane=" h=0}{literal}" + id; |
6a488035 TO |
89 | var header = $('#' + id); |
90 | var body = $('.crm-accordion-body.' + id); | |
91 | if (header.length > 0 && body.length > 0 && !body.html()) { | |
92 | body.html('<div class="crm-loading-element"><span class="loading-text">{/literal}{ts escape='js'}Loading{/ts}{literal}...</span></div>'); | |
0bdc50a1 | 93 | header.append('{/literal}<a href="#" class="crm-close-accordion crm-hover-button css_right" title="{ts escape='js'}Remove from search criteria{/ts}"><span class="icon close-icon"></span></a>{literal}'); |
6a488035 | 94 | header.addClass('active'); |
02ddf039 | 95 | CRM.loadPage(url, {target: body, block: false}); |
6a488035 TO |
96 | } |
97 | } | |
98 | }); | |
99 | </script> | |
100 | {/literal} | |
101 | ||
102 | {if $context EQ 'smog' || $context EQ 'amtg' || $savedSearch} | |
103 | <h3> | |
104 | {if $context EQ 'smog'}{ts}Find Contacts within this Group{/ts} | |
105 | {elseif $context EQ 'amtg'}{ts}Find Contacts to Add to this Group{/ts} | |
106 | {elseif $savedSearch}{ts 1=$savedSearch.name}%1 Smart Group Criteria{/ts} {help id='id-advanced-smart'} | |
107 | {/if} | |
108 | </h3> | |
109 | {/if} | |
110 | ||
111 | {strip} | |
112 | <div class="crm-accordion-wrapper crm-search_criteria_basic-accordion "> | |
113 | <div class="crm-accordion-header"> | |
114 | {ts}Basic Criteria{/ts} | |
115 | </div><!-- /.crm-accordion-header --> | |
116 | <div class="crm-accordion-body"> | |
117 | {include file="CRM/Contact/Form/Search/Criteria/Basic.tpl"} | |
118 | </div><!-- /.crm-accordion-body --> | |
119 | </div><!-- /.crm-accordion-wrapper --> | |
120 | ||
121 | {foreach from=$allPanes key=paneName item=paneValue} | |
122 | <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open eq 'true' and $openedPanes.$paneName} {else}collapsed{/if}"> | |
123 | <div class="crm-accordion-header" id="{$paneValue.id}"> | |
124 | {$paneName} | |
125 | </div> | |
126 | <div class="crm-accordion-body {$paneValue.id}"></div> | |
127 | </div> | |
128 | {/foreach} | |
129 | <div class="spacer"></div> | |
130 | ||
131 | <table class="form-layout"> | |
132 | <tr> | |
133 | <td>{$form.buttons.html}</td> | |
134 | </tr> | |
135 | </table> | |
136 | {/strip} |