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

мНет описания правки
Метка: отменено
м Отмена версии 83111, сделанной Pok (обсуждение)
Метка: отмена
Строка 1275: Строка 1275:
// wiki import end
// wiki import end


;(function($, mw) {
;(function($, mw){
     const COOKIE = 'ss14_wikiTheme';
     const COOKIE = 'ss14_wikiTheme';


Строка 1304: Строка 1304:
             class: 'mw-portlet mw-portlet-skin-client-prefs-skin-theme mw-portlet-js theme-menu',
             class: 'mw-portlet mw-portlet-skin-client-prefs-skin-theme mw-portlet-js theme-menu',
             id: 'skin-client-prefs-skin-theme'
             id: 'skin-client-prefs-skin-theme'
         }).append(
         });
        $portlet.append(
             $('<div>', { class: 'theme-menu__heading', text: 'Тема' }),
             $('<div>', { class: 'theme-menu__heading', text: 'Тема' }),
             $('<div>', { class: 'theme-menu__content' })
             $('<div>', { class: 'theme-menu__content' })
Строка 1348: Строка 1349:
     }
     }


     function createSettingsDropdown(currentTheme) {
     mw.themeUtils = { loadTheme, applyTheme, initThemeMenu };
        const $dropdown = $('<div>', { class: 'theme-dropdown' });
}(jQuery, mediaWiki));
        const $details = $('<details>', {
 
            id: 'theme-preferences-details',
;(function($, mw) {
            class: 'theme-dropdown-details'
    mw.loader.using('ext.gadget.theme').then(function() {
        });
        const { loadTheme, initThemeMenu } = mw.themeUtils;
        const $summary = $('<summary>', {
 
            class: 'theme-dropdown-summary',
        function createSettingsDropdown(currentTheme) {
            'data-tooltip-initialized': 'true'
            const $dropdown = $('<div>', { class: 'theme-dropdown' });
        }).append($('<span>', { class: 'theme-icon theme-icon-settings' }));
            const $details = $('<details>', { id: 'theme-preferences-details', class: 'theme-dropdown-details' });
        const $window = $('<div>', {
            const $summary = $('<summary>', { class: 'theme-dropdown-summary', 'data-tooltip-initialized': 'true' })
            id: 'theme-preferences',
                .append($('<span>', { class: 'theme-icon theme-icon-settings' }));
            class: 'theme-window'
            $details.append($summary);
        }).hide();
 
        const $header = $('<div>', {
            const $window = $('<div>', { id: 'theme-preferences', class: 'theme-window' }).hide();
            class: 'theme-window__header',
            const $header = $('<div>', {
            text: 'Параметры'
                id: 'theme-preferences__header',
        });
                class: 'theme-window__header',
        const $content = $('<div>', {
                text: 'Параметры'
            id: 'theme-preferences__content',
            });
            class: 'theme-window__content'
            $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').append($dropdown);


        $window.append($header, $content);
            const $cover = $('#menus-cover');
        $details.append($summary);
        $dropdown.append($details, $window);
        $('#user-tools').append($dropdown);


        initThemeMenu($content, currentTheme);
            $details.on('toggle', function() {
                const isOpen = $(this).prop('open');
                $window.toggle(isOpen);


        const $cover = $('#menus-cover');
        $details.on('toggle', function() {
            const isOpen = $(this).prop('open');
            $window.toggle(isOpen);
            if ($cover.length) {
                $cover.css('display', isOpen ? 'block' : 'none');
            }
        });
        $(document).on('click', function(e) {
            if (!$(e.target).closest('.theme-window, .theme-dropdown-summary').length && $details.prop('open')) {
                $details.removeAttr('open');
                 if ($cover.length) {
                 if ($cover.length) {
                     $cover.css('display', 'none');
                     $cover.css('display', isOpen ? 'block' : 'none');
                }
            });
 
            $(document).on('click', function(e) {
                const isClickInside = $(e.target).closest('.theme-window, .theme-dropdown-summary').length > 0;
                if (!isClickInside && $details.prop('open')) {
                    $details.removeAttr('open');
                    if ($cover.length) {
                        $cover.css('display', 'none');
                    }
                 }
                 }
             }
             });
        });
        }
    }


    function init() {
        function init() {
        const theme = loadTheme();
            const theme = loadTheme();
        applyTheme(theme);
            createSettingsDropdown(theme);
         createSettingsDropdown(theme);
         }
    }


    mw.loader.using(['jquery.cookie']).then(function() {
         $(init);
         $(init);
     });
     });
}(jQuery, mediaWiki));
}(jQuery, mediaWiki));