It took some time, but i came up with a solution.
In this Fiddle you can see the working Popup-menu in Action, as it was my target it works without Javascript avtivated. But if you have Javascript activated it also detects if you clicked outside the div and closes the Popup
var isOutSide = true,
bbb=document.getElementById('header-profile-popup'),
bbb2=document.getElementById('header-profile-popup-toggler'),
bbb3=document.getElementById('header-profile-popup-toggler-label');
document.body.addEventListener('click', function(){
if(isOutSide){
document.getElementById("header-profile-popup-toggler").checked = false;
}
isOutSide = true;
});
bbb.addEventListener('click', function(){
isOutSide = false;
});
bbb2.addEventListener('click', function(){
isOutSide = false;
});
bbb3.addEventListener('click', function(){
isOutSide = false;
});