commit of finished Evergreen skin as of September 2017
[equinox-eg-opac-skin.git] / skin / openils / var / templates_equinox / 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         <div class="search_box_row row">
50             <div id="search_box_keyword" class='search_box_wrapper col-3'>
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">
54                     [% l('Search: ') %]
55                 </label>
56                 <input type="text" id="search_box_hidden" name="query" aria-label="[%
57                         l('Enter search query:');
58                     %]" value="[% is_advanced ? ctx.naive_query_scrub(ctx.user_query) : CGI.param('query') | html %]" />
59             </div>
60
61             <div id="search_select_type" class="search_box_wrapper col-3">
62                 <label id="search_qtype_label" for="qtype">
63                     [%- l('Type: '); -%]
64                 </label>
65                 [%-
66                     INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
67                 -%]
68             </div>
69
70             <div id="search_select_format" class="search_box_wrapper col-3">
71                 <label id="search_itype_label" for="search_itype_selector">
72                     [%- l('Format: '); -%]
73                 </label>
74                 [%-
75                     IF search.basic_config.type == 'attr';
76                         INCLUDE "opac/parts/coded_value_selector.tt2"
77                             attr=search.basic_config.group none_ok=1 
78                             id='search_itype_selector'
79                             none_label=search.basic_config.none_label;
80                     ELSIF search.basic_config.type == 'filter';
81                         INCLUDE "opac/parts/filter_group_selector.tt2"
82                             filter_group=search.basic_config.group none_ok=1 
83                             id='search_itype_selector'
84                             none_label=search.basic_config.none_label;
85                     END;
86                 -%]
87             </div>
88
89             <div id="select_search_library" class="search_box_wrapper col-3">
90                 <label id="search_locg_label" for="search_org_selector">
91                     [%- l('Library: '); -%]
92                 </label>
93                 [%-
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             </div>
99
100             <div id="search_submit_actions" class="search_submit_wrapper">
101                 <span>
102                     <input id="detail" type="hidden" name="detail_record_view" value="[% show_detail_view %]"/>
103                     <input id='search-submit-go' type="submit" value="[% l('Search') %]" class="opac-button [% IF ctx.depth_sel_button AND NOT took_care_of_form %] with-depth [% END %]"
104                         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)'/>
105                     [%- IF ctx.depth_sel_button AND NOT took_care_of_form %]
106                     <button id='search-submit-go-depth' type="submit" value="[% ctx.depth_sel_depth %]" name="depth" class="[% ctx.depth_sel_button_class %]"
107                         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>
108                     [%- END %]
109                     <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") %]'/>
110                 </span>
111             </div>
112         </div>
113
114     </div>
115     [% IF ctx.bookbag %]
116     <div id="search-only-bookbag-container">
117         <input type="checkbox" id="search-only-bookbag" name="bookbag"
118             value="[% ctx.bookbag.id | html %]" checked="checked" />
119         <label for="search-only-bookbag">
120             [% l('Search only within the chosen list') %]
121         </label>
122     </div>
123     [% END %]
124     [% IF is_advanced || is_special %]
125     <div>
126         <input type="hidden" name="_adv" value="1" />
127         [% IF ctx.processed_search_query OR (NOT is_advanced AND NOT is_special) %]
128         <input name='page' type='hidden' value="0" />
129         [% END %]
130         [% IF is_advanced;
131             FOR p IN CGI.params.keys;
132                 NEXT UNLESS p.match('^fi:');
133                 NEXT IF p.match('^fi:search_format');
134                 FOR pv IN CGI.params.$p;
135                     %]<input type="hidden" name="[% p | html %]" value="[% pv | html %]" />[%
136                 END;
137             END;
138         END %]
139         [% IF is_special %]
140             <input type="hidden" name="_special" value="1" /> [%
141             number_of_expert_rows = CGI.param('tag').list.size;
142             index = 0;
143             WHILE index < number_of_expert_rows %]
144                 <input type="hidden" name="tag" value="[% CGI.param('tag').list.$index | html %]" />
145                 <input type="hidden" name="subfield" value="[% CGI.param('subfield').list.$index | html %]" />
146                 <input type="hidden" name="term" value="[% CGI.param('term').list.$index | html %]" />
147                 [% index = index + 1; %]
148             [% END %]
149         [% END %]
150     </div>
151     [%- END %]
152     [% UNLESS took_care_of_form %]
153         [% IF ctx.default_sort %]
154             <input type="hidden" name="sort" value="[% ctx.default_sort %]"/>
155         [% END %]
156         </form>
157     [% END %]
158     [% IF fcount > 0 %]
159       <div class="refine_search result_block_visible">
160         <span id="filter_hits">[ <a href="#" onclick="getAdvLimits();return false;">[% l('[quant,_1,filter,filters] applied', fcount) %]</a> ]</span>
161       </div>
162     [% END %]
163     [% IF ctx.query_struct.filters.size > 0 %]
164         [% stuff = INCLUDE 'opac/parts/result/adv_filter.tt2' %]
165         [% IF stuff %]
166         <h3 class="sr-only">[% l('Search Results filters') %]</h3>
167         <div id="adv_filter_results_block" class="adv_filter_results_hide">
168         <span class="adv_filter_results_block_label">[% l('Filtered by:') %]</span>
169             [% stuff %]
170         </div>
171         [% END %]
172     [% END %]
173     [% IF (is_advanced AND NOT is_special) AND CGI.param('qtype') %]
174     <div class="refine_search result_block_visible">
175         <span id="refine_search_link">[ <a href="[% mkurl(ctx.opac_root _ '/advanced') %]">[%
176             l('Refine My Original Search')
177         %]</a> ]</span>
178     </div>
179     [% END %]
180
181     <script>
182     function getAdvLimits() {
183         var AdvLimitsClass = document.getElementById('adv_filter_results_block').classList;
184         if (AdvLimitsClass.contains("adv_filter_results_hide")) {
185            AdvLimitsClass.remove("adv_filter_results_hide");
186         } else {
187            AdvLimitsClass.add("adv_filter_results_hide");
188         }
189         if (AdvLimitsClass.contains("adv_filter_results_show")) {
190            AdvLimitsClass.remove("adv_filter_results_show");
191         } else {
192            AdvLimitsClass.add("adv_filter_results_show");
193         }
194      }
195      </script>
196     <!-- Canonicalized query:
197
198     [% ctx.canonicalized_query | html %]
199
200     -->
201     <!--
202     <div id="breadcrumb">
203         <a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> &gt;
204     </div>
205     -->
206     <div class="clear-both"></div>
207 </div>