lightbox: close on ESC #451

This commit is contained in:
Sören Weber 2023-02-04 23:12:40 +01:00
parent 6d90be3015
commit 5babf80537
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -548,6 +548,13 @@ function initMenuScrollbar(){
adjustContentWidth();
}
function imageEscapeHandler( event ){
if( event.key == "Escape" ){
var image = event.target;
image.click();
}
}
function sidebarEscapeHandler( event ){
if( event.key == "Escape" ){
var b = document.querySelector( 'body' );
@ -752,6 +759,10 @@ function initSwipeHandler(){
document.querySelectorAll( '#sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX); }, false);
}
function initImage(){
document.querySelectorAll( '.lightbox' ).forEach( function(e){ e.addEventListener("keydown", imageEscapeHandler); }, false);
}
function clearHistory() {
var visitedItem = baseUriFull + 'visited-url/'
for( var item in sessionStorage ){
@ -1074,6 +1085,7 @@ ready( function(){
initSwipeHandler();
initHistory();
initSearch();
initImage();
});
function useMermaid( config ){