Show/hide facets & search results in mobile mode
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / result / table.tt2
1 [%  PROCESS "opac/parts/misc_util.tt2";
2
3     USE ResolverResolver;
4
5     ctx.result_start = 1 + ctx.page_size * page;
6     ctx.result_stop = ctx.page_size * (page + 1);
7     IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
8
9     result_count = ctx.result_start;
10
11 %]
12
13 [% PROCESS "opac/parts/result/paginate.tt2" %] 
14 [% ctx.results_count_header = PROCESS results_count_header;
15     ctx.results_count_header %]
16 [% IF ctx.bookbag %]
17 <div id="result-bookbag-heading">
18     <div class="result-bookbag-name">[% ctx.bookbag.name | html %]</div>
19     <div class="result-bookbag-description">[% ctx.bookbag.description | html %]</div>
20 </div>
21 [% END %]
22 <div id="result_table_div">
23             <div id="result_block" class="result_block_visible">
24                 <div id="refine_hits"><a onclick="getFacety();">[% l('Refine these results') %]</a></div>
25                 <table cellpadding="0" cellspacing="0"
26                     border="0" style="margin-top:10px;">
27                     <tbody id="result_table">
28                     [%  FOR rec IN ctx.records;
29                             attrs = {marc_xml => rec.marc_xml};
30                             PROCESS get_marc_attrs args=attrs;
31                             IF CGI.param('detail_record_view');
32                                 attrs.title = attrs.title_extended;
33                             END;
34                     -%]
35                         <tr class="result_table_row">
36                                             <td class="results_row_count" name="results_row_count">[%
37                                                     result_count; result_count = result_count + 1
38                                                 %].</td>
39                                             <td class='result_table_pic_header'>
40                                                 [% ident = attrs.isbn_clean || attrs.upc; IF ident; %]
41                                                 <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"><img alt="[% l('Image of item') %]"
42                                                         name='item_jacket' class='result_table_pic' width="55"
43                                                         src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ident | uri %]' /></a><br />
44                                                 [% END %]
45                                             </td>
46                                             <td class='result_table_title_cell' name='result_table_title_cell'>
47                                                <div class="result_metadata">
48                                                     <abbr class="unapi-id" title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:biblio-record_entry/[% rec.id %]'></abbr>
49                                                     <a class='record_title' name='record_[% rec.id %]' name='item_title'
50                                                         href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"
51                                                         [% HTML.attributes(title => l('Display record details for "[_1]"', attrs.title)) %]
52                                                         class='search_link'>[% attrs.title | html %]</a>
53 [%-
54 FOR entry IN attrs.graphic_titles;
55     FOR alt IN entry.graphic;
56         diratt = "";
57         IF alt.dir;
58             diratt = ' dir="' _ alt.dir _ '"';
59         END;
60 -%]
61 <div class="graphic880"[% diratt %]>
62     [% alt.value | html %]
63 </div>
64 [%-
65     END;
66 END;
67 -%]
68  
69                                                     <div>
70                                                         <a title="[% l("Perform an Author Search") %]"
71                                                                 class="record_author" name='item_author'
72                                                                 href="[%- 
73                                                                     authorquery = attrs.author | replace('[#"^$\+\-,\.:;&|\[\]()]', ' ');
74                                                                     mkurl(ctx.opac_root _ '/results', {qtype => 'author', query => authorquery}, ['page'])
75                                                                     -%]">[% attrs.author | html %]</a>
76 [%-
77 FOR entry IN attrs.graphic_authors;
78     FOR alt IN entry.graphic;
79         diratt = "";
80         IF alt.dir;
81             diratt = ' dir="' _ alt.dir _ '"';
82         END;
83 -%]
84 <div class="graphic880"[% diratt %]>
85     [% alt.value | html %]
86 </div>
87 [%-
88     END;
89 END;
90 -%]
91
92                                                     </div>
93                                                     <div id='bib_format' class='result_table_title_cell'>
94                                                     [%- IF attrs.format_label; %]
95                                                         [% attrs.format_label; %]
96                                                     [%- END %]
97                                                     [%- UNLESS CGI.param('detail_record_view')
98                                                             OR (show_more_details.default == 'true'
99                                                             OR show_more_details.default == 'hide');
100                                                             IF attrs.pubdate;
101                                                                 pubdate_clean = attrs.pubdate | html;
102                                                                 l(" ([_1])", pubdate_clean);
103                                                             END;
104                                                         END
105                                                     -%]
106                                                     </div>
107                                                     <span name="googleBooksLink" class="hide_me">
108                                                         <a style='padding-left: 8px;'
109                                                             class='classic_link hide_me'
110                                                             name="googleBooks-link">[% l("Browse in Google Books Search") %]</a>
111                                                     </span>
112                                                     <table cellpadding="0" cellspacing="0" border="0"
113                                                         class="results_info_table">
114                                                         [% IF args.holdings.size > 0 %]
115                                                         <tr name='bib_cn_list' class='result_table_title_cell'>
116                                                             <td valign='top'>
117                                                                 <strong>[% l('Call number:') %]</strong>
118                                                             </td>
119                                                             <td>[% args.holdings.0.label | html %]</td>
120                                                         </tr>
121                                                         [% END %]
122
123                                                         [% IF CGI.param('detail_record_view') %]
124                                                         <!-- These fields are visible when viewing the results page in 'detailed' mode -->
125
126                                                         [% IF attrs.pubinfo %]
127                                                             <tr name="results_pub_tr">
128                                                                 <td valign="top">
129                                                                     <strong>[% l('Publisher:') %]</strong>
130                                                                 </td>
131                                                                 <td>[% attrs.pubinfo | html %]
132 [%-
133 FOR entry IN attrs.graphic_pubinfos;
134     FOR alt IN entry.graphic;
135         diratt = "";
136         IF alt.dir;
137             diratt = ' dir="' _ alt.dir _ '"';
138         END;
139 -%]
140 <div class="graphic880"[% diratt %]>
141     [% alt.value | html %]
142 </div>
143 [%-
144     END;
145 END;
146 -%]
147 </td>
148                                                             </tr>
149                                                         [% END %]
150                                                         [% IF attrs.isbns.size > 0 %]
151                                                             <tr name="results_isbn_tr">
152                                                                 <td valign="top">
153                                                                     <strong>[% l('ISBN:') %]</strong>
154                                                                 </td>
155                                                                 <td>[% attrs.isbns.0 | html %]</td>
156                                                             </tr>
157                                                         [% END %]
158                                                         [%- IF attrs.issns.size > 0 %]
159                                                             <tr name="results_issn_tr">
160                                                                 <td valign="top">
161                                                                     <strong>[% l('ISSN:') %]</strong>
162                                                                 </td>
163                                                                 <td>[% attrs.issns.0 | html %]</td>
164                                                             </tr>
165                                                         [%- END %]
166                                                         [%- IF openurl.enabled == 'true';
167                                                             FOREACH issn IN args.issns;
168                                                                 NEXT IF issn == '';
169                                                                 res_urls = ResolverResolver.resolve_issn(issn, openurl.baseurl);
170                                                                 FOREACH res IN res_urls;
171                                                         %]
172                                                         <tr name="results_issn_tr">
173                                                             <td valign="top">
174                                                                 <strong><a href="[% res.target_url %]">
175                                                                 [% res.public_name | html %]</a></strong>
176                                                             </td>
177                                                             <td>[% res.target_coverage | html %]</td>
178                                                         </tr>
179                                                                 [% END %]
180                                                             [% END %]
181                                                         [% END %]
182
183                                                         [% IF attrs.edition %]
184                                                             <tr name="results_edition_tr">
185                                                                 <td valign="top">
186                                                                     <strong>[% l('Edition:') %]</strong>
187                                                                 </td>
188                                                                 <td>[% attrs.edition | html %]
189 [%-
190 FOR entry IN attrs.graphic_editions;
191     FOR alt IN entry.graphic;
192         diratt = "";
193         IF alt.dir;
194             diratt = ' dir="' _ alt.dir _ '"';
195         END;
196 -%]
197 <div class="graphic880"[% diratt %]>
198     [% alt.value | html %]
199 </div>
200 [%-
201     END;
202 END;
203 -%]
204 </td>
205                                                             </tr>
206                                                         [% END %]
207                                                         [% IF attrs.phys_desc %]
208                                                             <tr name="results_phys_desc_tr">
209                                                                 <td nowrap="nowrap" valign="top">
210                                                                     <strong>[% l('Phys. Desc.:') %]</strong>
211                                                                 </td>
212                                                                 <td>
213                                                                     [% args.phys_desc | html %]
214                                                                 </td>
215                                                             </tr>
216                                                         [% END %]
217                                                         [% FOR uri IN args.uris %]
218                                                             <tr name='bib_uri_list' class='result_table_title_cell'>
219                                                                 <td valign='top'>
220                                                                     <strong>[% l('Electronic resource') %]</strong>
221                                                                 </td>
222                                                                 <td><a href="[% uri.href %]">[% uri.link | html %]</a>[% ' - ' _ uri.note | html IF uri.note %]</td>
223                                                             </tr>
224                                                             [% END %]
225                                                             [%- IF args.holdings.size > 0;
226                                                                 FOREACH copy IN args.holdings;
227                                                                     IF copy.part_label != '';
228                                                                         has_parts = 'true';
229                                                                         LAST;
230                                                                     END;
231                                                                 END;
232                                                             %]
233                                                             <tr name='bib_cn_list' class='result_table_title_cell'>
234                                                                 <td colspan='2'>
235                                                                     <table class='result_holdings_table'>
236                                                                         <thead><tr>
237                                                                             <th>[% l('Library') %]</th>
238                                                                             <th>[% l('Shelving location') %]</th>
239                                                                             <th>[% l('Call number') %]</th>
240                                                                             [%- IF has_parts == 'true'; %]
241                                                                             <th>[% l('Part') %]</th>
242                                                                             [%- END %]
243                                                                             <th>[% l('Status') %]</th>
244                                                                         </tr></thead>
245                                                                         <tbody>
246                                                                 [% FOR copy IN args.holdings %]
247                                                                         <tr>
248                                                                             <td>
249 [%-
250     lib_url = ctx.get_org_setting(copy.circ_lib, 'lib.info_url');
251     IF lib_url; '<a href="'; lib_url | url; '">'; END;
252     copy.library | html;
253     IF lib_url; '</a>'; END;
254 -%]
255                                                                             </td>
256                                                                             <td>[% copy.location | html %]</td>
257                                                                             <td>[% copy.label | html %]</td>
258                                                                             [%- IF has_parts == 'true'; %]
259                                                                             <td>[% copy.part_label %]</td>
260                                                                             [%- END %]
261                                                                             <td>[% copy.status | html %]</td>
262                                                                         </tr>
263                                                                 [% END %]
264                                                                         </tbody>
265                                                                     </table>
266                                                                 </td>
267                                                             </tr>
268                                                             [%- has_parts = 'false';
269                                                                 END;
270                                                              %]
271                                                         [% END %] <!-- END detail_record_view -->
272                                                     </table>
273                                                     [% PROCESS "opac/parts/result/copy_counts.tt2" %]
274                                                     [% IF rec.user_circulated %]
275                                                     <div class="result_item_circulated">
276                                                         <img src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('Checked Out Before') %]"/>
277                                                         <span>[% l('I have checked this item out before') %]</span>
278                                                     </div>
279                                                     [% END %]
280                                                     [% IF ctx.bookbag;
281                                                         rec_id = rec.id;
282                                                         FOR note IN ctx.bookbag_items_by_bre_id.$rec_id.notes %]
283                                                     <div class="result-bookbag-item-note">
284                                                         [% note.note | html %]
285                                                     </div>
286                                                         [% END %]
287                                                     [% END %]
288                                                 </div>
289                                                 <div class="result_table_utils_cont">
290                                                     <div class="result_table_utils">
291 [%- search_ou = ctx.search_ou;
292     num_holdable_copies = attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size || 0;
293     IF ctx.place_unfillable ||
294         ( num_holdable_copies > 0
295             && (ctx.holds_block.enabled != 'true' || attrs.org_copy_counts.$search_ou.available == 0)
296         )
297 %]
298                                                         <div class="results_aux_utils place_hold"><a
299                                                                 href="[% mkurl(ctx.opac_root _ '/place_hold', 
300                                                                     {hold_target => rec.id, hold_type => 'T', hold_source_page => mkurl()}) %]" 
301                                                                     name="place_hold_link" class="no-dec"><img
302                                                                 src="[% ctx.media_prefix %]/images/green_check.png"
303                                                                 alt=""/><span class="result_place_hold">[% l('Place Hold') %]</span></a>
304                                                         </div>
305 [%- END -%]
306                                                         <div class="results_aux_utils result_util">
307                                                             [%  IF ctx.user;
308                                                                 INCLUDE "opac/parts/bookbag_actions.tt2";
309                                                             %]
310                                                             [%  ELSE;
311                                                                 operation = ctx.mylist.grep(rec.id).size ? "delete" : "add";
312                                                                 label = (operation == "add") ? l("Add to my list") : l("Remove from my list");
313                                                                 href = mkurl(ctx.opac_root _ '/mylist/' _ operation, 
314                                                                         {record => rec.id, anchor => 'record_' _ rec.id}, 1);
315                                                             %]      
316                                                             <a href="[% href %]" class="no-dec">
317                                                                 <img src="[% ctx.media_prefix %]/images/clipboard.png" alt="" />
318                                                                 [% label %]
319                                                             </a>
320                                                             [% END %]
321                                                         </div>
322                                                         [% IF ENV.OILS_CONTENT_CAFE_USER %]
323                                                         <div class="results_aux_utils result_util">
324                                                             <a title="[% l('Reviews and More') %]" target='_blank' 
325                                                                 href="[% ctx.ext_proto %]://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=[%- 
326                                                                     ENV.OILS_CONTENT_CAFE_USER %]&amp;Password=[%-
327                                                                     ENV.OILS_CONTENT_CAFE_PASS %]&amp;ItemKey=[% ident | uri %]&amp;Options=Y">
328                                                                 <img src='[% ctx.media_prefix %]/images/starz.png'/> 
329                                                                 <span class="results_reviews">[% l('Reviews &amp; More') %]</span>
330                                                             </a>
331                                                         </div>
332                                                         [% END %]
333                                                     </div>
334                                                 </div>
335
336                                             </td>
337
338                                         </tr>
339                                         [%- IF ENV.OILS_CHILIFRESH_ACCOUNT %]
340                                         <tr>
341                                             <td/>
342                                             <td align='center'> <!-- Chilifresh reviews link --> 
343                                                 <span class="chili_review" id="isbn_[% attrs.isbn_clean | html %]"> </span>
344                                             </td>
345                                         </tr>
346                                         <tr>
347                                             <td/>
348                                             <td colspan='5'> <!-- Chilifresh reviews panel -->
349                                                 <div id="chili_review_[% attrs.isbn_clean | html %]" style="display: none;" align="center"></div>
350                                             </td>
351                                         </tr>
352                                         [%- END %]
353                     [% END %]
354                     </tbody>
355                 </table>
356             </div>
357     <div class="facet_sidebar_hidden" id="facet_sidebar">
358         <div id="return_to_hits"><a onclick="getResulty();">[% l('Back to results') %]</a></div>
359     [% INCLUDE "opac/parts/staff_saved_searches.tt2" %]
360     [% INCLUDE 'opac/parts/result/facets.tt2' %]
361     </div>
362 </div>
363 <div class="result_footer_nav1">
364     [% ctx.results_count_header %]
365 </div>
366 <script>
367 resultBlock = document.querySelector('#result_block');
368 facetSidebar = document.querySelector('#facet_sidebar');
369 function getFacety() {
370     resultBlock.setAttribute('class', 'result_block_hidden');
371     facetSidebar.setAttribute('class', 'facet_sidebar_visible');
372     window.location.hash = 'facet_sidebar';
373 }
374 function getResulty() {
375     resultBlock.setAttribute('class', 'result_block_visible');
376     facetSidebar.setAttribute('class', 'facet_sidebar_hidden');
377     window.location.hash = 'result_block';
378 }
379 function moveFacets() {
380     var clientWidth = document.documentElement.clientWidth;
381     if (clientWidth >= 600) {
382         if (resultBlock && facetSidebar) {
383             resultBlock.parentNode.insertBefore(facetSidebar, resultBlock);
384         }
385     }
386 }
387 window.onresize = moveFacets;
388 window.onload = moveFacets;
389 </script>