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

Новая страница: «;(function($, mw){ const COOKIES = { THEME: 'ss14_wikiTheme', DARK: 'darkmode' }; function loadTheme() { const saved = $.cookie(COOKIES.THEME); return saved || 'normal'; } function saveTheme(theme) { $.cookie(COOKIES.THEME, theme, { expires: 365, path: '/' }); $.cookie(COOKIES.DARK, theme === 'dark', { expires: 365, path: '/' }); } function applyTheme(theme) { $('body') .removeCla...»
 
мНет описания правки
Строка 1: Строка 1:
;(function($, mw){
    const { loadTheme, initThemeMenu } = mw.themeUtils;
    function createSettingsDropdown(currentTheme) {
        const $dropdown = $('<div>', { class: 'theme-dropdown' });
        const $details = $('<details>', { id: 'theme-preferences-details', class: 'theme-dropdown-details' });
        const $summary = $('<summary>', { class: 'theme-dropdown-summary', 'data-tooltip-initialized': 'true' })
            .append($('<span>', { class: 'theme-icon theme-icon-settings' }));
        $details.append($summary);
        const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' }).hide();
        const $header = $('<div>', {
            id: 'theme-preferences__header',
            class: 'theme-window__header',
            text: 'Параметры'
        });
        $window.append($header);
        const $content = $('<div>', {
            id: 'theme-preferences__content',
            class: 'theme-window__content'
        });
        $window.append($content);
        initThemeMenu($content, currentTheme);
        $dropdown.append($details, $window);
        $('#user-tools').prepend($dropdown);
        $details.on('toggle', function() {
            $(this).prop('open') ? $window.show() : $window.hide();
        });
    }
    function init() {
        if (mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok') return;
        const theme = loadTheme();
        createSettingsDropdown(theme);
    }
    $(init);
}(jQuery, mediaWiki));
;(function($, mw){
;(function($, mw){
     const COOKIES = { THEME: 'ss14_wikiTheme', DARK: 'darkmode' };
     const COOKIES = { THEME: 'ss14_wikiTheme', DARK: 'darkmode' };