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