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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 1: Строка 1:
(function() {
(function() {
     var initAccordions = function() {
     function initComponents() {
         var accordions = document.querySelectorAll('.accordion-header');
         // Аккордеоны
       
        document.querySelectorAll('.accordion-header').forEach(function(header) {
        var toggleAccordion = function(e) {
            header.addEventListener('click', function() {
            var content = this.parentNode.querySelector('.accordion-content');
                var content = this.nextElementSibling;
            content.classList.toggle('active');
                var isActive = content.classList.contains('active');
         };
               
                document.querySelectorAll('.accordion-content').forEach(function(c) {
                    c.classList.remove('active');
                });
               
                if (!isActive) {
                    content.classList.add('active');
                    header.classList.add('active');
                }
            });
         });


         for (var i = 0; i < accordions.length; i++) {
         // Параллакс эффекты
            accordions[i].addEventListener('click', toggleAccordion);
        window.addEventListener('mousemove', function(e) {
        }
            var x = (e.clientX / window.innerWidth - 0.5) * 20;
    };
            var y = (e.clientY / window.innerHeight - 0.5) * 20;
 
             document.querySelector('.title-container').style.transform =  
    var addCardHover = function() {
                'translate(' + x + 'px, ' + y + 'px)';
        var cards = document.querySelectorAll('.species-card');
         });
       
     }
        var handleHover = function(isOver) {
             return function() {
                this.style.transform = isOver ? 'scale(1.03)' : 'none';
            };
        };
 
        for (var j = 0; j < cards.length; j++) {
            cards[j].addEventListener('mouseover', handleHover(true));
            cards[j].addEventListener('mouseout', handleHover(false));
         }
    };
 
    var initClassifiedAnimation = function() {
        var classifiedElements = document.querySelectorAll('.classified');
        for (var k = 0; k < classifiedElements.length; k++) {
            classifiedElements[k].style.animation = 'pulse 2s infinite';
        }
     };


     if (document.readyState === 'complete') {
     if (document.readyState === 'complete') {
         initAccordions();
         initComponents();
        addCardHover();
        initClassifiedAnimation();
     } else {
     } else {
         window.addEventListener('load', function() {
         window.addEventListener('load', initComponents);
            initAccordions();
            addCardHover();
            initClassifiedAnimation();
        });
     }
     }
})();
})();

Версия от 21:21, 23 февраля 2025

(function() {
    function initComponents() {
        // Аккордеоны
        document.querySelectorAll('.accordion-header').forEach(function(header) {
            header.addEventListener('click', function() {
                var content = this.nextElementSibling;
                var isActive = content.classList.contains('active');
                
                document.querySelectorAll('.accordion-content').forEach(function(c) {
                    c.classList.remove('active');
                });
                
                if (!isActive) {
                    content.classList.add('active');
                    header.classList.add('active');
                }
            });
        });

        // Параллакс эффекты
        window.addEventListener('mousemove', function(e) {
            var x = (e.clientX / window.innerWidth - 0.5) * 20;
            var y = (e.clientY / window.innerHeight - 0.5) * 20;
            document.querySelector('.title-container').style.transform = 
                'translate(' + x + 'px, ' + y + 'px)';
        });
    }

    if (document.readyState === 'complete') {
        initComponents();
    } else {
        window.addEventListener('load', initComponents);
    }
})();