]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/searchbar.tt2
c33a897cf3febfb5a4f4a5f627f44f91970c4bd6
[working/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 = ['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     </div>
48     <div class="searchbar">
49         <span class='search_box_wrapper'>
50             [%- # autosuggest breaks accessibility, as the aria-label
51                 # attribute is removed when the Dijit is created. :(  %]
52             <label id="search_box_label" for="search_box">[% l('Search: ') %]
53             <input type="text" id="search_box" name="query" aria-label="[%
54                     l('Enter search query:');
55                 %]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.user_query) : CGI.param('query') | html %]"
56                 [%- IF use_autosuggest.enabled == "t" %]
57                 dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
58                 submitter="this.textbox.form.submit();"
59                 [%-     IF use_autosuggest.value.search('opac_visible') %]
60                 store_args='{"org_unit_getter": function() { return [% ctx.search_ou %]; }}'
61                 [%-     END # opac_visible -%]
62                 [%- ELSE -%]
63                     [% IF basic_search != "f" %] autofocus [% END %] x-webkit-speech
64                 [%- END # autosuggest enabled %] />
65             </label>
66         </span>
67         <label id="search_qtype_label" for="qtype">
68         [%- 
69             l('Type: ');
70             INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
71         -%]
72         </label>
73         <label id="search_itype_label" for="search_itype_selector">
74         [%-
75             l('Format: ');
76             IF search.basic_config.type == 'attr';
77                 INCLUDE "opac/parts/coded_value_selector.tt2"
78                     attr=search.basic_config.group none_ok=1 
79                     id='search_itype_selector'
80                     none_label=search.basic_config.none_label;
81             ELSIF search.basic_config.type == 'filter';
82                 INCLUDE "opac/parts/filter_group_selector.tt2"
83                     filter_group=search.basic_config.group none_ok=1 
84                     id='search_itype_selector'
85                     none_label=search.basic_config.none_label;
86             END;
87         -%]
88         </label>
89         <label id="search_locg_label" for="search_org_selector">
90         [%- 
91             l('Library: ');
92             select_lib_label = l("Select search library");
93             INCLUDE build_org_selector arialabel=select_lib_label 
94               id='search_org_selector' show_loc_groups=1
95         -%]
96         </label>
97     <span>
98         <input id="detail" type="hidden" name="detail_record_view" value="[% show_detail_view %]"/>
99         <input id='search-submit-go' type="submit" value="[% l('Search') %]" class="opac-button"
100             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)'/>
101         [%- IF ctx.depth_sel_button AND NOT took_care_of_form %]
102         <button id='search-submit-go-depth' type="submit" value="[% ctx.depth_sel_depth %]" name="depth" class="[% ctx.depth_sel_button_class %]"
103             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>
104         [%- END %]
105         <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") %]'/>
106     </span>
107     </div>
108     [% IF ctx.bookbag %]
109     <div id="search-only-bookbag-container">
110         <input type="checkbox" id="search-only-bookbag" name="bookbag"
111             value="[% ctx.bookbag.id | html %]" checked="checked" />
112         <label for="search-only-bookbag">
113             [% l('Search only within the chosen list') %]
114         </label>
115     </div>
116     [% END %]
117     [% IF is_advanced || is_special %]
118     <div>
119         <input type="hidden" name="_adv" value="1" />
120         [% IF ctx.processed_search_query OR (NOT is_advanced AND NOT is_special) %]
121         <input name='page' type='hidden' value="0" />
122         [% END %]
123         [% IF is_advanced;
124             FOR p IN CGI.params.keys;
125                 NEXT UNLESS p.match('^fi:');
126                 NEXT IF p.match('^fi:search_format');
127                 FOR pv IN CGI.params.$p;
128                     %]<input type="hidden" name="[% p | html %]" value="[% pv | html %]" />[%
129                 END;
130             END;
131         END %]
132         [% IF is_special %]
133             <input type="hidden" name="_special" value="1" /> [%
134             number_of_expert_rows = CGI.param('tag').list.size;
135             index = 0;
136             WHILE index < number_of_expert_rows %]
137                 <input type="hidden" name="tag" value="[% CGI.param('tag').list.$index | html %]" />
138                 <input type="hidden" name="subfield" value="[% CGI.param('subfield').list.$index | html %]" />
139                 <input type="hidden" name="term" value="[% CGI.param('term').list.$index | html %]" />
140                 [% index = index + 1; %]
141             [% END %]
142         [% END %]
143     </div>
144     [%- END %]
145     [% UNLESS took_care_of_form %]
146         [% IF ctx.default_sort %]
147             <input type="hidden" name="sort" value="[% ctx.default_sort %]"/>
148         [% END %]
149         </form>
150     [% END %]
151     [% IF fcount > 0 %]
152       <div class="refine_search result_block_visible">
153         <span id="filter_hits">[ <a href="#" onclick="getAdvLimits();return false;">[% l('[quant,_1,filter,filters] applied', fcount) %]</a> ]</span>
154       </div>
155     [% END %]
156     [% IF ctx.query_struct.filters.size > 0 %]
157         [% stuff = INCLUDE 'opac/parts/result/adv_filter.tt2' %]
158         [% IF stuff %]
159         <h3 class="sr-only">[% l('Search Results filters') %]</h3>
160         <div id="adv_filter_results_block" class="adv_filter_results_hide">
161         <span class="adv_filter_results_block_label">[% l('Filtered by:') %]</span>
162             [% stuff %]
163         </div>
164         [% END %]
165     [% END %]
166     [% IF (is_advanced AND NOT is_special) AND CGI.param('qtype') %]
167     <div class="refine_search result_block_visible">
168         <span id="refine_search_link">[ <a href="[% mkurl(ctx.opac_root _ '/advanced') %]">[%
169             l('Refine My Original Search')
170         %]</a> ]</span>
171     </div>
172     [% END %]
173
174     <script>
175     function getAdvLimits() {
176         var AdvLimitsClass = document.getElementById('adv_filter_results_block').classList;
177         if (AdvLimitsClass.contains("adv_filter_results_hide")) {
178            AdvLimitsClass.remove("adv_filter_results_hide");
179         } else {
180            AdvLimitsClass.add("adv_filter_results_hide");
181         }
182         if (AdvLimitsClass.contains("adv_filter_results_show")) {
183            AdvLimitsClass.remove("adv_filter_results_show");
184         } else {
185            AdvLimitsClass.add("adv_filter_results_show");
186         }
187      }
188      </script>
189     <!-- Canonicalized query:
190
191     [% ctx.canonicalized_query | html %]
192
193     -->
194     <!--
195     <div id="breadcrumb">
196         <a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> &gt;
197     </div>
198     -->
199     <div class="clear-both"></div>
200 </div>