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

Страница интерфейса MediaWiki
(Откат правок Mr. Samuel (обсуждение) к последней версии AL-S)
Метки: откат отменено
Нет описания правки
Метки: ручная отмена отменено
Строка 1: Строка 1:
// Создаем div для отображения партиклов
$(document).ready(function() {
var particlesDiv = document.createElement("div");
    // Инициализация боковой панели
particlesDiv.id = "particles-js";
    $('.боковая-панель-кнопка').on('click', function() {
document.body.appendChild(particlesDiv);
        var targetId = $(this).data('target');
       
        // Удаляем активный класс у всех кнопок
        $('.боковая-панель-кнопка').removeClass('active');
        // Добавляем активный класс текущей кнопке
        $(this).addClass('active');
       
        // Скрываем все разделы
        $('.боковая-панель-раздел').removeClass('default');
        // Показываем выбранный раздел
        $('#' + targetId).addClass('default');
    });
   
    // Активируем первую кнопку по умолчанию
    $('.боковая-панель-кнопка:first').click();
   
    // Подключаем Tippy.js через CDN динамически
if (!window.tippy) {
    var tippyScript = document.createElement('script');
    tippyScript.src = "https://unpkg.com/@popperjs/core@2/dist/umd/popper.min.js";
    tippyScript.onload = function() {
        var tippyCoreScript = document.createElement('script');
        tippyCoreScript.src = "https://unpkg.com/tippy.js@6/dist/tippy-bundle.umd.min.js";
        tippyCoreScript.onload = initTippy;
        document.head.appendChild(tippyCoreScript);
    };
    document.head.appendChild(tippyScript);


// Добавляем стили для партиклов
    // Подключаем CSS
var style = document.createElement("style");
    var tippyCSS = document.createElement('link');
style.innerHTML = "#particles-js { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }";
    tippyCSS.rel = "stylesheet";
document.head.appendChild(style);
    tippyCSS.href = "https://unpkg.com/tippy.js@6/dist/tippy.css";
    document.head.appendChild(tippyCSS);
} else {
    initTippy();
}


// Загружаем и активируем particles.js
// Инициализация Tippy после загрузки скриптов
mw.loader.load( 'https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js' ).then( function () {
function initTippy() {
    particlesJS('particles-js', {
    $('.допуск-контейнер').each(function() {
        "particles": {
        var content = $(this).find('.допуск-подсказка').html(); // берем содержимое подсказки
            "number": {
tippy('.допуск-контейнер', {
                "value": 80,
    content: (reference) => reference.getAttribute('data-tooltip'),
                "density": {
    allowHTML: true,
                    "enable": true,
    interactive: true,
                    "value_area": 800
    placement: 'auto',
                }
    maxWidth: '80vw',
            },
    theme: 'dark',
            "color": {
    arrow: false,
                "value": "#ffffff"
    duration: [200, 200],
            },
    popperOptions: {
            "shape": {
        modifiers: [
                "type": "circle",
            { name: 'preventOverflow', options: { padding: 8 } },
                "stroke": {
            { name: 'flip', options: { fallbackPlacements: ['top','bottom','right','left'] } }
                    "width": 0,
        ]
                    "color": "#000000"
    }
                },
});
                "polygon": {
                    "nb_sides": 5
                }
            },
            "opacity": {
                "value": 0.5,
                "random": false,
                "anim": {
                    "enable": false,
                    "speed": 1,
                    "opacity_min": 0.1,
                    "sync": false
                }
            },
            "size": {
                "value": 3,
                "random": true,
                "anim": {
                    "enable": false,
                    "speed": 40,
                    "size_min": 0.1,
                    "sync": false
                }
            },
            "line_linked": {
                "enable": true,
                "distance": 150,
                "color": "#ffffff",
                "opacity": 0.4,
                "width": 1
            },
            "move": {
                "enable": true,
                "speed": 6,
                "direction": "none",
                "random": false,
                "straight": false,
                "out_mode": "out",
                "bounce": false,
                "attract": {
                    "enable": false,
                    "rotateX": 600,
                    "rotateY": 1200
                }
            }
        },
        "interactivity": {
            "detect_on": "canvas",
            "events": {
                "onhover": {
                    "enable": true,
                    "mode": "repulse"
                },
                "onclick": {
                    "enable": true,
                    "mode": "push"
                },
                "resize": true
            },
            "modes": {
                "grab": {
                    "distance": 400,
                    "line_linked": {
                        "opacity": 1
                    }
                },
                "bubble": {
                    "distance": 400,
                    "size": 40,
                    "duration": 2,
                    "opacity": 8,
                    "speed": 3
                },
                "repulse": {
                    "distance": 200,
                    "duration": 0.4
                },
                "push": {
                    "particles_nb": 4
                },
                "remove": {
                    "particles_nb": 2
                }
            }
        },
        "retina_detect": true
     });
     });
}
});
});

Версия от 12:52, 30 августа 2025

$(document).ready(function() {
    // Инициализация боковой панели
    $('.боковая-панель-кнопка').on('click', function() {
        var targetId = $(this).data('target');
        
        // Удаляем активный класс у всех кнопок
        $('.боковая-панель-кнопка').removeClass('active');
        // Добавляем активный класс текущей кнопке
        $(this).addClass('active');
        
        // Скрываем все разделы
        $('.боковая-панель-раздел').removeClass('default');
        // Показываем выбранный раздел
        $('#' + targetId).addClass('default');
    });
    
    // Активируем первую кнопку по умолчанию
    $('.боковая-панель-кнопка:first').click();
    
    // Подключаем Tippy.js через CDN динамически
if (!window.tippy) {
    var tippyScript = document.createElement('script');
    tippyScript.src = "https://unpkg.com/@popperjs/core@2/dist/umd/popper.min.js";
    tippyScript.onload = function() {
        var tippyCoreScript = document.createElement('script');
        tippyCoreScript.src = "https://unpkg.com/tippy.js@6/dist/tippy-bundle.umd.min.js";
        tippyCoreScript.onload = initTippy;
        document.head.appendChild(tippyCoreScript);
    };
    document.head.appendChild(tippyScript);

    // Подключаем CSS
    var tippyCSS = document.createElement('link');
    tippyCSS.rel = "stylesheet";
    tippyCSS.href = "https://unpkg.com/tippy.js@6/dist/tippy.css";
    document.head.appendChild(tippyCSS);
} else {
    initTippy();
}

// Инициализация Tippy после загрузки скриптов
function initTippy() {
    $('.допуск-контейнер').each(function() {
        var content = $(this).find('.допуск-подсказка').html(); // берем содержимое подсказки
		tippy('.допуск-контейнер', {
		    content: (reference) => reference.getAttribute('data-tooltip'),
		    allowHTML: true,
		    interactive: true,
		    placement: 'auto',
		    maxWidth: '80vw',
		    theme: 'dark',
		    arrow: false,
		    duration: [200, 200],
		    popperOptions: {
		        modifiers: [
		            { name: 'preventOverflow', options: { padding: 8 } },
		            { name: 'flip', options: { fallbackPlacements: ['top','bottom','right','left'] } }
		        ]
		    }
		});
    });
}

});