Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показано 66 промежуточных версий этого же участника)
Строка 1: Строка 1:
.alchemy-block {
(function() {  
border: 2px solid;
    if (typeof mw === 'undefined' || !window.document) return;  
border-radius: 12px;
   
margin: 1em 0;
    function initCollapse() {
overflow: hidden;
        var headings = document.querySelectorAll('.chem-heading');  
background: #1c1c1c;
        var hi = 0;  
color: #ddd;
        var len = headings.length;  
}
        for (; hi < len; hi++) {
 
            (function(node) {
.alchemy-header {
                if (node.getAttribute('data-chem-attached')) return;
padding: 0.5em 1em;
                node.setAttribute('data-chem-attached', '1');
font-size: 1.2em;
                node.style.cursor = 'pointer';  
font-weight: bold;
                node.addEventListener('click', function() {
}
                    var kind = node.getAttribute('data-kind') || '';  
 
                    var wrapper = findWrapper(node, kind);
.alchemy-body {
                    if (!wrapper) return;
padding: 1em;
                    var btn = node.querySelector('.collapse-btn');  
}
                   
 
                    if (wrapper.classList.contains('collapsed')) {  
.alchemy-product {
                        wrapper.classList.remove('collapsed');  
font-weight: bold;
                        wrapper.classList.add('expanded');  
margin-bottom: 0.5em;
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px';  
color: #fff;
                        if (btn) btn.textContent = 'свернуть';
}
                        var cleanup = function() {
 
                            wrapper.style.maxHeight = '';  
.alchemy-description {
                            wrapper.removeEventListener('transitionend', cleanup);  
font-style: italic;
                        };  
margin-top: 1em;
                        wrapper.addEventListener('transitionend', cleanup);  
color: #aaa;
                    } else {
}
                        var currentHeight = wrapper.scrollHeight;
 
                        wrapper.style.maxHeight = currentHeight + 'px';  
.alchemy-collapse {
                        wrapper.offsetHeight;  
margin-top: 1em;
                        wrapper.classList.remove('expanded');  
}
                        wrapper.classList.add('collapsed');  
 
                        wrapper.style.maxHeight = '0px';  
.alchemy-toggle {
                        if (btn) btn.textContent = 'развернуть';  
cursor: pointer;
                    }  
background: #2c2c2c;
                });  
padding: 0.4em 0.8em;
            })(headings[hi]);  
border-radius: 8px;
        }
user-select: none;
    }  
position: relative;
   
}
    function findWrapper(node, kind) {
 
        var parent = node.parentNode;
.alchemy-toggle::after {
        if (!parent) return null;  
content: '▼';
        var wrappers = parent.querySelectorAll('.collapsible');
float: right;
        var wi = 0;  
transition: transform 0.2s;
        var wlen = wrappers.length;  
}
        for (; wi < wlen; wi++) {
 
            if (wrappers[wi].getAttribute('data-kind') === kind) {
.alchemy-toggle.open::after {
                return wrappers[wi];  
transform: rotate(-90deg);
            }
}
        }
 
        return null;  
.alchemy-content {
    }  
display: none;
   
padding: 0.5em 1em;
    if (document.readyState === 'complete' || document.readyState === 'interactive') {
background: #2b2b2b;
        initCollapse();
border-radius: 6px;
    } else {  
margin-top: 0.4em;
        document.addEventListener('DOMContentLoaded', initCollapse);  
}
    }
 
})();
.alchemy-toggle.open + .alchemy-content {
display: block;
}

Текущая версия от 13:10, 4 апреля 2026

(function() { 
    if (typeof mw === 'undefined' || !window.document) return; 
    
    function initCollapse() { 
        var headings = document.querySelectorAll('.chem-heading'); 
        var hi = 0; 
        var len = headings.length; 
        for (; hi < len; hi++) { 
            (function(node) { 
                if (node.getAttribute('data-chem-attached')) return; 
                node.setAttribute('data-chem-attached', '1'); 
                node.style.cursor = 'pointer'; 
                node.addEventListener('click', function() { 
                    var kind = node.getAttribute('data-kind') || ''; 
                    var wrapper = findWrapper(node, kind); 
                    if (!wrapper) return; 
                    var btn = node.querySelector('.collapse-btn'); 
                    
                    if (wrapper.classList.contains('collapsed')) { 
                        wrapper.classList.remove('collapsed'); 
                        wrapper.classList.add('expanded'); 
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px'; 
                        if (btn) btn.textContent = 'свернуть'; 
                        var cleanup = function() { 
                            wrapper.style.maxHeight = ''; 
                            wrapper.removeEventListener('transitionend', cleanup); 
                        }; 
                        wrapper.addEventListener('transitionend', cleanup); 
                    } else { 
                        var currentHeight = wrapper.scrollHeight; 
                        wrapper.style.maxHeight = currentHeight + 'px'; 
                        wrapper.offsetHeight; 
                        wrapper.classList.remove('expanded'); 
                        wrapper.classList.add('collapsed'); 
                        wrapper.style.maxHeight = '0px'; 
                        if (btn) btn.textContent = 'развернуть'; 
                    } 
                }); 
            })(headings[hi]); 
        } 
    } 
    
    function findWrapper(node, kind) { 
        var parent = node.parentNode; 
        if (!parent) return null; 
        var wrappers = parent.querySelectorAll('.collapsible'); 
        var wi = 0; 
        var wlen = wrappers.length; 
        for (; wi < wlen; wi++) { 
            if (wrappers[wi].getAttribute('data-kind') === kind) { 
                return wrappers[wi]; 
            } 
        } 
        return null; 
    } 
    
    if (document.readyState === 'complete' || document.readyState === 'interactive') { 
        initCollapse(); 
    } else { 
        document.addEventListener('DOMContentLoaded', initCollapse); 
    } 
})();