Debian Codegraph @

skins/Vector/resources/skins.vector.js/echo.js

raw symbols SCIP
1 /**
2 * Upgrades Echo for icon consistency.
3 * Undos work inside Echo to replace our button.
4 */
5 function init() {
6 if ( document.querySelectorAll( '#pt-notifications-alert a, #pt-notifications-notice a' ).length !== 2 ) {
7 return;
8 }
9
10 mw.hook( 'ext.echo.NotificationBadgeWidget.onInitialize' ).add( ( badge ) => {
11 const element = badge.$element[ 0 ];
12 element.classList.add( 'mw-list-item' );
13 const anchor = /** @type {HTMLElement} */ ( element.querySelector( 'a' ) );
14 anchor.classList.add(
15 'cdx-button',
16 'cdx-button--weight-quiet',
17 'cdx-button--icon-only',
18 'cdx-button--fake-button',
19 'cdx-button--fake-button--enabled'
20 );
21 // Icon classes shouldn't go on the same element as button classes
22 // However this cant be avoided due to Echo button's implementation
23 // which directly sets the contents of the anchor element every update
24 // which would clear out any icon children that we define
25 if ( element.id === 'pt-notifications-alert' ) {
26 anchor.classList.add( 'vector-icon' );
27 }
28 if ( element.id === 'pt-notifications-notice' ) {
29 anchor.classList.add( 'vector-icon' );
30 }
31 // Workaround T343838
32 anchor.classList.add( 'skin-invert' );
33 } );
34 }
35
36 module.exports = init;