Bug 29603: Fix responsive behavior of facets menu in OPAC search results

The OPAC was originally featured a search results facets box that would
collapse at narrower browser widths and show a "Refine your search" link
under the breadcrumbs menu. At some point this broke, with the "Refine
your search" link appearing at the bottom instead.

This patch revises the page to restore the previous behavior.

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).

- Perform catalog search in the OPAC which will return multiple results.
- View the page at various browser widths. At narrower widths the facets
  menu should appear as a "collapsed" box with a "Refine your search"
  link.
- Clicking the link should toggle the facets menu visibility.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 915815ddae)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
(cherry picked from commit 2e72aae7e4)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Owen Leonard 2022-01-27 15:29:32 +00:00 committed by Victor Grousset/tuxayo
parent e8d9c094fe
commit d49f04237f
3 changed files with 126 additions and 52 deletions

View File

@ -381,39 +381,6 @@
display: none;
}
#search-facets {
margin-bottom: .5em;
h4 {
display: block;
margin: 0;
padding: 0;
a {
border-bottom: 0;
font-weight: normal;
padding: .7em .2em;
}
}
li {
padding: .4em;
}
h5 {
margin: .2em;
}
ul {
padding: 0;
}
}
#menu h4 a.menu-open,
#search-facets h4 a.menu-open {
border-bottom: 1px solid #D8D8D8;
}
#wrapper {
padding: 0;
}
@ -443,6 +410,55 @@
}
}
@media only screen and ( max-width: 991px ) {
#search-facets {
margin-bottom: .5em;
h2 {
display: block;
margin: 0;
padding: 0;
a {
border-bottom: 0;
font-weight: normal;
padding: .7em .2em;
&::before {
content: "\f0da";
display: inline-block;
font-family: FontAwesome;
width: 1em;
}
}
}
li {
padding: .4em;
}
h3 {
margin: .2em;
}
ul {
padding: 0;
}
}
#menu h2 a.menu-open,
#search-facets h2 a.menu-open {
border-bottom: 1px solid #D8D8D8;
&::before {
content: "\f0d7";
display: inline-block;
font-family: FontAwesome;
width: 1em;
}
}
}
@media only screen and ( min-width: 992px ) {
/* Screens above 768 pixels wide */
#menu {

View File

@ -102,18 +102,10 @@
</div>
[% END %]
[% IF ( total ) %]
[% IF ( opacfacets ) %]
<div class="col-lg-10 order-first order-md-first order-lg-2 maincontent">
[% ELSE %]
<div class="col order-first order-md-first order-lg-2 maincontent">
[% END %]
[% IF ( opacfacets ) %]
<div class="col-lg-10 maincontent">
[% ELSE %]
[% IF ( opacfacets ) %]
<div class="col-lg-10 order-first order-md-first order-lg-2">
[% ELSE %]
<div class="col order-first order-md-first order-lg-2">
[% END %]
<div class="col maincontent">
[% END %]
[% IF ( searchdesc ) %]

View File

@ -151,13 +151,79 @@ function confirmModal(message, title, yes_label, no_label, callback) {
});
})(jQuery);
$("#scrolltocontent").click(function() {
var content = $(".maincontent");
if (content.length > 0) {
$('html,body').animate({
scrollTop: content.first().offset().top
},
'slow');
content.first().find(':focusable').eq(0).focus();
enquire.register("screen and (max-width:608px)", {
match : function() {
if($("body.scrollto").length > 0){
window.scrollTo( 0, $(".maincontent").offset().top );
}
}
});
enquire.register("screen and (min-width:992px)", {
match : function() {
facetMenu( "show" );
},
unmatch : function() {
facetMenu( "hide" );
}
});
function facetMenu( action ){
if( action == "show" ){
$(".menu-collapse-toggle").off("click", facetHandler );
$(".menu-collapse").show();
} else {
$(".menu-collapse-toggle").on("click", facetHandler ).removeClass("menu-open");
$(".menu-collapse").hide();
}
}
var facetHandler = function(e){
e.preventDefault();
$(this).toggleClass("menu-open");
$(".menu-collapse").toggle();
};
$(document).ready(function(){
$("html").removeClass("no-js").addClass("js");
$(".close").click(function(){
window.close();
});
$(".focus").focus();
$(".js-show").show();
$(".js-hide").hide();
if( $(window).width() < 991 ){
facetMenu("hide");
}
// clear the basket when user logs out
$("#logout").click(function(){
var nameCookie = "bib_list";
var valCookie = readCookie(nameCookie);
if (valCookie) { // basket has contents
updateBasket(0,null);
delCookie(nameCookie);
return true;
} else {
return true;
}
});
$(".loginModal-trigger").on("click",function(e){
e.preventDefault();
$("#loginModal").modal("show");
});
$("#loginModal").on("shown.bs.modal", function(){
$("#muserid").focus();
});
$("#scrolltocontent").click(function() {
var content = $(".maincontent");
if (content.length > 0) {
$('html,body').animate({ scrollTop: content.first().offset().top },
'slow');
content.first().find(':focusable').eq(0).focus();
}
});
});