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