Content deleted Content added
No edit summary |
No edit summary |
||
(22 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 49 ⟶ 48:
function getMsg(suffix) {
var key = 'darkmode-turn-' + (isOn ? '
return mw.msg(key);
}
Line 69 ⟶ 68:
case 'vector-2022':
case 'minerva':
labelSelector = '#pt-darkmode span:not(
break;
default:
Line 85 ⟶ 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 114 ⟶ 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');
|