Koha/koha-tmpl/opac-tmpl/bootstrap/js/script.js
Owen Leonard 9ac43fd97b Bug 25492: Your Account Menu button does nothing on mobile devices
This patch removes some redundant code from the OPAC JavaScript which
was causing problems with the show/hide action on two controls which are
shown only at narrower browser widths: The "Your account" menu shown
when the user is on a user-related page, and the "Refine your search"
menu shown on the search results page.

To test, apply the patch and go to the OPAC. Narrow your browser width
to below 768 pixels.

 - Perform a search.
 - On the search results page you should see a "Refine your search"
   link at the top of the results. Clicking it should expand and
   collapse the facets menu.
 - Log in to the OPAC.
 - On the "Your summary" page there should be a "Your account menu" link
   at the top of the main part of the page. Clicking it should expand
   and collapse the account menu.
 - Verify that these menus display correctly when you widen and narrow
   the browser window.

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-06-12 10:32:35 +02:00

69 lines
1.7 KiB
JavaScript

/* global enquire readCookie updateBasket delCookie */
enquire.register("screen and (max-width:608px)", {
match : function() {
$("#masthead_search").insertAfter("#select_library");
if($("body.scrollto").length > 0){
$("body.scrollto").animate({
scrollTop: $(".maincontent").offset().top
}, 10);
}
},
unmatch : function() {
}
});
enquire.register("screen and (min-width:768px)", {
match : function() {
facetMenu( "show" );
},
unmatch : function() {
facetMenu( "hide" );
}
});
function facetMenu( action ){
if( action == "show" ){
$(".menu-collapse-toggle").unbind("click", facetHandler )
$(".menu-collapse").show();
} else {
$(".menu-collapse-toggle").bind("click", facetHandler ).removeClass("menu-open");
$(".menu-collapse").hide();
}
}
var facetHandler = function(e){
e.preventDefault();
$(this).toggleClass("menu-open");
$(".menu-collapse").toggle();
};
$(document).ready(function(){
$(".close").click(function(){
window.close();
});
$(".focus").focus();
$(".js-show").show();
$(".js-hide").hide();
if( $(window).width() < 768 ){
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");
});
});