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

мНет описания правки
мНет описания правки
Строка 1: Строка 1:
// Theme module
;(function($, mw){
;(function($, mw){
     const COOKIES = { THEME: 'theme', DARK: 'darkmode' };
     const COOKIES = { THEME: 'theme', DARK: 'darkmode' };
Строка 31: Строка 32:


         themes.forEach(item => {
         themes.forEach(item => {
             const $radioWrapper = $('<div>', { class: 'theme-client-prefs-radio' });
             const $wrapper = $('<div>', { class: 'theme-client-prefs-radio' });
             const $input = $('<input>', {
             const $input = $('<input>', {
                 type: 'radio',
                 type: 'radio', name: 'theme-selection',
                name: 'theme-selection',
                 id: `theme-value-${item.key}`, value: item.key,
                 id: `theme-value-${item.key}`,
                value: item.key,
                 checked: item.key === currentTheme
                 checked: item.key === currentTheme
             });
             });
             const $label = $('<label>', { for: `theme-value-${item.key}`, text: item.label });
             const $label = $('<label>', { for: `theme-value-${item.key}`, text: item.label });
             $radioWrapper.append($input, $label);
             $wrapper.append($input, $label);
             $form.append($radioWrapper);
             $form.append($wrapper);
         });
         });
         $item.append($form);
         $item.append($form);
         $list.append($item);
         $list.append($item);
Строка 55: Строка 53:
         });
         });
     }
     }
    mw.themeUtils = { loadTheme, applyTheme, initThemeMenu };
}(jQuery, mediaWiki));
// Settings dropdown module
;(function($, mw){
    const { loadTheme, initThemeMenu } = mw.themeUtils;


     function createSettingsDropdown(currentTheme) {
     function createSettingsDropdown(currentTheme) {
Строка 63: Строка 68:
         $details.append($summary);
         $details.append($summary);


         const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' });
         const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' }).hide();
        const $tabs = $('<div>', { class: 'theme-window__tabs' }); // placeholder for future tabs
         $window.append($('<div>', { id: 'theme-preferences__header', class: 'theme-window__header', text: 'Параметры' }));
         $window.append($('<div>', { id: 'theme-preferences__header', class: 'theme-window__header', text: 'Параметры' }));
         $window.append($tabs);
         initThemeMenu($window, currentTheme);


        $details.after($window);
         $dropdown.append($details, $window);
         $dropdown.append($details, $window);
         $('#user-tools').append($dropdown);
         $('#user-tools').append($dropdown);


         initThemeMenu($window, currentTheme);
         $details.on('toggle', function() {
            $(this).prop('open') ? $window.show() : $window.hide();
        });
     }
     }


Строка 78: Строка 83:
         if (mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok') return;
         if (mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok') return;
         const theme = loadTheme();
         const theme = loadTheme();
        applyTheme(theme);
         createSettingsDropdown(theme);
         createSettingsDropdown(theme);
     }
     }