Content deleted Content added
suggestions |
No edit summary |
||
(26 intermediate revisions by 2 users not shown) | |||
Line 34:
function vectorStickyCallback() {
makePortletLink('p-personal-sticky-header', 'pt-darkmode-sticky-header', '#pt-watchlist-sticky-header');▼
mw.hook('vector.page_title_scroll').remove(vectorStickyCallback);
if (document.getElementById('pt-darkmode-sticky-header')) return;
▲ makePortletLink('p-personal-sticky-header', 'pt-darkmode-sticky-header', '#pt-watchlist-sticky-header');
}
Line 46 ⟶ 45:
mw.hook('vector.page_title_scroll').add(vectorStickyCallback);
}
}
function getMsg(suffix) {
var key = 'darkmode-turn-' + (isOn ? 'off' : 'on') + '-' + suffix;
return mw.msg(key);
}
function makePortletLink(portletId, portletLinkId, nextnode) {
var
var
$(mw.util.addPortletLink(portletId, '#', label, portletLinkId, tooltip, '', nextnode))
.children().on('click', function (e) {
Line 60 ⟶ 63:
function togglePortlets() {
var labelSelector;
switch (mw.config.get('skin')) {
Line 68:
case 'vector-2022':
case 'minerva':
labelSelector = '#pt-darkmode span:not(
break;
default:
labelSelector = '#pt-darkmode a';
}
$(labelSelector).text(
$('#pt-darkmode a, #pt-darkmode-sticky-header a')
.attr('title',
}
Line 84:
var $gadgetsLink = $('link[rel="stylesheet"][href^="' + scriptPath + '?"][href*="ext.gadget."]');
if ($gadgetsLink.length) {
var
var modules = url.searchParams.get('modules');
if (isOn) {
} else {
if (
// dark-mode is the only module in this link
$gadgetsLink.remove();
return;
}
.replace('ext.gadget.dark-mode,', 'ext.gadget.') // dark-mode is first in the gadget list
.replace(/,dark-mode(,|$)/, '$1'); // dark-mode is in middle or end of the list
}
url.searchParams.set('modules', modules);
$gadgetsLink.prop('href',
} else {
// No gadget-containing styles are enabled
Line 113 ⟶ 115:
function savePreferenceLocally() {
mw.user.options.set('gadget-dark-mode', Number(isOn));
// In case the user navigates to another page too quickly
mw.storage.session.set('dark-mode-toggled', isOn ? '1' : '0');
Line 150 ⟶ 154:
$.when($.ready, mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Uri', 'mediawiki.storage
setHtmlClass();
setThemeColor();
|