const makeTemplate = function () { const templateString = `
`; const templateElement = document.createElement( 'div' ); templateElement.id = 'vector-dark-mode-launch-banner'; templateElement.innerHTML = templateString; return templateElement; }; function closeModal() { const modal = document.getElementById( 'vector-dark-mode-launch-banner' ); if ( modal ) { modal.remove(); } } function init() { const mountElement = document.getElementById( 'mw-teleport-target' ), isNotSkinVector2022 = mw.config.get( 'skin' ) !== 'vector-2022', templateElement = makeTemplate(), dialogOverlay = templateElement.querySelector( '.cdx-dialog-backdrop' ), dialogCloseButton = templateElement.querySelector( '.cdx-dialog__header__close-button' ); // since this can module can run via centralNotice, ensuring the currect skin is Vector 2022 if ( isNotSkinVector2022 ) { return; } if ( dialogOverlay ) { dialogOverlay.addEventListener( 'click', ( e ) => { if ( e.target === dialogOverlay ) { closeModal(); } } ); } if ( dialogCloseButton ) { dialogCloseButton.addEventListener( 'click', closeModal ); } if ( mountElement ) { mountElement.appendChild( templateElement ); } } module.exports = init;