MediaWiki:Gadget-dark-mode-toggle.js: Difference between revisions
Content deleted Content added
[follow up] Add day theme class to allow the control to show and be disabled in case of race condition Tag: Reverted |
Improves on yesterday's solution. This now has clearer actionable steps. Tag: Reverted |
||
Line 125:
function checkDisableNativeDarkMode() {
const appearanceMenu = document.getElementById( 'skin-client-prefs-skin-theme' );
// If the appearance menu is not present, try again in 1s. The UI hasn't stabilised yet.
if ( !appearanceMenu ) {
setTimeout( () => {
checkDisableNativeDarkMode();
}, 1000 );
return;
}
const classList = document.documentElement.classList;
const lightMode =
if ( lightMode && !lightMode.checked ) {
classList.add( 'skin-theme-clientpref-day' );
mw.notify(
`<span>Native dark mode has been enabled. Please set "Color" to light theme to avoid conflicts with the dark mode gadget to supress this message. <a href="https://en.wikipedia.org/w/index.php?title=MediaWiki%3AGadget-dark-mode">More information</a></span>`
) );
} else {
// everything is good - just disable the radios!
$(appearanceMenu).find('input').prop('disabled', true);
// add exclusion notice
const p = document.createElement('p');
p.setAttribute('class','exclusion-notice skin-theme-exclusion-notice');
p.textContent = 'This has been disabled by the dark mode gadget. Disable the gadget to use this feature.';
$( p ).insertAfter( $(appearanceMenu).find( 'form' ) );
}
}
|