Koha/koha-tmpl/opac-tmpl/bootstrap/js/script.js
Owen Leonard 7ea60c0bd9 Bug 26695: Add modal "shown" event to set cursor focus
This patch attaches a focus() call to the login modal's "shown.bs.modal"
event so that the cursor focus is set to the username field when the
login modal is displayed.

To test, apply the patch and confirm that your OPAC uses the regular
login process--not casAuthentication or GoogleOpenIDConnect.

Click the "Log in to your account" link in the header. A the login form
should appear in a modal dialog, and the focus should be on the username
field.

The same should be true if you trigger the modal from other
locations, for instance: "Log in to add tags" on the bibliographic
detail page or the tag cloud page.

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-11-03 10:57:35 +01:00

71 lines
1.8 KiB
JavaScript

/* global enquire readCookie updateBasket delCookie */
enquire.register("screen and (max-width:608px)", {
match : function() {
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");
});
$("#loginModal").on("shown.bs.modal", function(){
$("#muserid").focus();
});
});