MediaWiki:Common.js: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 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 $ | const $wrapper = $('<div>', { class: 'theme-client-prefs-radio' }); | ||
const $input = $('<input>', { | const $input = $('<input>', { | ||
type: 'radio', | type: 'radio', name: 'theme-selection', | ||
id: `theme-value-${item.key}`, value: item.key, | |||
id: `theme-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 }); | ||
$ | $wrapper.append($input, $label); | ||
$form.append($ | $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(); | ||
$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 | initThemeMenu($window, currentTheme); | ||
$dropdown.append($details, $window); | $dropdown.append($details, $window); | ||
$('#user-tools').append($dropdown); | $('#user-tools').append($dropdown); | ||
$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(); | ||
createSettingsDropdown(theme); | createSettingsDropdown(theme); | ||
} | } | ||