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