Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt
Owen Leonard a89a203c1c
Bug 23099: OPAC Search result sorting "go" button flashes on page load
There are a few places in the OPAC where we hide the submit button on a
sorting form because the form auto-submits when the selection changes.
These should be hidden using CSS instead of JS to prevent the temporary
appearance of the submit button while the page loads.

To test, apply the patch and rebuild the OPAC CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

Test OPAC search results and OPAC checkout history. On both pages you
should not see a "Go" button next to the <select> input for changing the
sort order.

Disable JavaScript in your browser and test those pages again. The "Go"
button should appear.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-08-05 15:03:20 +01:00

372 lines
27 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo;
[% IF ( searchdesc ) %]
Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %]
[% ELSE %]
You did not specify any search criteria.
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
<link rel="alternate" type="application/rss+xml" title="Koha - RSS" href="/cgi-bin/koha/opac-rss.pl?[% query_cgi | $raw %][% limit_cgi | url %]" />
</head>
[% INCLUDE 'bodytag.inc' bodyid='results-grouped' %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li>
[% IF ( searchdesc ) %]
<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>
[% ELSE %]
<a href="#">You did not specify any search criteria.</a>
[% END %]
</li>
</ul>
[% IF ( query_error ) %]
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="alert">
<h4>Error:</h4>
<p>[% query_error | html %]</p>
</div>
</div> <!-- / .span12 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
[% END %]
<div class="container-fluid">
<div class="row-fluid">
[% IF ( opacfacets && total ) %]
<div class="span2">
<div id="facetcontainer">
<!-- FACETS START -->
[% INCLUDE 'opac-facets.inc' %]
<!-- FACETS END -->
</div>
</div>
<div class="span10">
[% ELSE %]
<div class="span12">
[% END %]
<div id="grouped-results">
<!-- Search Results Table -->
[% IF ( total ) %]
[% IF ( scan ) %]
<h1>Scan index:</h1>
<form action="/cgi-bin/koha/opac-search.pl" method="get">
<table>
<tbody>
<tr>
<td>
Scan index for: <input type="text" name="q" id="scan-index" size="35" value="" />
</td>
</tr>
<tr>
<td>
<label for="scan-index">Indexed in:</label>
<select name="idx" id="scan-index">
<option value="">Any word</option>
<option value="kw,phr:">Any phrase</option>
<option value="ti:">Title</option>
<option value="ti,phr:">Title phrase</option>
<option value="au,phr:">Author</option>
<option value="su:">Subject</option>
<option value="su,phr:">Subject phrase</option>
<option value="se:">Series</option>
<option value="pb:">Publisher</option>
<option value="nt:">Notes</option>
<option value="se:">Series Title</option>
<option value="sn:">ISBN</option>
<option value="ss:">ISSN</option>
</select>
<input type="hidden" name="scan" value="1" />
</td>
</tr>
</tbody>
</table>
</form>
<form action="/cgi-bin/koha/opac-search.pl" method="get">
<table>
<thead>
<tr>
<th>Term/Phrase</th>
<th>Count</th>
</tr>
</thead>
<tbody>
[% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
<tr>
<td>
<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>
</td>
<td>
[% FOREACH subtitl IN SEARCH_RESULT.subtitle.split(' | ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
<span class="subtitle">[% subtitl | html %]</span>
[% END %]
<span class="part-number">[% SEARCH_RESULT.part_number | html %]</span> <span class="part-name">[% SEARCH_RESULT.part_name | html %]</span>
</td>
</tr>
[% END %]
</thead>
</table>
</form>
[% ELSE %]
<div class="searchresults">
<form action="/cgi-bin/koha/opac-search.pl" method="get" name="bookbag_form" id="bookbag_form">
[% IF ( searchdesc ) %]
[% FOREACH QUERY_INPUT IN QUERY_INPUTS %]
<input type="hidden" name="[% QUERY_INPUT.input_name | html %]" value="[% QUERY_INPUT.input_value | html %]"/>
[% END %]
[% FOREACH LIMIT_INPUT IN LIMIT_INPUTS %]
<input type="hidden" name="[% LIMIT_INPUT.input_name | html %]" value="[% LIMIT_INPUT.input_value | html %]"/>
[% END %]
[% END %]
<!-- TABLE RESULTS START -->
<table class="table table-striped">
<tr>
<td colspan="3" class="resultscontrol">
<div class="resort">
<select id="sort_by" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
<input type="submit" class="submit clearfix" id="sortsubmit" value="Go" />
</div>
[% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<div class="cartlist"><span class="checkall"></span>
<span class="clearall"></span>
<a href="#" class="highlight_toggle" id="highlight_toggle_off">Unhighlight</a>
<a href="#" class="highlight_toggle" id="highlight_toggle_on">Highlight</a>
<span class="addto"></span></div>
[% END %]
</td>
</tr>
<!-- Actual Search Results -->
[% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
<tr class="grouplabel"><td colspan="3">[% SEARCH_RESULT.group_label | html %]</td></tr>
[% FOREACH GROUP_RESULT IN SEARCH_RESULT.GROUP_RESULTS %]
[% IF ( GROUP_RESULT.even ) %]
<tr class="highlight">
[% ELSE %]
<tr>
[% END %]
<td>
[% IF ( AdlibrisEnabled && GROUP_RESULT.normalized_isbn ) %]
<img src="[% AdlibrisURL | html %]?isbn=[% GROUP_RESULT.normalized_isbn | html %]" class="adlibris-cover" alt="Adlibris cover image" />
[% END %]
[% IF ( OPACAmazonCoverImages ) %]
<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 %]
</a>
[% ELSE %]
[% UNLESS ( noItemTypeImages ) %]
[% IF ( GROUP_RESULT.imageurl ) %]
<img src="[% GROUP_RESULT.imageurl | html %]" title="[% GROUP_RESULT.description | html %]" />
[% END %]
[% END %]
[% GROUP_RESULT.description | html %]
[% END %]
</td>
<td>
[% GROUP_RESULT.result_number | html %].
[% IF ( GROUP_RESULT.BiblioDefaultViewmarc ) %]
<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 %]
[% ELSE %]
[% IF ( GROUP_RESULT.BiblioDefaultViewisbd ) %]
<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 %]
[% ELSE %]
<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 %]
[% END %]
[% FOREACH subtitl IN GROUP_RESULT.subtitle %]
[% subtitl | html %]
[% END %]
</a>
[% END # / IF GROUP_RESULT.BiblioDefaultViewmarc %]
[% IF ( GROUP_RESULT.author ) %]
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>
[% ELSE %]
&nbsp;
[% END %]
<p>
[% IF ( GROUP_RESULT.publicationyear ) %] - [% GROUP_RESULT.publicationyear | html %][% END %]
[% IF ( GROUP_RESULT.publishercode ) %]- [% GROUP_RESULT.publishercode | html %][% END %]
[% IF ( GROUP_RESULT.place ) %] ; [% GROUP_RESULT.place | html %][% END %]
[% IF ( GROUP_RESULT.pages ) %] - [% GROUP_RESULT.pages | html %][% END %]
[% IF ( GROUP_RESULT.notes ) %] : [% GROUP_RESULT.notes | html %][% END %]
[% IF ( GROUP_RESULT.size ) %] ; [% GROUP_RESULT.size | html %][% END %]
[% IF ( GROUP_RESULT.timestamp ) %] <i>(modified on [% GROUP_RESULT.timestamp | html %])</i>[% END %]
</p>
[% IF ( GROUP_RESULT.searchhighlightblob ) %]
<p class="searchhighlightblob">[% GROUP_RESULT.searchhighlightblob | html %]</p>
[% END %]
<p class="availability">
[% IF ( GROUP_RESULT.available_items_loop ) %]
<span class="available"><strong>Items available at:</strong>
[% FOREACH available_items_loo IN GROUP_RESULT.available_items_loop %]
[% IF ( available_items_loo.branchname ) %][% available_items_loo.branchname | html %][% END %]
[% IF ( OPACItemsResultsDisplay ) %]
[% IF ( available_items_loo.location ) %]<span class="shelvingloc">[% available_items_loo.location | html %]</span>[% END %]
[% 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 %]
[% END %]
([% available_items_loo.count | html %]),
[% END # / FOREACH available_items_loo %]
</span>
[% ELSE %]
<span class="unavailable">No items available:</span>
[% END # / IF GROUP_RESULT.available_items_loop %]
<span class="unavailable">
[% IF ( GROUP_RESULT.onloancount ) %] Checked out ([% GROUP_RESULT.onloancount | html %]), [% END %]
[% IF ( GROUP_RESULT.withdrawncount ) %] Withdrawn ([% GROUP_RESULT.withdrawncount | html %]), [% END %]
[% IF ( GROUP_RESULT.itemlostcount ) %] Lost ([% GROUP_RESULT.itemlostcount | html %]),[% END %]
[% IF ( GROUP_RESULT.damagedcount ) %] Damaged ([% GROUP_RESULT.damagedcount | html %]),[% END %]
[% IF ( GROUP_RESULT.orderedcount ) %] On order ([% GROUP_RESULT.orderedcount | html %]),[% END %]
[% IF ( GROUP_RESULT.intransitcount ) %] In transit ([% GROUP_RESULT.intransitcount | html %]),[% END %]
</span>
</p>
<p>
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( GROUP_RESULT.norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 && GROUP_RESULT.holdable %]
<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-->
[% END %]
[% END %]
[% END %]
[% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<input type="checkbox" name="biblionumber" value="[% GROUP_RESULT.biblionumber | html %]" title="Click to add to cart" /> <label for="bib[% GROUP_RESULT.biblionumber | html %]">
[% END %]
<img src="[% themelang | html %]/images/[% GROUP_RESULT.itemtype | html %].gif" alt="[% GROUP_RESULT.ccode | html %]" title="[% GROUP_RESULT.ccode | html %]" />
[% IF ( ( Koha.Preference( 'opacbookbag' ) = 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]</label>[% END %]
[% IF ( GROUP_RESULT.classification ) %]
<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% GROUP_RESULT.classification |url %]"> [% GROUP_RESULT.classification | html %] </a>
[% END %]
</p>
</td>
</tr>
[% END # / FOREACH GROUP_RESULT %]
[% END # / FOREACH SEARCH_RESULTS %]
</table>
</form>
</div> <!-- / .searchresults -->
[% END # / IF scan %]
[% INCLUDE 'page-numbers.inc' %]
[% END # / IF total %]
[% IF Koha.Preference( 'suggestion' ) == 1 && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername || Koha.Preference( 'ILLModule' ) == 1 ) %]
<div class="suggestion">
Not finding what you're looking for?
<ul>
[% IF Koha.Preference( 'AnonSuggestions' ) == 1 %]
<li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
[% ELSE %]
[% IF ( loggedinusername ) %]
<li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
[% END %]
[% END %]
[% IF Koha.Preference( 'ILLModule' ) == 1 && loggedinusername %]
<li>Make an <a href="/cgi-bin/koha/opac-illrequests.pl?op=create">Interlibrary loan request</a></li>
[% END %]
</ul>
</div>
[% END %]
</div> <!-- / #grouped-results -->
</div> <!-- /.span10/12 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div><!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
<script>
//<![CDATA[
var q_array = new Array(); // will hold the search terms, if possible
$(document).ready(function(){
[% IF ( OpacHighlightedWords ) %]
$('a.title').each(function() {
$(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
});
[% END %]
$('#sort_by').change(function() {
$('#bookbag_form').submit();
});
$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">" + _("Clear all") + "</a>");
$("span.checkall").html("<a id=\"CheckAll\" href=\"#\">" + _("Select all") + "</a>");
$("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") + "\" />");
$("#addto").change(function(){
cartList();
});
$(".addto").find("input:submit").click(function(){
cartList();
return false;
});
function cartList(){
if($("#addto").find("option:selected").attr("value") == "addtolist"){
var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
[% IF ( loggedinusername ) %]if (vShelfAdd()) {
Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?selectedshelf='+shelfnumber+'&' + vShelfAdd());
}[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
return false;
} else if($("#addto").find("option:selected").attr("value") == "newlist"){
[% IF ( loggedinusername ) %]if (vShelfAdd()) {
Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?newshelf=1&' + vShelfAdd());
}[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
return false;
}
if($("#addto").find("option:selected").attr("value") == "addtocart"){
addMultiple();
return false;
}
}
$("#CheckAll").click(function(){
$("#bookbag_form").checkCheckboxes();
return false;
});
$("#CheckNone").click(function(){
$("#bookbag_form").unCheckCheckboxes();
return false;
});
[% IF ( query_desc ) %]
var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
q_array = query_desc.split(" ");
// ensure that we don't have "" at the end of the array, which can
// break the highlighter
while (q_array.length > 0 && q_array[q_array.length-1] == "") {
q_array = q_array.splice(0,-1);
}
highlightOn();
$("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;});
$("#highlight_toggle_off").show().click(function() {highlightOff();});
[% END %]
});
function highlightOff() {
$("td").removeHighlight();
$(".highlight_toggle").toggle();
}
function highlightOn() {
var x;
for (x in q_array) {
q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1");
q_array[x] = q_array[x].toLowerCase();
var myStopwords = "[% Koha.Preference('NotHighlightedWords') | html %]".toLowerCase().split('|');
if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) {
$("td").highlight(q_array[x]);
}
}
$(".highlight_toggle").toggle();
}
//]]>
</script>
[% END %]