mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
lightbox: close on ESC #451
This commit is contained in:
parent
6d90be3015
commit
5babf80537
1 changed files with 12 additions and 0 deletions
|
@ -548,6 +548,13 @@ function initMenuScrollbar(){
|
||||||
adjustContentWidth();
|
adjustContentWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function imageEscapeHandler( event ){
|
||||||
|
if( event.key == "Escape" ){
|
||||||
|
var image = event.target;
|
||||||
|
image.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sidebarEscapeHandler( event ){
|
function sidebarEscapeHandler( event ){
|
||||||
if( event.key == "Escape" ){
|
if( event.key == "Escape" ){
|
||||||
var b = document.querySelector( 'body' );
|
var b = document.querySelector( 'body' );
|
||||||
|
@ -752,6 +759,10 @@ function initSwipeHandler(){
|
||||||
document.querySelectorAll( '#sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX); }, false);
|
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() {
|
function clearHistory() {
|
||||||
var visitedItem = baseUriFull + 'visited-url/'
|
var visitedItem = baseUriFull + 'visited-url/'
|
||||||
for( var item in sessionStorage ){
|
for( var item in sessionStorage ){
|
||||||
|
@ -1074,6 +1085,7 @@ ready( function(){
|
||||||
initSwipeHandler();
|
initSwipeHandler();
|
||||||
initHistory();
|
initHistory();
|
||||||
initSearch();
|
initSearch();
|
||||||
|
initImage();
|
||||||
});
|
});
|
||||||
|
|
||||||
function useMermaid( config ){
|
function useMermaid( config ){
|
||||||
|
|
Loading…
Reference in a new issue