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

мНет описания правки
мНет описания правки
Строка 1275: Строка 1275:
// wiki import end
// wiki import end


mw.loader.using('ext.gadget.theme', function(){
;(function($, mw) {
  $(function(){
    mw.loader.using('ext.gadget.theme').then(function() {
    if ( mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok' ) return;
        const { loadTheme, initThemeMenu } = mw.themeUtils;
    const theme = mw.themeUtils.loadTheme();
    createSettingsDropdown(theme);
  });
});


;(function($, mw){
        function createSettingsDropdown(currentTheme) {
    const { loadTheme, initThemeMenu } = mw.themeUtils;
            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);


    function createSettingsDropdown(currentTheme) {
            const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' }).hide();
        const $dropdown = $('<div>', { class: 'theme-dropdown' });
            const $header = $('<div>', {
        const $details = $('<details>', { id: 'theme-preferences-details', class: 'theme-dropdown-details' });
                id: 'theme-preferences__header',
        const $summary = $('<summary>', { class: 'theme-dropdown-summary', 'data-tooltip-initialized': 'true' })
                class: 'theme-window__header',
             .append($('<span>', { class: 'theme-icon theme-icon-settings' }));
                text: 'Параметры'
        $details.append($summary);
             });
            $window.append($header);


        const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' }).hide();
            const $content = $('<div>', {
        const $header = $('<div>', {
                id: 'theme-preferences__content',
            id: 'theme-preferences__header',
                class: 'theme-window__content'
            class: 'theme-window__header',
             });
             text: 'Параметры'
            $window.append($content);
        });
        $window.append($header);


        const $content = $('<div>', {
             initThemeMenu($content, currentTheme);
             id: 'theme-preferences__content',
            class: 'theme-window__content'
        });
        $window.append($content);


        initThemeMenu($content, currentTheme);
            $dropdown.append($details, $window);
            $('#user-tools').prepend($dropdown);


        $dropdown.append($details, $window);
            $details.on('toggle', function() {
        $('#user-tools').prepend($dropdown);
                $(this).prop('open') ? $window.show() : $window.hide();
            });
        }


         $details.on('toggle', function() {
         function init() {
             $(this).prop('open') ? $window.show() : $window.hide();
             if (mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok') return;
        });
            const theme = loadTheme();
    }
            createSettingsDropdown(theme);
        }


    function init() {
         $(init);
         if (mw.config.get('wgPageName') !== 'Обсуждение_участника:Pok') return;
     });
        const theme = loadTheme();
        createSettingsDropdown(theme);
     }
 
    $(init);
}(jQuery, mediaWiki));
}(jQuery, mediaWiki));