|
|
Line 601: |
Line 601: |
| $(window).resize(setStickyHeaderTop); | | $(window).resize(setStickyHeaderTop); |
| } | | } |
|
| |
| // Dark mode
| |
| // Initialize element
| |
| var newDiv = document.createElement('div');
| |
| newDiv.classList.toggle('noticebox');
| |
| newDiv.style.cssText = 'display:none; max-width:100%; width:100%; text-align:center;';
| |
| darkModeNoticeElem = newDiv;
| |
| const cnElem = document.getElementById('mw-content');
| |
| if (cnElem !== null) {
| |
| cnElem.insertBefore(darkModeNoticeElem, cnElem.firstChild);
| |
| }
| |
|
| |
| if (!darkModeNoticeDismissed) {
| |
| darkModeNoticeToggle();
| |
| if (darkModeSchemeQuery.addEventListener) {
| |
| darkModeSchemeQuery.addEventListener('change', darkModeNoticeToggle);
| |
| }
| |
| }
| |
| });
| |
|
| |
|
| |
| // Add dark mode links to "Wiki tools" and personal tools menus
| |
| $.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() {
| |
| var dmLinkTools = mw.util.addPortletLink('p-tb', '#', 'Dark mode', 't-darkmode', 'Toggle between a dark and light theme', null, '#t-specialpages');
| |
| var dmLinkPersonal = mw.util.addPortletLink('p-personal', '#', 'Dark mode', 'pt-darkmode', 'Toggle between a dark and light theme', null, null);
| |
| dmLinkPersonal.style.marginTop = '0.5rem';
| |
| $(dmLinkTools).on('click', function(e) {
| |
| e.preventDefault();
| |
| darkModeNoticeVisible(true);
| |
| });
| |
| $(dmLinkPersonal).on('click', function(e) {
| |
| e.preventDefault();
| |
| darkModeNoticeVisible(true);
| |
| });
| |
| }); | | }); |