Content deleted Content added
No edit summary |
No edit summary |
||
(33 intermediate revisions by 2 users not shown) | |||
Line 31:
// For others, update Gadget-dark-mode.css directly which is loaded without FOUCs
$(document.documentElement).toggleClass('client-dark-mode', isOn);
}
function vectorStickyCallback() {
mw.hook('vector.page_title_scroll').remove(vectorStickyCallback);
if (document.getElementById('pt-darkmode-sticky-header')) return;
}
Line 37 ⟶ 43:
if (mw.config.get('skin') === 'vector-2022') {
mw.
▲ makePortletLink('p-personal-sticky-header', 'pt-darkmode-sticky-header', '#pt-watchlist-sticky-header');
}
}
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) {
e.preventDefault();
toggleMode();
Line 55 ⟶ 63:
function togglePortlets() {
var labelSelector;
switch (mw.config.get('skin')) {
case 'vector':
case 'vector-2022':
case 'minerva':
$(labelSelector).text(mw.msg('darkmode-turn-' + onOrOff + '-label'));▼
break;
default:
labelSelector = '#pt-darkmode a';
}
$('#pt-darkmode a, #pt-darkmode-sticky-header a')
.attr('title', getMsg('tooltip'));
}
Line 69 ⟶ 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 137 ⟶ 154:
$.when($.ready, mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Uri', 'mediawiki.storage
setHtmlClass();
setThemeColor();
// Recover state if the navigation was too quick
|