theme, plugins und config für die Webseite der Baptisten Hohenacker
https://baptisten-hohenacker.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
943 B
45 lines
943 B
function init(){ |
|
document.body.onclick = function(e){ |
|
//console.log(e) |
|
if (e.target.tagName != "LABEL" && e.target.tagName != "INPUT"){ |
|
document.closeAllPopups(); |
|
} |
|
} |
|
|
|
|
|
Array.from(document.getElementsByTagName("label")).forEach( function(label){ |
|
console.log(label) |
|
console.log(label.for) |
|
|
|
label.onkeydown=function(e){ |
|
var cbox=document.getElementById(this.getAttribute("for")) |
|
var key = e.keyCode ? e.keyCode : e.which; |
|
if (key == 32|| key == 13){//space or enter |
|
console.log("toggle!!"); |
|
e.stopPropagation(); |
|
e.preventDefault(); |
|
cbox.checked = !cbox.checked; |
|
} |
|
if (key == 27){ //escape |
|
cbox.checked = false; |
|
} |
|
if (key == 40){// down arrow |
|
cbox.checked = true; |
|
} |
|
console.log(key) |
|
|
|
} |
|
|
|
}); |
|
} |
|
|
|
document.closeAllPopups = function(){ |
|
Array.from(document.getElementsByTagName("label")).forEach( function(label){ |
|
var cbox=document.getElementById(label.getAttribute("for")); |
|
cbox.checked = false; |
|
}); |
|
} |
|
//setTimeout(init,0); |
|
onload=init |
|
|
|
|
|
|