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

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


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


Строка 1349: Строка 1349:
     }
     }


    mw.themeUtils = { loadTheme, saveTheme, applyTheme, initThemeMenu };
     function createSettingsDropdown(currentTheme) {
 
     function createSettingsDropdown() {
        const currentTheme = loadTheme();
         const $dropdown = $('<div>', { class: 'theme-dropdown' });
         const $dropdown = $('<div>', { class: 'theme-dropdown' });
         const $details = $('<details>', { id: 'theme-preferences-details', class: 'theme-dropdown-details' });
         const $details = $('<details>', { id: 'theme-preferences-details', class: 'theme-dropdown-details' });
Строка 1373: Строка 1370:
         $window.append($content);
         $window.append($content);


         initThemeMenu($content);
         initThemeMenu($content, currentTheme);


         $dropdown.append($details, $window);
         $dropdown.append($details, $window);
Строка 1383: Строка 1380:
             const isOpen = $(this).prop('open');
             const isOpen = $(this).prop('open');
             $window.toggle(isOpen);
             $window.toggle(isOpen);
             if ($cover.length) {
             if ($cover.length) {
                 $cover.css('display', isOpen ? 'block' : 'none');
                 $cover.css('display', isOpen ? 'block' : 'none');
Строка 1389: Строка 1387:


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


     $(function() {
     function init() {
         applyTheme(loadTheme());
         const theme = loadTheme();
         createSettingsDropdown();
        applyTheme(theme);
     });
         createSettingsDropdown(theme);
}(jQuery, mediaWiki));
     }
 
    $(init);
 
})(jQuery, mediaWiki);