- initial
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Nav hamburger
|
||||
const ham=document.getElementById('ham'),navLinks=document.getElementById('navLinks');
|
||||
ham?.addEventListener('click',()=>navLinks?.classList.toggle('open'));
|
||||
document.addEventListener('click',e=>{if(!e.target.closest('.navbar'))navLinks?.classList.remove('open')});
|
||||
|
||||
// User dropdown
|
||||
const uBtn=document.getElementById('userBtn'),uDd=document.getElementById('userDd');
|
||||
uBtn?.addEventListener('click',e=>{e.stopPropagation();uDd?.classList.toggle('open')});
|
||||
document.addEventListener('click',()=>uDd?.classList.remove('open'));
|
||||
|
||||
// Flash auto-dismiss after 4.5s
|
||||
setTimeout(()=>{
|
||||
document.querySelectorAll('.flash').forEach(el=>{
|
||||
el.style.transition='opacity .5s';
|
||||
el.style.opacity='0';
|
||||
setTimeout(()=>el.remove(),500);
|
||||
});
|
||||
},4500);
|
||||
|
||||
// Confirm dialogs
|
||||
document.querySelectorAll('[data-confirm]').forEach(el=>{
|
||||
el.addEventListener('click',e=>{if(!confirm(el.dataset.confirm))e.preventDefault();});
|
||||
});
|
||||
|
||||
// Admin sidebar active link
|
||||
document.querySelectorAll('.asl').forEach(l=>{
|
||||
const href=l.getAttribute('href');
|
||||
if(href&&(location.pathname===href||location.pathname.startsWith(href.replace(/\/[^/]+$/,'/')+'/')&&href!='/admin/'))
|
||||
l.classList.add('on');
|
||||
if(location.pathname===href)l.classList.add('on');
|
||||
});
|
||||
Reference in New Issue
Block a user