working timeline
This commit is contained in:
		
							parent
							
								
									bb32b4f957
								
							
						
					
					
						commit
						996fabfae6
					
				
					 582 changed files with 26710 additions and 388 deletions
				
			
		
							
								
								
									
										27
									
								
								public/closable.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								public/closable.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
const closable = document.querySelectorAll("details.closable");
 | 
			
		||||
 | 
			
		||||
closable.forEach((detail) => {
 | 
			
		||||
	detail.addEventListener("toggle", () => {
 | 
			
		||||
		if (detail.open) setTargetDetail(detail);
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function setTargetDetail(targetDetail) {
 | 
			
		||||
	closable.forEach((detail) => {
 | 
			
		||||
		if (detail !== targetDetail) {
 | 
			
		||||
			detail.open = false;
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
document.addEventListener("click", function (event) {
 | 
			
		||||
	const isClickInsideDetail = [...closable].some((detail) =>
 | 
			
		||||
		detail.contains(event.target)
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	if (!isClickInsideDetail) {
 | 
			
		||||
		closable.forEach((detail) => {
 | 
			
		||||
			detail.open = false;
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue