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

Страница интерфейса MediaWiki
Нет описания правки
Метка: отменено
Нет описания правки
Метка: ручная отмена
Строка 19: Строка 19:
      
      
     // Подключаем Tippy.js через CDN динамически
     // Подключаем Tippy.js через CDN динамически
mw.loader.load('https://unpkg.com/@popperjs/core@2/dist/umd/popper.min.js', function() {
if (!window.tippy) {
    mw.loader.load('https://unpkg.com/tippy.js@6/dist/tippy-bundle.umd.min.js', function() {
    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 Tippy
    // Подключаем CSS
        var tippyCSS = document.createElement('link');
    var tippyCSS = document.createElement('link');
        tippyCSS.rel = 'stylesheet';
    tippyCSS.rel = "stylesheet";
        tippyCSS.href = 'https://unpkg.com/tippy.js@6/dist/tippy.css';
    tippyCSS.href = "https://unpkg.com/tippy.js@6/dist/tippy.css";
        document.head.appendChild(tippyCSS);
    document.head.appendChild(tippyCSS);
} else {
    initTippy();
}


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


});
});

Версия от 12:57, 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(this, {
            content: content,
            allowHTML: true,
            interactive: true,
            placement: 'auto',      // автоматический выбор позиции
            maxWidth: '80vw',       // responsive
            theme: 'dark',          // темная тема
            arrow: false,           // без стрелки
            duration: [200, 200],   // плавное появление/исчезание
            popperOptions: {
                modifiers: [
                    {
                        name: 'preventOverflow',
                        options: {
                            padding: 8, // отступ от краев экрана
                        },
                    },
                    {
                        name: 'flip',
                        options: {
                            fallbackPlacements: ['top', 'bottom', 'right', 'left'],
                        },
                    },
                ],
            },
        });
    });
}

});