Bug 23099: OPAC Search result sorting "go" button flashes on page load
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-results-grouped.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
5 [% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo;
8 [% IF ( searchdesc ) %]
9     Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %]
10 [% ELSE %]
11     You did not specify any search criteria.
12 [% END %]</title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 [% BLOCK cssinclude %][% END %]
15 <link rel="alternate" type="application/rss+xml" title="Koha - RSS" href="/cgi-bin/koha/opac-rss.pl?[% query_cgi | $raw %][% limit_cgi | url %]" />
16
17 </head>
18 [% INCLUDE 'bodytag.inc' bodyid='results-grouped' %]
19 [% INCLUDE 'masthead.inc' %]
20
21     <div class="main">
22         <ul class="breadcrumb">
23             <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
24             <li>
25                 [% IF ( searchdesc ) %]
26                     <a href="#">Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %]</a>
27                 [% ELSE %]
28                     <a href="#">You did not specify any search criteria.</a>
29                 [% END %]
30             </li>
31         </ul>
32
33         [% IF ( query_error ) %]
34             <div class="container-fluid">
35                 <div class="row-fluid">
36                     <div class="span12">
37                         <div class="alert">
38                             <h4>Error:</h4>
39                             <p>[% query_error | html %]</p>
40                         </div>
41                     </div> <!-- / .span12 -->
42                 </div> <!-- / .row-fluid -->
43             </div> <!-- / .container-fluid -->
44         [% END %]
45
46         <div class="container-fluid">
47             <div class="row-fluid">
48                 [% IF ( opacfacets && total ) %]
49                     <div class="span2">
50                         <div id="facetcontainer">
51                             <!-- FACETS START -->
52                             [% INCLUDE 'opac-facets.inc' %]
53                             <!-- FACETS END -->
54                         </div>
55                     </div>
56                     <div class="span10">
57                 [% ELSE %]
58                     <div class="span12">
59                 [% END %]
60                     <div id="grouped-results">
61                         <!-- Search Results Table -->
62                         [% IF ( total ) %]
63                             [% IF ( scan ) %]
64                                 <h1>Scan index:</h1>
65                                     <form action="/cgi-bin/koha/opac-search.pl" method="get">
66                                         <table>
67                                             <tbody>
68                                                 <tr>
69                                                     <td>
70                                                         Scan index for: <input type="text" name="q" id="scan-index" size="35" value="" />
71                                                     </td>
72                                                 </tr>
73                                                 <tr>
74                                                     <td>
75                                                         <label for="scan-index">Indexed in:</label>
76                                                         <select name="idx" id="scan-index">
77                                                             <option value="">Any word</option>
78                                                             <option value="kw,phr:">Any phrase</option>
79                                                             <option value="ti:">Title</option>
80                                                             <option value="ti,phr:">Title phrase</option>
81                                                             <option value="au,phr:">Author</option>
82                                                             <option value="su:">Subject</option>
83                                                             <option value="su,phr:">Subject phrase</option>
84                                                             <option value="se:">Series</option>
85                                                             <option value="pb:">Publisher</option>
86                                                             <option value="nt:">Notes</option>
87                                                             <option value="se:">Series Title</option>
88                                                             <option value="sn:">ISBN</option>
89                                                             <option value="ss:">ISSN</option>
90                                                         </select>
91                                                         <input type="hidden" name="scan" value="1" />
92                                                     </td>
93                                                 </tr>
94                                             </tbody>
95                                         </table>
96                                     </form>
97
98                                     <form action="/cgi-bin/koha/opac-search.pl" method="get">
99                                         <table>
100                                             <thead>
101                                                 <tr>
102                                                     <th>Term/Phrase</th>
103                                                     <th>Count</th>
104                                                 </tr>
105                                             </thead>
106                                             <tbody>
107                                                 [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
108                                                 <tr>
109                                                     <td>
110                                                         <a href="/cgi-bin/koha/opac-search.pl?q=[% SEARCH_RESULT.scan_use |url %]&quot;[% SEARCH_RESULT.title |url %]&quot;"><span class="biblio-title">[% SEARCH_RESULT.title | html %]</span></a>
111                                                     </td>
112                                                     <td>
113                                                         [% FOREACH subtitl IN SEARCH_RESULT.subtitle.split(' | ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
114                                                             <span class="subtitle">[% subtitl | html %]</span>
115                                                         [% END %]
116                                                         <span class="part-number">[% SEARCH_RESULT.part_number | html %]</span> <span class="part-name">[% SEARCH_RESULT.part_name | html %]</span>
117                                                     </td>
118                                                 </tr>
119                                                 [% END %]
120                                             </thead>
121                                         </table>
122                                     </form>
123                             [% ELSE %]
124
125                                 <div class="searchresults">
126                                     <form action="/cgi-bin/koha/opac-search.pl" method="get" name="bookbag_form" id="bookbag_form">
127                                         [% IF ( searchdesc ) %]
128                                             [% FOREACH QUERY_INPUT IN QUERY_INPUTS %]
129                                                 <input type="hidden" name="[% QUERY_INPUT.input_name | html %]" value="[% QUERY_INPUT.input_value | html %]"/>
130                                             [% END %]
131                                             [% FOREACH LIMIT_INPUT IN LIMIT_INPUTS %]
132                                                 <input type="hidden" name="[% LIMIT_INPUT.input_name | html %]" value="[% LIMIT_INPUT.input_value | html %]"/>
133                                             [% END %]
134                                         [% END %]
135
136                                         <!-- TABLE RESULTS START -->
137                                         <table class="table table-striped">
138                                             <tr>
139                                                 <td colspan="3" class="resultscontrol">
140                                                     <div class="resort">
141                                                         <select id="sort_by" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
142                                                         <input type="submit" class="submit clearfix" id="sortsubmit" value="Go" />
143                                                     </div>
144                                                     [% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
145                                                         <div class="cartlist"><span class="checkall"></span>
146                                                         <span class="clearall"></span>
147                                                         <a href="#" class="highlight_toggle" id="highlight_toggle_off">Unhighlight</a>
148                                                         <a href="#" class="highlight_toggle" id="highlight_toggle_on">Highlight</a>
149                                                         <span class="addto"></span></div>
150                                                     [% END %]
151                                                 </td>
152                                             </tr>
153                                             <!-- Actual Search Results -->
154                                             [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
155                                                 <tr class="grouplabel"><td colspan="3">[% SEARCH_RESULT.group_label | html %]</td></tr>
156                                                 [% FOREACH GROUP_RESULT IN SEARCH_RESULT.GROUP_RESULTS %]
157                                                     [% IF ( GROUP_RESULT.even ) %]
158                                                         <tr class="highlight">
159                                                     [% ELSE %]
160                                                         <tr>
161                                                     [% END %]
162                                                         <td>
163                                                             [% IF ( AdlibrisEnabled && GROUP_RESULT.normalized_isbn ) %]
164                                                                 <img src="[% AdlibrisURL | html %]?isbn=[% GROUP_RESULT.normalized_isbn | html %]" class="adlibris-cover" alt="Adlibris cover image" />
165                                                             [% END %]
166                                                             [% IF ( OPACAmazonCoverImages ) %]
167                                                                 <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]">[% IF ( GROUP_RESULT.isbn ) %]<img src="https://images-na.ssl-images-amazon.com/images/P/[% GROUP_RESULT.isbn | html %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />[% ELSE %]<img src="http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif" alt="" class="thumbnail" />[% END %]
168                                                             </a>
169                                                         [% ELSE %]
170                                                             [% UNLESS ( noItemTypeImages ) %]
171                                                                 [% IF ( GROUP_RESULT.imageurl ) %]
172                                                                     <img src="[% GROUP_RESULT.imageurl | html %]" title="[% GROUP_RESULT.description | html %]" />
173                                                                 [% END %]
174                                                             [% END %]
175                                                             [% GROUP_RESULT.description | html %]
176                                                         [% END %]
177                                                         </td>
178                                                         <td>
179                                                             [% GROUP_RESULT.result_number | html %].
180                                                             [% IF ( GROUP_RESULT.BiblioDefaultViewmarc ) %]
181                                                                 <a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
182                                                             [% ELSE %]
183                                                                 [% IF ( GROUP_RESULT.BiblioDefaultViewisbd ) %]
184                                                                     <a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
185                                                                 [% ELSE %]
186                                                                     <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
187                                                                 [% END %]
188                                                                 [% FOREACH subtitl IN GROUP_RESULT.subtitle %]
189                                                                     [% subtitl | html %]
190                                                                 [% END %]
191                                                                 </a>
192                                                             [% END # / IF GROUP_RESULT.BiblioDefaultViewmarc %]
193                                                             [% IF ( GROUP_RESULT.author ) %]
194                                                                 by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% GROUP_RESULT.author |url %]" title="Search for works by this author">[% GROUP_RESULT.author | html %]</a>
195                                                             [% ELSE %]
196                                                                 &nbsp;
197                                                             [% END %]
198                                                             <p>
199                                                                 [% IF ( GROUP_RESULT.publicationyear ) %] - [% GROUP_RESULT.publicationyear | html %][% END %]
200                                                                 [% IF ( GROUP_RESULT.publishercode ) %]- [% GROUP_RESULT.publishercode | html %][% END %]
201                                                                 [% IF ( GROUP_RESULT.place ) %] ; [% GROUP_RESULT.place | html %][% END %]
202                                                                 [% IF ( GROUP_RESULT.pages ) %] - [% GROUP_RESULT.pages | html %][% END %]
203                                                                 [% IF ( GROUP_RESULT.notes ) %] : [% GROUP_RESULT.notes | html %][% END %]
204                                                                 [% IF ( GROUP_RESULT.size ) %] ; [% GROUP_RESULT.size | html %][% END %]
205                                                                 [% IF ( GROUP_RESULT.timestamp ) %] <i>(modified on [% GROUP_RESULT.timestamp | html %])</i>[% END %]
206                                                             </p>
207                                                             [% IF ( GROUP_RESULT.searchhighlightblob ) %]
208                                                                 <p class="searchhighlightblob">[% GROUP_RESULT.searchhighlightblob | html %]</p>
209                                                             [% END %]
210                                                             <p class="availability">
211                                                                 [% IF ( GROUP_RESULT.available_items_loop ) %]
212                                                                     <span class="available"><strong>Items available at:</strong>
213                                                                         [% FOREACH available_items_loo IN GROUP_RESULT.available_items_loop %]
214                                                                             [% IF ( available_items_loo.branchname ) %][% available_items_loo.branchname | html %][% END %]
215                                                                             [% IF ( OPACItemsResultsDisplay ) %]
216                                                                                 [% IF ( available_items_loo.location ) %]<span class="shelvingloc">[% available_items_loo.location | html %]</span>[% END %]
217                                                                                 [% IF ( available_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% available_items_loo.itemcallnumber |url %]">[% available_items_loo.itemcallnumber | html %]</a>][% END %]
218                                                                             [% END %]
219                                                                             ([% available_items_loo.count | html %]),
220                                                                         [% END # / FOREACH available_items_loo %]
221                                                                     </span>
222                                                                 [% ELSE %]
223                                                                     <span class="unavailable">No items available:</span>
224                                                                 [% END # / IF GROUP_RESULT.available_items_loop %]
225                                                                 <span class="unavailable">
226                                                                     [% IF ( GROUP_RESULT.onloancount ) %] Checked out ([% GROUP_RESULT.onloancount | html %]), [% END %]
227                                                                     [% IF ( GROUP_RESULT.withdrawncount ) %] Withdrawn ([% GROUP_RESULT.withdrawncount | html %]), [% END %]
228                                                                     [% IF ( GROUP_RESULT.itemlostcount ) %] Lost ([% GROUP_RESULT.itemlostcount | html %]),[% END %]
229                                                                     [% IF ( GROUP_RESULT.damagedcount ) %] Damaged ([% GROUP_RESULT.damagedcount | html %]),[% END %]
230                                                                     [% IF ( GROUP_RESULT.orderedcount ) %] On order ([% GROUP_RESULT.orderedcount | html %]),[% END %]
231                                                                     [% IF ( GROUP_RESULT.intransitcount ) %] In transit ([% GROUP_RESULT.intransitcount | html %]),[% END %]
232                                                                 </span>
233                                                             </p>
234                                                             <p>
235                                                                 [% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
236                                                                     [% UNLESS ( GROUP_RESULT.norequests ) %]
237                                                                         [% IF Koha.Preference( 'opacuserlogin' ) == 1 && GROUP_RESULT.holdable %]
238                                                                             <a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber | html %]">Place hold</a><!-- add back when available 0 holds in queue-->
239                                                                         [% END %]
240                                                                     [% END %]
241                                                                 [% END %]
242
243                                                                 [% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
244                                                                     <input type="checkbox" name="biblionumber" value="[% GROUP_RESULT.biblionumber | html %]" title="Click to add to cart" /> <label for="bib[% GROUP_RESULT.biblionumber | html %]">
245                                                                 [% END %]
246                                                                 <img src="[% themelang | html %]/images/[% GROUP_RESULT.itemtype | html %].gif" alt="[% GROUP_RESULT.ccode | html %]" title="[% GROUP_RESULT.ccode | html %]" />
247                                                                 [% IF ( ( Koha.Preference( 'opacbookbag' ) = 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]</label>[% END %]
248                                                                 [% IF ( GROUP_RESULT.classification ) %]
249                                                                     <a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% GROUP_RESULT.classification |url %]"> [% GROUP_RESULT.classification | html %] </a>
250                                                                 [% END %]
251                                                             </p>
252                                                         </td>
253                                                     </tr>
254                                                 [% END # / FOREACH GROUP_RESULT %]
255                                             [% END # / FOREACH SEARCH_RESULTS %]
256                                         </table>
257                                     </form>
258                                 </div> <!-- / .searchresults -->
259                             [% END # /  IF scan %]
260                             [% INCLUDE 'page-numbers.inc' %]
261                         [% END # / IF total %]
262
263                         [% IF Koha.Preference( 'suggestion' ) == 1 && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername || Koha.Preference( 'ILLModule' ) == 1 ) %]
264                             <div class="suggestion">
265                                 Not finding what you're looking for?
266                                 <ul>
267                                     [% IF Koha.Preference( 'AnonSuggestions' ) == 1 %]
268                                         <li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
269                                     [% ELSE %]
270                                         [% IF ( loggedinusername ) %]
271                                             <li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
272                                         [% END %]
273                                     [% END %]
274                                     [% IF Koha.Preference( 'ILLModule' ) == 1 && loggedinusername %]
275                                         <li>Make an <a href="/cgi-bin/koha/opac-illrequests.pl?op=create">Interlibrary loan request</a></li>
276                                     [% END %]
277                                 </ul>
278                             </div>
279                         [% END %]
280                     </div> <!-- / #grouped-results -->
281                 </div> <!-- /.span10/12 -->
282             </div> <!-- / .row-fluid -->
283         </div> <!-- / .container-fluid -->
284     </div><!-- / .main -->
285
286 [% INCLUDE 'opac-bottom.inc' %]
287 [% BLOCK jsinclude %]
288 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
289 <script>
290 //<![CDATA[
291
292 var q_array = new Array();  // will hold the search terms, if possible
293
294 $(document).ready(function(){
295     [% IF ( OpacHighlightedWords ) %]
296         $('a.title').each(function() {
297             $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
298         });
299     [% END %]
300
301     $('#sort_by').change(function() {
302         $('#bookbag_form').submit();
303     });
304     $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">" + _("Clear all") + "</a>");
305     $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">" + _("Select all") + "</a>");
306     $("span.addto").html("<label for=\"addto\">" + _("Add to: ") + "</label><select name=\"addto\" id=\"addto\"><option value=\"\"></option>[% IF Koha.Preference( 'opacbookbag' ) == 1 %]<option value=\"addtocart\">" + _("Cart") + "</option>[% END %][% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %]<optgroup label=\"" + _("Lists:") + "\">[% IF ( barshelves ) %][% FOREACH barshelvesloo IN barshelvesloop %][% IF ( category == 1 ) %]<option id=\"s[% barshelvesloo.shelfnumber | html %]\" value=\"addtolist\">[% barshelvesloo.shelfname | html %]</option>[% END %][% END %][% END %]<option value=\"newlist\">" + _("[ New list ]") + "</option></optgroup>[% ELSE %]<option value=\"newlist\">" + _("List") + "</option>[% END %][% END %]</select> <input type=\"submit\" class=\"submit\" value=\"" + _("Save") + "\" />");
307     $("#addto").change(function(){
308         cartList();
309     });
310     $(".addto").find("input:submit").click(function(){
311         cartList();
312         return false;
313     });
314     function cartList(){
315             if($("#addto").find("option:selected").attr("value") == "addtolist"){
316             var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
317             [% IF ( loggedinusername ) %]if (vShelfAdd()) {
318             Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?selectedshelf='+shelfnumber+'&' + vShelfAdd());
319             }[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
320             return false;
321         } else if($("#addto").find("option:selected").attr("value") == "newlist"){
322             [% IF ( loggedinusername ) %]if (vShelfAdd()) {
323             Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?newshelf=1&' + vShelfAdd());
324             }[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
325             return false;
326         }
327         if($("#addto").find("option:selected").attr("value") == "addtocart"){
328             addMultiple();
329             return false;
330          }
331     }
332     $("#CheckAll").click(function(){
333         $("#bookbag_form").checkCheckboxes();
334         return false;
335     });
336     $("#CheckNone").click(function(){
337         $("#bookbag_form").unCheckCheckboxes();
338         return false;
339     });
340     [% IF ( query_desc ) %]
341     var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
342     q_array = query_desc.split(" ");
343     // ensure that we don't have "" at the end of the array, which can
344     // break the highlighter
345     while (q_array.length > 0 && q_array[q_array.length-1] == "") {
346         q_array = q_array.splice(0,-1);
347     }
348     highlightOn();
349     $("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;});
350     $("#highlight_toggle_off").show().click(function() {highlightOff();});
351     [% END %]
352 });
353
354 function highlightOff() {
355     $("td").removeHighlight();
356     $(".highlight_toggle").toggle();
357 }
358 function highlightOn() {
359     var x;
360     for (x in q_array) {
361         q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1");
362         q_array[x] = q_array[x].toLowerCase();
363         var myStopwords = "[% Koha.Preference('NotHighlightedWords') | html %]".toLowerCase().split('|');
364         if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) {
365             $("td").highlight(q_array[x]);
366         }
367     }
368     $(".highlight_toggle").toggle();
369 }
370 //]]>
371 </script>
372 [% END %]