Modals: lock background scroll; comment dropdown keeps row on one line, full tone labels, flip up near bottom
This commit is contained in:
@@ -27,15 +27,30 @@
|
||||
document.querySelectorAll('pre code').forEach(function(el){ window.hljs.highlightElement(el); });
|
||||
};
|
||||
})();
|
||||
document.addEventListener('DOMContentLoaded', function(){ window.__hljsSet(document.documentElement.getAttribute('data-theme')); window.__hljsAll(); });
|
||||
document.addEventListener('DOMContentLoaded', function(){ window.__hljsSet(document.documentElement.getAttribute('data-theme')); window.__hljsAll(); syncModalScrollLock(); });
|
||||
function toggleTheme(){
|
||||
var e=document.documentElement; var t=e.getAttribute('data-theme')==='dark'?'light':'dark';
|
||||
e.setAttribute('data-theme',t); localStorage.setItem('lms-theme',t); window.__hljsSet(t);
|
||||
}
|
||||
function openModal(id){ var d=document.getElementById(id); if(d) d.showModal(); }
|
||||
function closeModal(id){ var d=document.getElementById(id); if(d) d.close(); }
|
||||
function openModal(id){ var d=document.getElementById(id); if(d) d.showModal(); syncModalScrollLock(); }
|
||||
function closeModal(id){ var d=document.getElementById(id); if(d) d.close(); syncModalScrollLock(); }
|
||||
function openModalData(btn){ openModal(btn.dataset.modal); }
|
||||
function closeModalData(btn){ closeModal(btn.dataset.modal); }
|
||||
/* Пока открыта хоть одна модалка — блокируем прокрутку страницы (внутри .modal-body прокрутка остаётся). */
|
||||
function syncModalScrollLock(){
|
||||
var root = document.documentElement;
|
||||
if (document.querySelector('dialog[open]')) {
|
||||
var sw = window.innerWidth - root.clientWidth;
|
||||
root.style.setProperty('--modal-scrollbar', (sw > 0 ? sw : 0) + 'px');
|
||||
root.classList.add('modal-open');
|
||||
} else {
|
||||
root.classList.remove('modal-open');
|
||||
root.style.removeProperty('--modal-scrollbar');
|
||||
}
|
||||
}
|
||||
document.addEventListener('toggle', function (e) {
|
||||
if (e.target && e.target.tagName === 'DIALOG') syncModalScrollLock();
|
||||
}, true);
|
||||
function sectionStateKey(id){ return 'lms-section-open:' + id; }
|
||||
function applySectionState(acc){
|
||||
var id = acc.getAttribute('data-section-id');
|
||||
|
||||
Reference in New Issue
Block a user