init
This commit is contained in:
		
						commit
						d013ece0f3
					
				
					 363 changed files with 20823 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								themes/duckquill/static/closable.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								themes/duckquill/static/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