You really could simplify this a bit I think:
// If an event gets to the body
$("body").click(function(){
$(".popup").fadeOut().removeClass("active");
});
// Prevent events from getting pass .popup
$(".popup").click(function(e){
e.stopPropagation();
});
Clicking on the popup, or any of its children will cause propagation to stop before it reaches the body.
Demo of stopping event-propagation: http://jsbin.com/ofeso3/edit
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…