]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/parts/searchbar.tt2
LP2061136 - Stamping 1405 DB upgrade script
[Evergreen.git] / Open-ILS / src / templates / opac / parts / searchbar.tt2
1 <h3 class="sr-only">[% l('Catalog Search') %]</h3>
2 [% PROCESS "opac/parts/org_selector.tt2";
3
4 # We need to ignore some filters in our count
5
6 fignore = ['lasso','location_groups','site','core_limit','limit','badge_orgs','badges','estimation_strategy','depth'];
7 fcount = 0;
8 FOR f IN ctx.query_struct.filters;
9     IF fignore.grep('^' _ f.name _ '$').size;
10         NEXT;
11     END;
12     fcount = fcount + 1;
13 END;
14
15     # don't display a box for the search_format filter,
16     # as that's got its own widget
17     ignore_filters = ['search_format'];
18
19     trimmed_filters = [];
20     FOR filter IN ctx.query_struct.filters;
21         fname = filter.name;
22         IF ignore_filters.grep('^' _ fname _ '$').size;
23             NEXT;
24         END;
25         trimmed_filters.push(filter);
26     END;
27
28     ctx.query_struct.filters = trimmed_filters;
29
30  %]
31
32 <div id="search-wrapper">
33     [% UNLESS took_care_of_form -%]
34     <form action="[% ctx.opac_root %]/results" method="get">
35     [%- END %]
36     [% IF ctx.page == 'rresult' && ctx.metarecord && search.metarecord_default %]
37     <input type="hidden" name="modifier" value="metabib"/>
38     [% END %]
39     [% IF (ctx.page == 'place_hold' || ctx.page == 'myopac' || ctx.page == 'home' || ctx.page == 'record') && search.metarecord_default %]
40     <input type="hidden" name="modifier" value="metabib"/>
41     [% END %]
42     <div id="search-box">
43         <span class="search_catalog_lbl mobile_hide">[% l('Search the Catalog') %]</span>
44         <span class="adv_search_catalog_lbl"><a href="[% mkurl(ctx.opac_root _ '/advanced', {},  expert_search_parms.merge(browse_search_parms, facet_search_parms)) %]"
45             id="home_adv_search_link">[% l('Advanced Search') %]</a></span>
46         <span class="browse_the_catalog_lbl"><a href="[% mkurl(ctx.opac_root _ '/browse', {}, expert_search_parms.merge(general_search_parms, facet_search_parms, ['fi:has_browse_entry'])) %]">[% l('Browse the Catalog') %]</a></span>
47         [% IF ctx.get_org_setting(ctx.physical_loc || ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1 %]
48         <span class="search_courses_label"><a href="[% mkurl(ctx.opac_root _ '/course_search') %]">[% l('Search for Courses') %]</a></span>
49         <span class="search_courses_label"><a href="[% mkurl(ctx.opac_root _ '/course_browse') %]">[% l('Browse for Courses') %]</a></span>
50         [% END %]
51         [% INCLUDE 'opac/parts/cart.tt2' %]
52     </div>
53     <div class="searchbar [% is_home_page ? 'searchbar-home' : '' %]">
54         <span class='search_box_wrapper'>
55             [%- # autosuggest breaks accessibility, as the aria-label
56                 # attribute is removed when the Dijit is created. :(  %]
57             <label id="search_box_label" for="search_box">[% l('Search: ') %]
58             <input type="search" id="search_box" name="query" aria-label="[%
59                     l('Enter search query:');
60                 %]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.user_query) : CGI.param('query') | html %]"
61                 class="search-box"
62                 [%- IF use_autosuggest.enabled == "t" %]
63                     data-instructions="[% l('Press down arrow for autocomplete') %]"
64                     data-listbox-name="[% l('autocomplete') %]"
65                     data-search-org="[% ctx.physical_loc || ctx.aou_tree.id %]"
66                 [%- ELSE -%]
67                     [% IF basic_search != "f" AND is_home_page %] autofocus [% END %] x-webkit-speech
68                 [%- END # autosuggest enabled %] />
69             </label>
70         </span>
71         <label id="search_qtype_label" for="qtype">
72         [%- 
73             l('Type: ');
74             INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
75         -%]
76         </label>
77         <label id="search_itype_label" for="search_itype_selector">
78         [%-
79             l('Format: ');
80             IF search.basic_config.type == 'attr';
81                 INCLUDE "opac/parts/coded_value_selector.tt2"
82                     attr=search.basic_config.group none_ok=1 
83                     id='search_itype_selector'
84                     none_label=search.basic_config.none_label;
85             ELSIF search.basic_config.type == 'filter';
86                 INCLUDE "opac/parts/filter_group_selector.tt2"
87                     filter_group=search.basic_config.group none_ok=1 
88                     id='search_itype_selector'
89                     none_label=search.basic_config.none_label;
90             END;
91         -%]
92         </label>
93         <label id="search_locg_label" for="search_org_selector">
94         [%- 
95             l('Library: ');
96             select_lib_label = l("Select search library");
97             INCLUDE build_org_selector arialabel=select_lib_label 
98               id='search_org_selector' show_loc_groups=1 show_lassos=1
99         -%]
100         </label>
101         <label id="search_scope_label" for="search_scope_selector">
102         [%#-
103             l('Where: ');
104             select_scope_label = l("Select search scope");
105             INCLUDE build_scope_selector arialabel=select_scope_label value=ctx.search_scope
106               id='search_scope_selector' name='search_scope' show_loc_groups=1
107         -%]
108         </label>
109       <span>
110         <input id="detail" type="hidden" name="detail_record_view" value="[% show_detail_view %]"/>
111         <input id='search-submit-go' type="submit" value="[% l('Search') %]" class="opac-button"
112             onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden";[% IF ctx.depth_sel_button AND NOT took_care_of_form %] $("search-submit-go-depth").className="hidden";[% END %]}, 2000)'/>
113         [%- IF ctx.depth_sel_button AND NOT took_care_of_form %]
114         <button id='search-submit-go-depth' type="submit" value="[% ctx.depth_sel_depth %]" name="depth" class="[% ctx.depth_sel_button_class %]"
115             onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden"; $("search-submit-go-depth").className="hidden";}, 2000)' title="[% ctx.depth_sel_tooltip | html %]">[% ctx.depth_sel_button_label | html %]</button>
116         [%- END %]
117         <img id='search-submit-spinner' src='[% ctx.media_prefix %]/opac/images/progressbar_green.gif[% ctx.cache_key %]' style='height:16px;width:16px;' class='hidden' alt='[% l("Search In Progress") %]'/>
118         [%- IF took_care_of_form && !search.no_highlight %]
119         <label for="no_highlight">
120           <input type="checkbox" id="no_highlight" name="no_highlight" value="1"
121               onchange="search_modifier_onchange('no_highlight', this, true)"
122               [% CGI.param('no_highlight').size ? ' checked="checked"' : '' %] />
123           [% l('Disable Highlighting') %]
124         </label>
125         [%- END %]
126       </span>
127     </div>
128     [% IF ctx.bookbag %]
129     <div id="search-only-bookbag-container">
130         <input type="checkbox" id="search-only-bookbag" name="bookbag"
131             value="[% ctx.bookbag.id | html %]" checked="checked" />
132         <label for="search-only-bookbag">
133             [% l('Search only within the chosen list') %]
134         </label>
135     </div>
136     [% END %]
137     [% IF is_advanced || is_special %]
138     <div>
139         <input type="hidden" name="_adv" value="1" />
140         [% IF ctx.processed_search_query OR (NOT is_advanced AND NOT is_special) %]
141         <input name='page' type='hidden' value="0" />
142         [% END %]
143         [% IF is_advanced;
144             FOR p IN CGI.params.keys;
145                 NEXT UNLESS p.match('^fi:');
146                 NEXT IF p.match('^fi:search_format');
147                 FOR pv IN CGI.params.$p;
148                     %]<input type="hidden" name="[% p | html %]" value="[% pv | html %]" />[%
149                 END;
150             END;
151         END %]
152         [% IF is_special %]
153             <input type="hidden" name="_special" value="1" /> [%
154             number_of_expert_rows = CGI.param('tag').list.size;
155             index = 0;
156             WHILE index < number_of_expert_rows %]
157                 <input type="hidden" name="tag" value="[% CGI.param('tag').list.$index | html %]" />
158                 <input type="hidden" name="subfield" value="[% CGI.param('subfield').list.$index | html %]" />
159                 <input type="hidden" name="term" value="[% CGI.param('term').list.$index | html %]" />
160                 [% index = index + 1; %]
161             [% END %]
162         [% END %]
163     </div>
164     [%- END %]
165     [% UNLESS took_care_of_form %]
166         [% IF ctx.default_sort %]
167             <input type="hidden" name="sort" value="[% ctx.default_sort %]"/>
168         [% END %]
169         </form>
170     [% END %]
171     [% IF fcount > 0 %]
172       <div class="refine_search result_block_visible">
173         <span id="filter_hits">[ <a href="#" onclick="getAdvLimits();return false;">[% l('[quant,_1,filter,filters] applied', fcount) %]</a> ]</span>
174       </div>
175     [% END %]
176     [% IF ctx.query_struct.filters.size > 0 %]
177         [% stuff = INCLUDE 'opac/parts/result/adv_filter.tt2' %]
178         [% IF stuff %]
179         <h3 class="sr-only">[% l('Search Results filters') %]</h3>
180         <div id="adv_filter_results_block" class="adv_filter_results_hide">
181         <span class="adv_filter_results_block_label">[% l('Filtered by:') %]</span>
182             [% stuff %]
183         </div>
184         [% END %]
185     [% END %]
186     [% IF ctx.search_summary.suggestions.one_class_multi_term %]
187     <div class="result_block_visible refine_search" id="did_you_mean">
188         <em><strong>[% s_list = ctx.search_summary.suggestions.one_class_multi_term; l('Did you mean: ') %]</strong></em><ul class="suggestion refine_search">
189         [% FOREACH s IN s_list.suggestions %]
190             <li class="suggestion refine_search">
191               <a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>s_list.class, query=>s.suggestion}) %]">[% s.prefix_key || s.suggestion | html %]</a>
192             </li>
193         [% END %]</ul>
194     </div>
195     <br/>
196     [% END %]
197     [% IF (is_advanced AND NOT is_special) AND CGI.param('qtype') %]
198     <div class="refine_search result_block_visible">
199         <span id="refine_search_link">[ <a href="[% mkurl(ctx.opac_root _ '/advanced') %]">[%
200             l('Refine My Original Search')
201         %]</a> ]</span>
202     </div>
203     [% END %]
204
205     <script>
206     function getAdvLimits() {
207         var AdvLimitsClass = document.getElementById('adv_filter_results_block').classList;
208         if (AdvLimitsClass.contains("adv_filter_results_hide")) {
209            AdvLimitsClass.remove("adv_filter_results_hide");
210         } else {
211            AdvLimitsClass.add("adv_filter_results_hide");
212         }
213         if (AdvLimitsClass.contains("adv_filter_results_show")) {
214            AdvLimitsClass.remove("adv_filter_results_show");
215         } else {
216            AdvLimitsClass.add("adv_filter_results_show");
217         }
218      }
219      </script>
220     <!-- Canonicalized query:
221
222     [% ctx.canonicalized_query | html %]
223
224     -->
225     <!--
226     <div id="breadcrumb">
227         <a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> &gt;
228     </div>
229     -->
230     <div class="clear-both"></div>
231 </div>